Skip to main content

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

HeaderTypeDescription
Content-TypestringMust be application/json.
accessTokenstringAccess 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:

FieldTypeDescription
productIdstringThe unique identifier of the product.
variantIdstringThe unique identifier of the product variant (optional).
stocknumberThe 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 CodeDescription
400Bad Request: Invalid input data.
404Bad Request: One of the specified productId or variantId does not exist.
401Unauthorized: Access token is invalid or missing.
500Internal Server Error: An error occurred on the server.

Notes

  • For products without variants, only the productId and stock fields 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.