Skip to main content

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

HeaderTypeDescription
Content-TypestringMust be set to application/json.
accessTokenstringA valid access token is required.

Request Body

The request body must be a JSON object that includes the details required for creating a warehouse:

FieldTypeDescription
namestringThe name of the warehouse. (required)
countrystringThe country where the warehouse is located. (required)
activebooleanIndicates whether the warehouse is active. (required)
defaultbooleanIndicates whether this is the default warehouse.
addressobjectDetailed address information for the warehouse. (required)
shippingZonesarrayList of shipping zone IDs associated with the warehouse. (optional)
inventoryarrayInventory information for products stored in the warehouse. (optional)

Address Object (address)

The address object contains detailed address information:

FieldTypeDescription
firstNamestringFirst name of the contact person at the warehouse. (required)
lastNamestringLast name of the contact person at the warehouse. (required)
address1stringPrimary address line. (required)
address2stringSecondary address line. (optional, can be null or empty)
citystringCity where the warehouse is located. (required)
statestringState where the warehouse is located. (required)
countrystringCountry where the warehouse is located. (required)
zipcodestringZip code of the warehouse location. (required)

Inventory Object (inventory[])

Each object in the inventory array represents a product's inventory details:

FieldTypeDescription
productIdstringUnique identifier for the product.
stocknumberCurrent stock level of the product.
minStocknumberMinimum stock level for the product before reordering.
variantsarrayDetails about product variants, if any. (optional)

Variant Object (variants[])

Each object in the variants array represents a variant's inventory details:

FieldTypeDescription
variantIdstringUnique identifier for the variant.
stocknumberCurrent stock level of the variant.
minStocknumberMinimum 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 CodeDescription
200 OKThe request was successful, and the warehouse was created.

Success Response Body Structure

FieldTypeDescription
successbooleanIndicates if the request was successful.
messagestringMessage indicating the result of the operation.
dataobjectContains 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:

FieldTypeDescription
namestringName of the warehouse.
countrystringCountry where the warehouse is located.
activebooleanIndicates whether the warehouse is active.
defaultbooleanIndicates whether this is the default warehouse.
addressobjectDetailed address information for the warehouse.
shippingZonesarrayList of shipping zone IDs associated with the warehouse.
inventoryarrayInventory information for products stored in the warehouse.
createdAtstringTimestamp when the warehouse was created (ISO format).
updatedAtstringTimestamp when the warehouse was last updated (ISO format).
idstringUnique identifier for the warehouse.

Address Object (address)

The address object contains detailed address information:

FieldTypeDescription
firstNamestringFirst name of the contact person at the warehouse.
lastNamestringLast name of the contact person at the warehouse.
address1stringPrimary address line.
address2stringSecondary address line.
citystringCity where the warehouse is located..
statestringState where the warehouse is located (contains name and code).
countrystringCountry where the warehouse is located (contains name and code).
zipcodestringZip code of the warehouse location.

Inventory Object (inventory[])

Each object in the inventory array represents a product's inventory details:

FieldTypeDescription
productIdstringUnique identifier for the product.
stocknumberCurrent stock level of the product.
minStocknumberMinimum stock level for the product before reordering.
variantsarrayDetails about product variants, if any. (optional)

Variant Object (variants[])

Each object in the variants array represents a variant's inventory details:

FieldTypeDescription
variantIdstringUnique identifier for the variant.
stocknumberCurrent stock level of the variant.
minStocknumberMinimum stock level for the variant before reordering.

Error Responses

Status CodeDescription
400 Bad RequestInvalid request format or missing data.
401 UnauthorizedInvalid or missing access token.
403 ForbiddenAccess denied.
404 Not FoundCompany not found.
500 Internal Server ErrorServer 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.