Manage commercetools Import API containers, import operations, and import summaries from the terminal.
- Import containers define the scope and configuration of an import.
- Import operations are the individual records being imported.
- Import summaries give an aggregate view of the import results per container.
Commands that call the API need an authenticated session. For how to log in, see
Authentication.
Import containers
Import containers define the namespace for a set of import operations.
Manage import containersbash
# List all import containers
commercetools import import-containers list [--limit <n>] [--offset <n>]
# Get an import container by key
commercetools import import-containers get --key <key>
# Create an import container
commercetools import import-containers create --body '{"key":"my-container","resourceType":"product-drafts"}'
# Update an import container
commercetools import import-containers update \
--key <key> \
--version <n> \
--actions '[{"action":"changeResourceType","resourceType":"prices"}]'
# Delete an import container
commercetools import import-containers delete --key <key>
list
| Flag | Description | Default |
|---|
--limit | Maximum number of results | 20 |
--offset | Number of results to skip | 0 |
get / delete
| Flag | Description |
|---|
--key | Import container key (required) |
create
| Flag | Description |
|---|
--body | JSON string or path to a JSON file prefixed with @ |
update
| Flag | Description |
|---|
--key | Import container key |
--version | Current version of the container |
--actions | JSON array of update actions or path to a JSON file prefixed with @ |
Import operations
Import operations represent individual resources being imported into a container.
Manage import operationsbash
# List import operations for a container
commercetools import import-operations list \
--container-key <key> \
[--limit <n>] \
[--offset <n>]
# Get a specific import operation by ID
commercetools import import-operations get --id <id>
list
| Flag | Description | Default |
|---|
--container-key | Key of the import container (required) | |
--limit | Maximum number of results | 20 |
--offset | Number of results to skip | 0 |
get
| Flag | Description |
|---|
--id | Import operation ID (required) |
Import summaries
Import summaries provide an aggregate view of all import operations in a container, grouped by status.
Get an import summarybash
# Get the import summary for a container
commercetools import import-summaries get --container-key <key>
Flag reference
| Flag | Description |
|---|
--container-key | Key of the import container (required) |
Examples
Set up and monitor a product importbash
# 1. Create an import container
commercetools import import-containers create \
--body '{"key":"product-import","resourceType":"product-drafts"}'
# 2. Check the summary after importing via API
commercetools import import-summaries get --container-key product-import
# 3. Inspect failed operations
commercetools import import-operations list \
--container-key product-import \
--limit 50 | jq '.results[] | select(.state=="rejected")'