Update Product Inventory
The PUT endpoint allows you to update the inventory levels of multiple products or product variants.
Endpoint
- URL:
/products/inventory - Method:
PUT
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Request Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be application/json. |
accessToken | string | Access token for authentication. (required) |
Request Body
The request body should be a JSON array containing one or more inventory update objects. Each object should have the following fields:
| Field | Type | Description |
|---|---|---|
productId | string | The unique identifier of the product. |
variantId | string | The unique identifier of the product variant (optional). |
stock | number | The stock level to set for the product or variant. |
Sample Request Body
[
{
"productId": "636d07be0438c42bc4d455e3",
"variantId": "636d07be0438c42bc4d455f2",
"stock": 500
},
{
"productId": "636d07be0438c42bc4d45693",
"stock": 400
}
]
Response
- Status Code: 200 OK
Success Response Body
A successful request typically confirms the inventory update with a message and may include updated product details.
{
"success": true,
"message": "Inventory updated successfully"
}
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request: Invalid input data. |
| 404 | Bad Request: One of the specified productId or variantId does not exist. |
| 401 | Unauthorized: Access token is invalid or missing. |
| 500 | Internal Server Error: An error occurred on the server. |
Notes
- For products without variants, only the
productIdandstockfields are required. - Ensure that all product and variant IDs are correct and valid in your inventory system.
- Make sure the access token is valid and active for successful authentication.