Access and update inventory data

This section describes how to set backorder and preorder levels and thresholds.

You can use the administration interface to set stock levels and stock thresholds, but not to set backorder and preorder levels and thresholds. Instead, you must use one of the following methods:

  • Import inventory data for your catalog with the Commerce import feature. To learn how to import preorder and backorder inventory data, see Import and Export Catalog Items and Inventory.
  • Set SKU inventory data with the Admin API updateInventory endpoint. This section describes how to use the updateInventory endpoint.
  • In a system where Commerce interacts with an external system, import and export large amounts of inventory data with the Admin API. See Perform Bulk Export and Import for more information.

Before you set backorder and preorder inventory data, you must enable backorders and preorders with the updateInventoryConfiguration endpoint. See Enable preorder and backorder functionality for more information.

Use the getInventory endpoint to retrieve inventory information for a specific product or SKU. For details about using this endpoint, see Access inventory data.

Use the updateInventory endpoint to modify the inventory of a specific SKU. In the request body, specify new values for the properties you want to update.

The following sample request sets the backorder level for SKU to 200. The backorder threshold is 15, at which point the item will show as out of stock on the store.

PUT /ccadmin/v1/inventories/xsku5014 HTTP 1.1
Authorization: Bearer <access_token>

{
  "backorderThreshold": 15,
  "backorderLevel": 200
}

The following example shows a sample response:

{
  "preorderThreshold": 0,
  "backorderLevel": 200,
  "displayName": null,
  "availabilityDate": null,
  "availabilityStatusMsg": "backorderable",
  "stockThreshold": 5,
  "stockLevel": 0,
  "availableToPromise": null,
  "skuNumber": "xsku5014",
  "preorderLevel": 0,
  "locationId": null,
  "translations": null,
  "inventoryId": null,
  "backorderThreshold": 15,
  "links": [
    {
      "rel": "self",
      "href": "https://myserver.example.com:7002/ccadmin/v1/inventories/xsku5014
  ],
  "availabilityStatus": 1003,
  "skuId": "xsku5014",
}