Create inventory data for locations
You can use the createInventory
endpoint to set inventory
values for a specific SKU at a location.
This section applies to Open Storefront Framework (OSF) and Storefront Classic.
When you create a new inventory location, it initially has no inventory data associated with it. You can set inventory values for a SKU at the location. For example, the following request specifies inventory data for the location created in the previous section:
POST /ccadmin/v1/inventories HTTP/1.1
Authorization: Bearer <access_token>
{
"locationId": "Warehouse13",
"id": "xsku5014",
"stockThreshold": 10,
"stockLevel": 75
}
The endpoint includes the inventory data in the response body:
{
"locationInventoryInfo": [
{
"preorderThreshold": 0,
"stockThreshold": 10,
"availabilityStatus": 1000,
"backorderThreshold": 0,
"availabilityStatusMsg": "inStock",
"backorderLevel": 0,
"locationId": "Warehouse13",
"preorderLevel": 0,
"skuNumber": null,
"availableToPromise": null,
"translations": null,
"availabilityDate": null,
"inventoryId": null,
"displayName": null,
"stockLevel": 75
}
],
"links": [
{
"rel": "self",
"href": "https://myserver.example.com:7002/ccadmin/v1/inventories"
}
],
"skuNumber": "xsku5014",
"skuId": "xsku5014",
"displayName": "Titanium Analog Watch"
}
Notice that the response encapsulates the returned inventory data in a locationInventoryInfo
array object. This object type is used whenever inventory is returned for a non-default location, and enables returning inventory for multiple locations. (See Retrieve inventory data for locations for an example of returning inventory for multiple locations.)
Update inventory for a location
You can use the updateInventory
endpoint to modify the inventory of a specific SKU at a specific location. You specify the location and the updated inventory data in the request body. For example:
PUT /ccadmin/v1/inventories/xsku5014 HTTP/1.1
Authorization: Bearer <access_token>
{
"locationId": "Warehouse13",
"stockThreshold": 20,
"stockLevel": 200
}
Delete inventory for a location
You can use the deleteInventory
endpoint to delete the inventory of a specific SKU at a specific location. This endpoint takes two query parameters:
- A
type
query parameter to specify the item type. The value of this parameter must beproduct
(for a product) orvariant
(for a SKU). Thedefault
is variant, so if you omit the parameter, Oracle Commerce assumes that the item is a SKU. - An optional
locationId
query parameter to specify the location by its ID.
For example:
DELETE /ccadmin/v1/inventories/xsku5014?locationId=Warehouse13 HTTP/1.1
Authorization: Bearer <access_token>