BETA

Importing Categories

This endpoint can be used to import Category data to create and update Categories in a commercetools Project. The Category data to import is represented by CategoryImport and loaded in a CategoryImportRequest, which is posted to import Categories.

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

Representations

CategoryImportRequest

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

type​
String​
"category"

The category import resource type.

resources​
Array of CategoryImport​

The category import resources of this request.

MaxItems: 20​
Example: json
{
"type" : "category",
"resources" : [ {
"key" : "greatTestCat",
"name" : {
"en" : "greatTestCat"
},
"slug" : {
"en" : "great-slug"
},
"description" : {
"de" : "Beschreibung der Kategorie",
"en" : "category's description"
},
"parent" : {
"typeId" : "category",
"key" : "category-key"
},
"orderHint" : "category's order hint",
"externalId" : "external-id",
"metaTitle" : {
"de" : "der Metatitel der Katze",
"en" : "the cat's meta title"
},
"metaDescription" : {
"de" : "die Meta-Beschreibung der Katze",
"en" : "the cat's meta description"
},
"metaKeywords" : {
"de" : "die Schlüsselwörter der Katze",
"en" : "the cat's key words"
},
"assets" : [ {
"key" : "asset-key",
"sources" : [ {
"uri" : "https://google.com",
"key" : "asset-source-key",
"dimensions" : {
"w" : 12,
"h" : 10
},
"contentType" : "dummy content type"
} ],
"name" : {
"de" : "Asset-Name",
"en" : "asset name"
},
"description" : {
"de" : "Asset-Beschreibung",
"en" : "asset description"
},
"tags" : [ "tag 1" ],
"custom" : {
"type" : {
"key" : "custom-type",
"typeId" : "type"
},
"fields" : {
"boolean-field" : {
"type" : "Boolean",
"value" : false
}
}
}
} ],
"custom" : {
"type" : {
"typeId" : "type",
"key" : "custom-type"
},
"fields" : {
"boolean-field" : {
"type" : "Boolean",
"value" : true
},
"string-field" : {
"type" : "String",
"value" : "a string"
}
}
}
} ]
}

CategoryImport

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

key​
String​
name​

Maps to Category.name.

slug​

Maps to Category.slug. Must match the pattern [-a-zA-Z0-9_]{2,256}.

description​

Maps to Category.description.

Maps to Category.parent. The Reference to the parent Category with which the Category is associated. If referenced Category does not exist, the state of the ImportOperation will be set to unresolved until the necessary Category is created.

orderHint​
String​

Maps to Category.orderHint.

externalId​
String​

Maps to Category.externalId.

metaTitle​

Maps to Category.metaTitle.

metaDescription​

Maps to Category.metaDescription.

metaKeywords​

Maps to Category.metaKeywords.

assets​
Array of Asset​
custom​

The custom fields for this Category.

Import Categories

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

POST
https://import.{region}.commercetools.com/{projectKey}/categories/import-containers/{importContainerKey}
OAuth 2.0 Scopes:
manage_products:{projectKey}
Path parameters:
region
​
String
​

The Region in which the Project is hosted.

projectKey
​
String
​

The commercetools Project key.

importContainerKey
​
String
​

The ImportContainer used to create the new resource

Response:
Request Example:cURL
curl -X POST https://import.{region}.commercetools.com/{projectKey}/categories/import-containers/{importContainerKey} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}' \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"type" : "category",
"resources" : [ {
"key" : "greatTestCat",
"name" : {
"en" : "greatTestCat"
},
"slug" : {
"en" : "great-slug"
},
"description" : {
"de" : "Beschreibung der Kategorie",
"en" : "category's description"
},
"parent" : {
"typeId" : "category",
"key" : "category-key"
},
"orderHint" : "category's order hint",
"externalId" : "external-id",
"metaTitle" : {
"de" : "der Metatitel der Katze",
"en" : "the cat's meta title"
},
"metaDescription" : {
"de" : "die Meta-Beschreibung der Katze",
"en" : "the cat's meta description"
},
"metaKeywords" : {
"de" : "die Schlüsselwörter der Katze",
"en" : "the cat's key words"
},
"assets" : [ {
"key" : "asset-key",
"sources" : [ {
"uri" : "https://google.com",
"key" : "asset-source-key",
"dimensions" : {
"w" : 12,
"h" : 10
},
"contentType" : "dummy content type"
} ],
"name" : {
"de" : "Asset-Name",
"en" : "asset name"
},
"description" : {
"de" : "Asset-Beschreibung",
"en" : "asset description"
},
"tags" : [ "tag 1" ],
"custom" : {
"type" : {
"key" : "custom-type",
"typeId" : "type"
},
"fields" : {
"boolean-field" : {
"type" : "Boolean",
"value" : false
}
}
}
} ],
"custom" : {
"type" : {
"typeId" : "type",
"key" : "custom-type"
},
"fields" : {
"boolean-field" : {
"type" : "Boolean",
"value" : true
},
"string-field" : {
"type" : "String",
"value" : "a string"
}
}
}
} ]
}
DATA