Skip to main content

Create Warehouse

Creates a new warehouse with its address, the shipping zones it serves and its starting stock levels.

HTTP Request​

  • URL: /wareHouse/create
  • Method: POST
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: READ_WRITE_WAREHOUSE

Request Body​

The request body must be JSON and contain the following fields:

FieldTypeRequiredDescription
nameStringYesName of the warehouse.
countryStringYesTwo-letter country code, for example US.
addressObjectNoAddress of the warehouse. See below.
inventoryArrayNoStock levels per product. See below. Leave out if there is no stock yet.
activeBooleanNoWhether the warehouse is active. Default is true.
defaultBooleanNoMake this your store's default warehouse. Default is false.
shippingZonesArrayNoIDs of the shipping zones this warehouse serves.

Address Object​

FieldTypeRequiredDescription
firstNameStringYesFirst name of the contact person.
lastNameStringYesLast name of the contact person.
address1StringYesStreet address.
address2StringNoAdditional address line.
cityStringYesCity.
stateStringYesState or province code, for example IL.
countryStringYesTwo-letter country code, for example US.
zipcodeStringYesPostal code.

Inventory Object​

FieldTypeRequiredDescription
productIdStringYesID of the product.
stockNumberNoUnits in stock. Default is 0.
minStockNumberNoLow-stock level. Default is 0.
variantsArrayNoStock per variant. See below.

Variant Object​

FieldTypeRequiredDescription
variantIdStringYesID of the variant.
stockNumberNoUnits in stock. Default is 0.
minStockNumberNoLow-stock level. Default is 0.

cURL Example​

curl --location '<BASE_URL>/wareHouse/create' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Chicago Distribution Center",
"country": "US",
"active": true,
"default": false,
"address": {
"firstName": "Marcus",
"lastName": "Reyes",
"address1": "2400 S Western Ave",
"address2": "Dock 4",
"city": "Chicago",
"state": "IL",
"country": "US",
"zipcode": "60608"
},
"shippingZones": ["66d36af6d1fc2890ebc32e0b"],
"inventory": [
{
"productId": "65b88ef5045a7d009e79974b",
"stock": 240,
"minStock": 25
},
{
"productId": "66b4a01249e6ce3d41c428fa",
"variants": [
{
"variantId": "66d5a286fcb786834cebb16a",
"stock": 500,
"minStock": 50
}
]
}
]
}'

Response​

  • 200 OK: The warehouse was created successfully.
  • 400 Bad Request: The access token is missing or invalid, does not have the required scope, or the request body is not valid.

Sample JSON Response​

{
"success": true,
"message": "WareHouse created Successfully",
"data": {
"_id": "6650c4b2e8a1f93d7c2b5e40",
"name": "Chicago Distribution Center",
"country": {
"code": "US",
"name": "United States"
},
"active": true,
"default": false,
"address": {
"firstName": "Marcus",
"lastName": "Reyes",
"address1": "2400 S Western Ave",
"address2": "Dock 4",
"city": "Chicago",
"state": {
"code": "IL",
"name": "Illinois"
},
"country": {
"code": "US",
"name": "United States"
},
"zipcode": "60608"
},
"shippingZones": ["66d36af6d1fc2890ebc32e0b"],
"inventory": [
{
"_id": "6650c4b2e8a1f93d7c2b5e41",
"productId": "65b88ef5045a7d009e79974b",
"stock": 240,
"minStock": 25,
"variants": []
},
{
"_id": "6650c4b2e8a1f93d7c2b5e42",
"productId": "66b4a01249e6ce3d41c428fa",
"stock": 0,
"minStock": 0,
"variants": [
{
"_id": "6650c4b2e8a1f93d7c2b5e43",
"variantId": "66d5a286fcb786834cebb16a",
"stock": 500,
"minStock": 50
}
]
}
],
"metaFields": [],
"createdAt": "2024-05-24T16:47:14.302Z",
"updatedAt": "2024-05-24T16:47:14.302Z"
}
}

Response Details​

FieldTypeDescription
successBooleanWhether the request was successful.
messageStringResult message.
dataObjectThe new warehouse. _id is the warehouse ID.

Warehouse Data​

The warehouse fields are described in Get Single Warehouse. Country and state codes are returned with their full names.

Notes​

  • If default is true, this warehouse becomes the default and any other warehouse is no longer the default.
  • Products or variants that are not found in your catalog are skipped.