Create Warehouse
This POST API allows you to create new warehouses for a specific company. The endpoint supports providing detailed address information, shipping zones, and inventory details.
Endpoint Details
- URL:
/warehouse/create - Method:
POST - Authentication: Bearer Token (required)
Authentication
You must provide a valid accessToken in the request headers to authenticate and access this endpoint.
Authentication Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be set to application/json. |
accessToken | string | A valid access token is required. |
Request Body
The request body must be a JSON object that includes the details required for creating a warehouse:
| Field | Type | Description |
|---|---|---|
name | string | The name of the warehouse. (required) |
country | string | The country where the warehouse is located. (required) |
active | boolean | Indicates whether the warehouse is active. (required) |
default | boolean | Indicates whether this is the default warehouse. |
address | object | Detailed address information for the warehouse. (required) |
shippingZones | array | List of shipping zone IDs associated with the warehouse. (optional) |
inventory | array | Inventory information for products stored in the warehouse. (optional) |
Address Object (address)
The address object contains detailed address information:
| Field | Type | Description |
|---|---|---|
firstName | string | First name of the contact person at the warehouse. (required) |
lastName | string | Last name of the contact person at the warehouse. (required) |
address1 | string | Primary address line. (required) |
address2 | string | Secondary address line. (optional, can be null or empty) |
city | string | City where the warehouse is located. (required) |
state | string | State where the warehouse is located. (required) |
country | string | Country where the warehouse is located. (required) |
zipcode | string | Zip code of the warehouse location. (required) |
Inventory Object (inventory[])
Each object in the inventory array represents a product's inventory details:
| Field | Type | Description |
|---|---|---|
productId | string | Unique identifier for the product. |
stock | number | Current stock level of the product. |
minStock | number | Minimum stock level for the product before reordering. |
variants | array | Details about product variants, if any. (optional) |
Variant Object (variants[])
Each object in the variants array represents a variant's inventory details:
| Field | Type | Description |
|---|---|---|
variantId | string | Unique identifier for the variant. |
stock | number | Current stock level of the variant. |
minStock | number | Minimum stock level for the variant before reordering. |
Sample Request Body
{
"name": "New York Central Warehouse",
"country": "US",
"active": true,
"default": true,
"address": {
"firstName": "Alex",
"lastName": "Johnson",
"address1": "150 Main St",
"address2": "Suite 200",
"city": "New York",
"state": "NY",
"country": "US",
"zipcode": "10001"
},
"shippingZones": ["6ae3599858dec23921d0c089"],
"inventory": [
{
"productId": "76b4a11249e6ce3d41c428fa",
"stock": 0,
"minStock": 0,
"variants": [
{
"variantId": "76d5a286fcb786834cebb168",
"stock": 150,
"minStock": 10
}
]
},
{
"productId": "75b88ef6045a7d009e79cb6c",
"stock": 300,
"minStock": 30
}
]
}
Response
Success Response
| Status Code | Description |
|---|---|
| 200 OK | The request was successful, and the warehouse was created. |
Success Response Body Structure
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
message | string | Message indicating the result of the operation. |
data | object | Contains the details of the newly created warehouse. |
Sample Response Body
{
"success": true,
"message": "Warehouse created successfully",
"data": {
"name": "New York Central Warehouse",
"country": "US",
"active": true,
"default": true,
"address": {
"firstName": "Alex",
"lastName": "Johnson",
"address1": "150 Main St",
"address2": "Suite 200",
"city": "New York",
"state": "NY",
"country": "US",
"zipcode": "10001"
},
"shippingZones": ["6ae3599858dec23921d0c089"],
"inventory": [
{
"productId": "76b4a11249e6ce3d41c428fa",
"stock": 200,
"minStock": 20,
"variants": [
{
"variantId": "76d5a286fcb786834cebb168",
"stock": 150,
"minStock": 10
}
]
},
{
"productId": "75b88ef6045a7d009e79cb6c",
"stock": 300,
"minStock": 30
}
],
"createdAt": "2024-01-10T12:00:00Z",
"updatedAt": "2024-01-12T12:00:00Z",
"id": "76b9b3b166169eecd60e5ba9"
}
}
Data Object (data)
The data object in the response contains the following fields, representing the newly created warehouse:
| Field | Type | Description |
|---|---|---|
name | string | Name of the warehouse. |
country | string | Country where the warehouse is located. |
active | boolean | Indicates whether the warehouse is active. |
default | boolean | Indicates whether this is the default warehouse. |
address | object | Detailed address information for the warehouse. |
shippingZones | array | List of shipping zone IDs associated with the warehouse. |
inventory | array | Inventory information for products stored in the warehouse. |
createdAt | string | Timestamp when the warehouse was created (ISO format). |
updatedAt | string | Timestamp when the warehouse was last updated (ISO format). |
id | string | Unique identifier for the warehouse. |
Address Object (address)
The address object contains detailed address information:
| Field | Type | Description |
|---|---|---|
firstName | string | First name of the contact person at the warehouse. |
lastName | string | Last name of the contact person at the warehouse. |
address1 | string | Primary address line. |
address2 | string | Secondary address line. |
city | string | City where the warehouse is located.. |
state | string | State where the warehouse is located (contains name and code). |
country | string | Country where the warehouse is located (contains name and code). |
zipcode | string | Zip code of the warehouse location. |
Inventory Object (inventory[])
Each object in the inventory array represents a product's inventory details:
| Field | Type | Description |
|---|---|---|
productId | string | Unique identifier for the product. |
stock | number | Current stock level of the product. |
minStock | number | Minimum stock level for the product before reordering. |
variants | array | Details about product variants, if any. (optional) |
Variant Object (variants[])
Each object in the variants array represents a variant's inventory details:
| Field | Type | Description |
|---|---|---|
variantId | string | Unique identifier for the variant. |
stock | number | Current stock level of the variant. |
minStock | number | Minimum stock level for the variant before reordering. |
Error Responses
| Status Code | Description |
|---|---|
| 400 Bad Request | Invalid request format or missing data. |
| 401 Unauthorized | Invalid or missing access token. |
| 403 Forbidden | Access denied. |
| 404 Not Found | Company not found. |
| 500 Internal Server Error | Server encountered an error. |
Notes
- Make sure all required fields are included in the request body to avoid validation errors.
- The API requires a valid access token for authentication to create the warehouse successfully.