BETA

Importing Categories

This page documents the API under the category endpoint /{projectKey}/categories. Namely, we document CategoryImportRequest and the endpoint methods for ImportOperations for Categories.

CategoryImportRequest

Representations

CategoryImportRequest

An import request for multiple category import resources.

type
String
"category"

The category import resource type.

resources

The category import resources of this request.

MaxItems: 20
Example: json
{
"type" : "category",
"resources" : [ {
"key" : "greatTestCat",
"name" : {
"en" : "greatTestCat"
},
"slug" : {
"en" : "great-slug"
}
} ]
}

CategoryImport

Import representation for a category.

key
String
name
LocalizedString

Maps to Category.name.

slug
LocalizedString

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

description
LocalizedString

Maps to Category.description.

Maps to Category.parent. The parent category referenced must already exist in the commercetools project, or the import operation will have an Unresolved state.

orderHint
String

Maps to Category.orderHint.

externalId
String

Maps to Category.externalId.

metaTitle
LocalizedString

Maps to Category.metaTitle.

metaDescription
LocalizedString

Maps to Category.metaDescription.

metaKeywords
LocalizedString

Maps to Category.metaKeywords.

assets
Array of Asset
custom

The custom fields for this category.

Endpoints

Request Category Data to be Imported

Creates import request for creating new categories or updating existing ones.

POST
https://import.europe-west1.gcp.commercetools.com/{projectKey}/categories/importSinkKey={importSinkKey}
OAuth 2.0 Scopes:
manage_project:{projectKey}, manage_products:{projectKey}
Path Parameters:
projectKey
String
The commercetools project key.
importSinkKey
String
The import sink used to create the new resource
Response:

201ImportResponse

Request Example:cURL
curl -X POST https://import.europe-west1.gcp.commercetools.com/{projectKey}/categories/importSinkKey={importSinkKey} -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"
}
} ]
}
DATA

Request a Category to be Deleted

Deletes the category given by the resource key.

DELETE
https://import.europe-west1.gcp.commercetools.com/{projectKey}/categories/importSinkKey={importSinkKey}/resourceKey={resourceKey}
OAuth 2.0 Scopes:
manage_project:{projectKey}, manage_products:{projectKey}
Path Parameters:
projectKey
String
The commercetools project key.
importSinkKey
String
The import sink used to create the new resource
resourceKey
String
-
Response:

200ImportOperationStatus

Request Example:cURL
curl -X DELETE https://import.europe-west1.gcp.commercetools.com/{projectKey}/categories/importSinkKey={importSinkKey}/resourceKey={resourceKey} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'

Get ImportOperations

Get ImportOperations by an ImportSink Key

Retrieves all category import operations of an import sink key.

GET
https://import.europe-west1.gcp.commercetools.com/{projectKey}/categories/importSinkKey={importSinkKey}/import-operations
OAuth 2.0 Scopes:
manage_project:{projectKey}, manage_products:{projectKey}, view_products:{projectKey}
Path Parameters:
projectKey
String
The commercetools project key.
importSinkKey
String
The import sink used to create the new resource
Query Parameters:
limit
Float
-
offset
Float
-
resourceKey
String
The key of the import operation to retrieve.
state
The state of the import operations to retrieve.
Request Example:cURL
curl -X GET https://import.europe-west1.gcp.commercetools.com/{projectKey}/categories/importSinkKey={importSinkKey}/import-operations -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'

Get an ImportOperation by its ID

Retrieves the import operation with the given id.

GET
https://import.europe-west1.gcp.commercetools.com/{projectKey}/categories/importSinkKey={importSinkKey}/import-operations/{id}
OAuth 2.0 Scopes:
manage_project:{projectKey}, manage_products:{projectKey}, view_products:{projectKey}
Path Parameters:
projectKey
String
The commercetools project key.
importSinkKey
String
The import sink used to create the new resource
id
String
The operation identifier
Response:
Request Example:cURL
curl -X GET https://import.europe-west1.gcp.commercetools.com/{projectKey}/categories/importSinkKey={importSinkKey}/import-operations/{id} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
Response Example:json
{
"version" : 1,
"state" : "Unresolved",
"importSinkKey" : "category-import-sink",
"resourceKey" : "child-category",
"resourceType" : "category",
"resourceAsString" : "'{}'",
"id" : "252c6ed3-c668-4610-afe9-87b9255e62e0",
"createdAt" : "2018-02-05T09:47:16.648Z",
"lastModifiedAt" : "2018-02-05T09:47:16.649Z",
"expiresAt" : "2018-02-08T09:47:16.649Z",
"retryCount" : 0,
"unresolvedReferences" : [ {
"typeId" : "category",
"key" : "my-parent-category-key"
} ]
}