Importing Categories

Create and update Categories in your Project.

The Category data to import is represented by CategoryImport and included in a CategoryImportRequest, which is imported using Import Categories.

Representations

CategoryImportRequest

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

"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": {
"exampleBooleanField": {
"type": "Boolean",
"value": false
}
}
}
}
],
"custom": {
"type": {
"typeId": "type",
"key": "custom-type"
},
"fields": {
"exampleBooleanField": {
"type": "Boolean",
"value": true
},
"exampleStringField": {
"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​

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

MinLength: 2​MaxLength: 256​Pattern: ^[A-Za-z0-9_-]+$​
externalId​
String​

Maps to Category.externalId.

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.

metaTitle​

Maps to Category.metaTitle.

metaDescription​

Maps to Category.metaDescription.

metaKeywords​

Maps to Category.metaKeywords.

assets​
Array of Asset​

Maps to Category.assets.

custom​

The custom fields for this Category.

Import Categories

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

Creates a request for creating new Categories 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:CategoryImportRequestasapplication/json
Response:
201ImportResponseasapplication/json
Request Example:cURL
curl 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" : {
"exampleBooleanField" : {
"type" : "Boolean",
"value" : false
}
}
}
} ],
"custom" : {
"type" : {
"typeId" : "type",
"key" : "custom-type"
},
"fields" : {
"exampleBooleanField" : {
"type" : "Boolean",
"value" : true
},
"exampleStringField" : {
"type" : "String",
"value" : "a string"
}
}
}
} ]
}
DATA
201 Response Example: ImportResponsejson
{
"operationStatus": [
{
"state": "processing",
"operationId": "252c6ed3-c668-4610-afe9-87b9255e62e0"
}
]
}