Inventory
Inventory allows you to track stock quantity per SKU and optionally per supply channel.
Only one InventoryEntry can be created for a combination of an SKU and supply channel.
Representations
InventoryEntry
idString | Unique identifier of the InventoryEntry. |
versionInt | Current version of the InventoryEntry. |
keyString | User-defined unique identifier of the InventoryEntry. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
skuString | ProductVariant |
supplyChannel | Channel that supplies this InventoryEntry. |
quantityOnStockInt | Overall amount of stock ( |
availableQuantityInt | Available amount of stock ( |
restockableInDaysInt | How often the InventoryEntry is restocked (in days). |
expectedDelivery | Date and time of the next restock. |
custom | Custom Fields of the InventoryEntry. |
createdAt | Date and time (UTC) the InventoryEntry was initially created. |
createdByBETA | Present on resources created after 1 February 2019 except for events not tracked. |
lastModifiedAt | Date and time (UTC) the InventoryEntry was last updated. |
lastModifiedByBETA | Present on resources created after 1 February 2019 except for events not tracked. |
InventoryEntryDraft
keyString | User-defined unique identifier for the InventoryEntry. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
skuString | ProductVariant |
supplyChannel | Channel that supplies this InventoryEntry. |
quantityOnStockInt | Overall amount of stock. |
restockableInDaysInt | How often the InventoryEntry is restocked (in days). |
expectedDelivery | Date and time of the next restock. |
custom | Custom Fields of the InventoryEntry. |
InventoryPagedQueryResponse
limitInt | Number of results requested. |
offsetInt | Number of elements skipped. |
countInt | Actual number of results returned. |
totalInt | Total number of results matching the query.
This number is an estimation that is not strongly consistent.
This field is returned by default.
For improved performance, calculating this field can be deactivated by using the query parameter |
resultsArray of InventoryEntry | Inventory entries matching the query. |
InventoryEntryReference
Reference to an InventoryEntry.
idString | Unique identifier of the referenced InventoryEntry. |
typeIdString | "inventory-entry"References an InventoryEntry. |
obj | Contains the representation of the expanded InventoryEntry. Only present in responses to requests with Reference Expansion for InventoryEntries. |
InventoryEntryResourceIdentifier
ResourceIdentifier to an InventoryEntry.
idString | Unique identifier of the referenced InventoryEntry. Either |
keyString | User-defined unique identifier of the referenced InventoryEntry. Either |
typeIdString | "inventory-entry"References an InventoryEntry. |
Get InventoryEntry
Get InventoryEntry by ID
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/inventory/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "aea4caed-accf-4667-adfe-be08ba6fdf91","version" : 1,"key" : "ie-key-1","sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4,"createdAt" : "2015-03-11T13:36:20.720Z","lastModifiedAt" : "2015-03-11T13:36:20.720Z"}
Get InventoryEntry by Key
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/inventory/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "aea4caed-accf-4667-adfe-be08ba6fdf91","version" : 1,"key" : "ie-key-1","sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4,"createdAt" : "2015-03-11T13:36:20.720Z","lastModifiedAt" : "2015-03-11T13:36:20.720Z"}
Query Inventory
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
where | The parameter can be passed multiple times. |
/^var[.][a-zA-Z0-9]+$/Any string parameter matching this regular expression | Predicate parameter values. The parameter can be passed multiple times. |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limitInt | Number of results requested. |
offsetInt | Number of elements skipped. |
withTotalBoolean | Controls the calculation of the total number of query results. Set to |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/inventory -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"limit" : 20,"offset" : 0,"count" : 1,"total" : 1,"results" : [ {"id" : "aea4caed-accf-4667-adfe-be08ba6fdf91","version" : 1,"sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4,"createdAt" : "2015-03-11T13:36:20.720Z","lastModifiedAt" : "2015-03-11T13:36:20.720Z"} ]}
Create InventoryEntry
Produces the InventoryEntryCreated Message.
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
expand | The parameter can be passed multiple times. |
curl -X POST https://api.{region}.commercetools.com/{projectKey}/inventory -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4}DATA
{"id" : "aea4caed-accf-4667-adfe-be08ba6fdf91","version" : 1,"key" : "ie-key-1","sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4,"createdAt" : "2015-03-11T13:36:20.720Z","lastModifiedAt" : "2015-03-11T13:36:20.720Z"}
Update InventoryEntry
Update InventoryEntry by ID
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
versionInt | Expected version of the InventoryEntry on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict error will be returned. |
actionsArray of InventoryEntryUpdateAction | Update actions to be performed on the InventoryEntry. |
curl -X POST https://api.{region}.commercetools.com/{projectKey}/inventory/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "addQuantity","quantity" : 4} ]}DATA
{"id" : "aea4caed-accf-4667-adfe-be08ba6fdf91","version" : 1,"key" : "ie-key-1","sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4,"createdAt" : "2015-03-11T13:36:20.720Z","lastModifiedAt" : "2015-03-11T13:36:20.720Z"}
Update InventoryEntry by Key
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
versionInt | Expected version of the InventoryEntry on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict error will be returned. |
actionsArray of InventoryEntryUpdateAction | Update actions to be performed on the InventoryEntry. |
curl -X POST https://api.{region}.commercetools.com/{projectKey}/inventory/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "addQuantity","quantity" : 4} ]}DATA
{"id" : "aea4caed-accf-4667-adfe-be08ba6fdf91","version" : 1,"key" : "ie-key-1","sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4,"createdAt" : "2015-03-11T13:36:20.720Z","lastModifiedAt" : "2015-03-11T13:36:20.720Z"}
Update actions
Add Quantity
Updates availableQuantity based on the new quantityOnStock and amount of active reservations.
actionString | "addQuantity" |
quantityInt | Value to add to |
{"action" : "addQuantity","quantity" : 1}
Remove Quantity
Updates availableQuantity based on the new quantityOnStock and amount of active reservations.
actionString | "removeQuantity" |
quantityInt | Value to remove from |
{"action" : "removeQuantity","quantity" : 1}
Change Quantity
Updates availableQuantity based on the new quantityOnStock and amount of active reservations.
actionString | "changeQuantity" |
quantityInt | Value to set for |
{"action" : "changeQuantity","quantity" : 5}
Set Key
actionString | "setKey" |
keyString | Value to set. If empty, any existing value will be removed. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
{"action" : "setKey","key" : "ie-key-1"}
Set RestockableInDays
actionString | "setRestockableInDays" |
restockableInDaysInt | Value to set. If empty, any existing value will be removed. |
{"action" : "setRestockableInDays","restockableInDays" : 7}
Set ExpectedDelivery
actionString | "setExpectedDelivery" |
expectedDelivery | Value to set. If empty, any existing value will be removed. |
{"action" : "setExpectedDelivery","expectedDelivery" : "2015-10-21T14:00:00.000Z"}
Set SupplyChannel
If an entry with the same sku and supplyChannel already exists, this action will fail and a 400 Bad Request DuplicateField error will be returned.
actionString | "setSupplyChannel" |
supplyChannel | Value to set. If empty, any existing value will be removed. |
{"action" : "setSupplyChannel","supplyChannel" : {"id" : "{{supplyChannelId}}","typeId" : "channel"}}
Set Custom Type
actionString | "setCustomType" |
type | Defines the Type that extends the InventoryEntry with Custom Fields. If absent, any existing Type and Custom Fields are removed from the InventoryEntry. |
fields | Sets the Custom Fields fields for the InventoryEntry. |
{"action" : "setCustomType","type" : {"id" : "{{type-id}}","typeId" : "type"},"fields" : {"examplaryStringTypeField" : "TextString"}}
Set CustomField
actionString | "setCustomField" |
nameString | Name of the Custom Field. |
value | If |
{"action" : "setCustomField","name" : "ExamplaryStringTypeField","value" : "TextString"}
Delete InventoryEntry
Delete InventoryEntry by ID
Produces the InventoryEntryDeleted Message.
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/inventory/{id}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "aea4caed-accf-4667-adfe-be08ba6fdf91","version" : 1,"key" : "ie-key-1","sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4,"createdAt" : "2015-03-11T13:36:20.720Z","lastModifiedAt" : "2015-03-11T13:36:20.720Z"}
Delete InventoryEntry by Key
Produces the InventoryEntryDeleted Message.
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/inventory/key={key}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "aea4caed-accf-4667-adfe-be08ba6fdf91","version" : 1,"key" : "ie-key-1","sku" : "sku_GIRLS_HARTBREAK_CREW_variant1_1421832124541","quantityOnStock" : 4,"availableQuantity" : 4,"createdAt" : "2015-03-11T13:36:20.720Z","lastModifiedAt" : "2015-03-11T13:36:20.720Z"}