This is the early access documentation preview for Custom Views. This documentation might not be in sync with our official documentation.

Importing Inventories

Create and update InventoryEntries in your Project.

The Inventory data to import is represented by InventoryImport and included in an InventoryImportRequest, which is imported using Import Inventory.

Representations

InventoryImportRequest

The request body to import Inventories. Contains data for InventoryEntries to be created or updated in a commercetools Project.

type
String
"inventory"

The Inventory import resource type.

resources
Array of InventoryImport

The inventory import resources of this request.

MaxItems: 20
Example: json
{
"type": "inventory",
"resources": [
{
"key": "inventory-import-key",
"sku": "product-variant-sku",
"quantityOnStock": 15,
"restockableInDays": 2,
"expectedDelivery": "2022-06-30T14:00:00.000Z",
"supplyChannel": {
"typeId": "channel",
"key": "channel-key"
},
"custom": {
"type": {
"typeId": "type",
"key": "custom-field-key"
},
"fields": {
"theNameofTheInventoryCustomField": {
"type": "LocalizedString",
"value": {
"en": "English text",
"de": "German text"
}
}
}
}
}
]
}

InventoryImport

The data representation for an Inventory to be imported that is persisted as a Inventory in the Project.

key
String

User-defined unique identifier. If an InventoryEntry with this key exists, it will be updated with the imported data.

sku
String

Maps to Inventory.sku

quantityOnStock
Int

Maps to Inventory.quantityOnStock

restockableInDays
Int

Maps to Inventory.restockableInDays

expectedDelivery

Maps to Inventory.expectedDelivery

supplyChannel

Maps to Inventory.supplyChannel

custom

Maps to Inventory.custom.

Import Inventory

POST
https://import.{region}.commercetools.com/{projectKey}/inventories/import-containers/{importContainerKey}

Creates a request for creating new Inventories or updating existing ones.

OAuth 2.0 Scopes:
manage_products:{projectKey}
Path parameters:
region
String

The Region in which the Project is hosted.

projectKey
String

The Project key.

importContainerKey
String

The ImportContainer used to create the new resource

Request Body:InventoryImportRequestasapplication/json
Response:
201ImportResponseasapplication/json
Request Example:cURL
curl https://import.{region}.commercetools.com/{projectKey}/inventories/import-containers/{importContainerKey} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}' \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"type" : "inventory",
"resources" : [ {
"key" : "inventory-import-key",
"sku" : "product-variant-sku",
"quantityOnStock" : 15,
"restockableInDays" : 2,
"expectedDelivery" : "2022-06-30T14:00:00.000Z",
"supplyChannel" : {
"typeId" : "channel",
"key" : "channel-key"
},
"custom" : {
"type" : {
"typeId" : "type",
"key" : "custom-field-key"
},
"fields" : {
"theNameofTheInventoryCustomField" : {
"type" : "LocalizedString",
"value" : {
"en" : "English text",
"de" : "German text"
}
}
}
}
} ]
}
DATA
201 Response Example: ImportResponsejson
{
"operationStatus": [
{
"state": "processing",
"operationId": "252c6ed3-c668-4610-afe9-87b9255e62e0"
}
]
}