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 sku of the InventoryEntry. |
supplyChannel | Channel that supplies this InventoryEntry. |
quantityOnStockInt | Overall amount of stock ( availableQuantity + reserved). |
availableQuantityInt | Available amount of stock ( quantityOnStock - reserved). |
minCartQuantityInt | Minimum quantity that can be added to a Cart. See Quantity limits. Minimum: 1 |
maxCartQuantityInt | Maximum quantity that can be added to a Cart. See Quantity limits. Minimum: 1 |
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 | IDs and references that created the InventoryEntry. |
lastModifiedAt | Date and time (UTC) the InventoryEntry was last updated. |
lastModifiedByBETA | IDs and references that last modified the InventoryEntry. |
InventoryEntryDraft
keyString | User-defined unique identifier for the InventoryEntry. This field is optional for backwards compatibility reasons, but we strongly recommend setting it. Keys are mandatory for importing InventoryEntries with the Import API and the Merchant Center. MinLength: 2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
skuString | ProductVariant sku of the InventoryEntry. |
supplyChannel | Channel that supplies this InventoryEntry. |
quantityOnStockInt | Overall amount of stock. |
minCartQuantityInt | Minimum quantity that can be added to a Cart. See Quantity limits. Minimum: 1 |
maxCartQuantityInt | Maximum quantity that can be added to a Cart. See Quantity limits. Minimum: 1 |
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. Default: 20Minimum: 0Maximum: 500 |
offsetInt | Number of elements skipped. Default: 0Maximum: 10000 |
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 withTotal=false.
When the results are filtered with a Query Predicate, total is subject to a limit. |
resultsArray of InventoryEntry | Inventory entries matching the query. |
InventoryEntryReference
idString | Unique identifier of the referenced InventoryEntry. |
typeId | inventory-entryType of referenced resource. |
obj | Contains the representation of the expanded InventoryEntry. Only present in responses to requests with Reference Expansion for InventoryEntries. |
InventoryEntryResourceIdentifier
id or key is required. If both are set, an InvalidJsonInput error is returned.idString | Unique identifier of the referenced InventoryEntry. Required if key is absent. |
keyString | User-defined unique identifier of the referenced InventoryEntry. Required if id is absent. |
typeId | inventory-entryType of referenced resource. If given, it must match the expected ReferenceTypeId of the referenced resource. |
Get InventoryEntry
Get InventoryEntry by ID
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
idString | id of the InventoryEntry. |
expand | The parameter can be passed multiple times. |
application/jsoncurl --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_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 | key of the Project. |
keyString | key of the InventoryEntry. |
expand | The parameter can be passed multiple times. |
application/jsoncurl --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_CREW_variant1_1421832124541",
"quantityOnStock": 4,
"availableQuantity": 4,
"createdAt": "2015-03-11T13:36:20.720Z",
"lastModifiedAt": "2015-03-11T13:36:20.720Z"
}Query InventoryEntries
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
where | 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. Default: 20Minimum: 0Maximum: 500 |
offsetInt | Number of elements skipped. Default: 0Maximum: 10000 |
withTotalBoolean | Controls the calculation of the total number of query results. Set to false to improve query performance when the total is not needed.Default: true |
var.<varName>String | Predicate parameter values. The parameter can be passed multiple times. |
application/jsoncurl --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_CREW_variant1_1421832124541",
"quantityOnStock": 4,
"availableQuantity": 4,
"createdAt": "2015-03-11T13:36:20.720Z",
"lastModifiedAt": "2015-03-11T13:36:20.720Z",
"minCartQuantity": 2,
"maxCartQuantity": 50
}
]
}Check if InventoryEntry exists
Check if InventoryEntry exists by ID
id. Returns a 200 status if the InventoryEntry exists, or a 404 status otherwise.view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
idString | id of the InventoryEntry. |
curl --head https://api.{region}.commercetools.com/{projectKey}/inventory/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" Check if InventoryEntry exists by Key
key. Returns a 200 status if the InventoryEntry exists, or a 404 status otherwise.view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
keyString | key of the InventoryEntry. |
curl --head https://api.{region}.commercetools.com/{projectKey}/inventory/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" Check if InventoryEntry exists by Query Predicate
200 status if any Inventory Entries match the Query Predicate, or a 404 status otherwise.view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
where |
curl --head https://api.{region}.commercetools.com/{projectKey}/inventory -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" Create InventoryEntry
Creates an InventoryEntry in the Project.
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
expand | The parameter can be passed multiple times. |
application/jsonapplication/jsoncurl https://api.{region}.commercetools.com/{projectKey}/inventory -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"key" : "ie-key-1",
"sku" : "sku_GIRLS_CREW_variant1_1421832124541",
"quantityOnStock" : 4
}
DATA{
"id": "aea4caed-accf-4667-adfe-be08ba6fdf91",
"version": 1,
"key": "ie-key-1",
"sku": "sku_GIRLS_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 | key of the Project. |
idString | id of the InventoryEntry. |
expand | The parameter can be passed multiple times. |
application/jsonversionInt | Expected version of the InventoryEntry on which the changes should be applied.
If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actionsArray of InventoryEntryUpdateAction | Update actions to be performed on the InventoryEntry. |
application/jsoncurl 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_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 | key of the Project. |
keyString | key of the InventoryEntry. |
expand | The parameter can be passed multiple times. |
application/jsonversionInt | Expected version of the InventoryEntry on which the changes should be applied.
If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actionsArray of InventoryEntryUpdateAction | Update actions to be performed on the InventoryEntry. |
application/jsoncurl 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_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
availableQuantity based on the new quantityOnStock and amount of active reservations.actionString | "addQuantity" |
quantityInt | Value to add to quantityOnStock. |
{
"action": "addQuantity",
"quantity": 1
}Remove Quantity
availableQuantity based on the new quantityOnStock and amount of active reservations.actionString | "removeQuantity" |
quantityInt | Value to remove from quantityOnStock. |
{
"action": "removeQuantity",
"quantity": 1
}Change Quantity
availableQuantity based on the new quantityOnStock and amount of active reservations.actionString | "changeQuantity" |
quantityInt | Value to set for quantityOnStock. |
{
"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
sku and supplyChannel already exists, an DuplicateField error is 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": {
"exampleStringField": "TextString"
}
}Set CustomField
actionString | "setCustomField" |
nameString | Name of the Custom Field. |
value | If value is absent or null, this field will be removed if it exists.
Removing a field that does not exist returns an InvalidOperation error.
If value is provided, it is set for the field defined by name. |
{
"action": "setCustomField",
"name": "exampleStringField",
"value": "TextString"
}Set Inventory Limits
actionString | "setInventoryLimits" |
minCartQuantityInt | Sets the minimum quantity that can be added to a Cart. If the value is absent or null
the inventory limit is removed. |
maxCartQuantityInt | Sets the maximum quantity that can be added to a Cart. If the value is absent or null
the inventory limit is removed. |
{
"action": "setInventoryLimits",
"minCartQuantity": 2,
"maxCartQuantity": 50
}Delete InventoryEntry
Delete InventoryEntry by ID
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
idString | id of the InventoryEntry. |
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/jsoncurl -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_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
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
keyString | key of the InventoryEntry. |
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/jsoncurl -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_CREW_variant1_1421832124541",
"quantityOnStock": 4,
"availableQuantity": 4,
"createdAt": "2015-03-11T13:36:20.720Z",
"lastModifiedAt": "2015-03-11T13:36:20.720Z"
}