Update Warehouse
This PUT API allows you to update details of an existing warehouse including its address and inventory information. This endpoint supports specifying shipping zones and managing product inventory.
Endpoint Details
- URL:
/wareHouse/update/{warehouse_id} - Method:
PUT - Authentication: Bearer Token (required)
Path Parameters
| Parameter | Type | Description |
|---|---|---|
warehouse_id | string | The unique identifier of the warehouse to be updated. |
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 should be in JSON format and must contain the following details to update the warehouse:
| Field | Type | Description |
|---|---|---|
name | string | Name of the warehouse. |
country | string | Country code where the warehouse is located. |
active | boolean | Indicates if the warehouse is active. |
default | boolean | Indicates if this is the default warehouse. |
address | object | The address details for the warehouse. See the address object structure below. |
shippingZones | array | List of shipping zone IDs associated with the warehouse. |
inventory | array | List of inventory items with product IDs, stock, minStock, and optional variant details. |
Address Object (address)
The address object contains detailed address information:
| Field | Type | Description |
|---|---|---|
firstName | string | First name of the contact person. |
lastName | string | Last name of the contact person. |
address1 | string | Primary address line. |
address2 | string | Secondary address line. |
city | string | City where the warehouse is located. |
state | string | State code of the location. |
country | string | Country code. |
zipcode | string | Postal code of the warehouse. |
Inventory Object (inventory[])
Each object in the inventory array represents a product's inventory details:
| Field | Type | Description |
|---|---|---|
productId | string | The unique identifier of the product. |
stock | number | Current stock quantity of the product. |
minStock | number | Minimum stock threshold for the product. |
variants | array | List of variant objects, each with a variant ID, stock, and minStock values. |
Variant Object (variants[])
| Field | Type | Description |
|---|---|---|
variantId | string | The unique identifier of the product variant. |
stock | number | Current stock quantity of the variant. |
minStock | number | Minimum stock threshold for the variant. |
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 details were updated. |
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 updated warehouse. |
Sample Response Body
{
"success": true,
"message": "Warehouse updated 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"
}
}
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 | Warehouse not found. |
| 500 Internal Server Error | Server encountered an error. |
Notes
- Ensure that the
warehouse_idin the URL matches the actual ID of the warehouse you wish to update. - Make sure that all required fields are included in the request body to avoid validation errors.
- Use a valid access token for authentication to successfully update the warehouse details.