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:
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Name of the warehouse. |
country | String | Yes | Two-letter country code, for example US. |
address | Object | No | Address of the warehouse. See below. |
inventory | Array | No | Stock levels per product. See below. Leave out if there is no stock yet. |
active | Boolean | No | Whether the warehouse is active. Default is true. |
default | Boolean | No | Make this your store's default warehouse. Default is false. |
shippingZones | Array | No | IDs of the shipping zones this warehouse serves. |
Address Object
| Field | Type | Required | Description |
|---|---|---|---|
firstName | String | Yes | First name of the contact person. |
lastName | String | Yes | Last name of the contact person. |
address1 | String | Yes | Street address. |
address2 | String | No | Additional address line. |
city | String | Yes | City. |
state | String | Yes | State or province code, for example IL. |
country | String | Yes | Two-letter country code, for example US. |
zipcode | String | Yes | Postal code. |
Inventory Object
| Field | Type | Required | Description |
|---|---|---|---|
productId | String | Yes | ID of the product. |
stock | Number | No | Units in stock. Default is 0. |
minStock | Number | No | Low-stock level. Default is 0. |
variants | Array | No | Stock per variant. See below. |
Variant Object
| Field | Type | Required | Description |
|---|---|---|---|
variantId | String | Yes | ID of the variant. |
stock | Number | No | Units in stock. Default is 0. |
minStock | Number | No | Low-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
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request was successful. |
message | String | Result message. |
data | Object | The 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
defaultistrue, 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.