Update Product Inventory
Sets the stock level of several products or variants in a single request.
HTTP Request
- URL:
/products/inventory - Method:
PUT - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_WRITE_PRODUCT
Request Body
Send a JSON array with one item for each product or variant.
| Field | Type | Required | Description |
|---|---|---|---|
productId | String | Yes | The ID of the product. |
variantId | String | No | The ID of a variant of the product. Send it to set the variant's stock. |
stock | Number | No | The new stock level. |
cURL Example
curl --location --request PUT '<BASE_URL>/products/inventory' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '[
{
"productId": "67bb23803b6220fb83f2a1c2",
"variantId": "67bb23803b6220fb83f2a1dc",
"stock": 500
},
{
"productId": "6703a2d9e1d2f3a4b5c6d812",
"stock": 400
}
]'
Response
- 200 OK: The stock levels were updated successfully.
- 400 Bad Request: The access token is missing or invalid, or an item has a missing or invalid ID.
Sample JSON Response
{
"success": true,
"message": "Inventory updated successfully"
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | true when the request succeeded. |
message | String | Confirmation message. |
Notes
- For products without variants, send only
productIdandstock. - Updating stock turns on inventory tracking (
trackInventory) for the product. - You can find variant IDs in the
variantslist returned by Get Product.