BETA

Importing Inventories

This endpoint can be used to import inventory data to create and update InventoryEntry in a Project.

The Inventory data to import is represented by InventoryImport and loaded in InventoryImportRequest, which is posted to import Inventory.

To monitor an import status, use Get ImportSummary, Get ImportOperation, and Query ImportOperations.

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
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

Response:

201ImportResponse

Request Example:cURL
curl -X POST 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"
} ]
}