BETA

Importing Product Drafts

This page documents the API under the product draft endpoint /{projectKey}/product-drafts. Namely, we document ProductDraftImportRequest and the endpoint methods for ImportOperations for Product Drafts.

ProductDraftImportRequest

Representations

ProductDraftImportRequest

An import request for multiple product draft import resources.

type
String
"product-draft"

The type of the import resource.

resources

The product draft import resources of this request.

MaxItems: 20
Example: json
{
"type" : "product-draft",
"resources" : [ {
"key" : "product-draft-key",
"name" : {
"en" : "blue shirt"
},
"slug" : {
"en" : "blue-t-shirt"
},
"productType" : {
"typeId" : "product-type",
"key" : "sample"
},
"masterVariant" : {
"attributes" : [ {
"type" : "reference",
"name" : "product-ref-attribute",
"value" : {
"key" : "greatTestCat",
"typeId" : "category"
}
} ]
}
} ]
}

ProductDraftImport

key
String

The product's product type. Maps to Product.productType.

The product type referenced must already exist in the commercetools project, or the import operation state is set to Unresolved.

name
LocalizedString
slug
LocalizedString

Human-readable identifiers usually used as deep-link URL to the related product. Each slug must be unique across a project, but a product can have the same slug for different languages. Allowed are alphabetic, numeric, underscore (_) and hyphen (-) characters.

description
LocalizedString

Maps to Product.description.

categories

An array of references to categories by their keys. Maps to Product.categories.

The categories referenced must already exist in the commercetools project, or the import operation state is set to Unresolved.

metaTitle
LocalizedString
metaDescription
LocalizedString
metaKeywords
LocalizedString

The master product variant. Required if the variants array has product variants.

variants

An array of related product variants.

References a tax category by its key.

The tax category referenced must already exist in the commercetools project, or the import operation state is set to Unresolved.

searchKeywords
SearchKeywords

References a state by its key.

The tax category referenced must already exist in the commercetools project, or the import operation state is set to Unresolved.

publish
Boolean

If there were updates, only the updates will be published to staged and current projection.

Default: false

ProductVariantDraftImport

key
String
sku
String
prices
attributes
Array of Attribute
images
Array of Image
assets
Array of Asset

PriceDraftImport

country
CountryCode

A two-digit country code as per ISO 3166-1 alpha-2.

References a customer group by its key.

References a channel by its key.

validFrom
DateTime
validUntil
DateTime
discounted
DiscountedPrice

Sets a discounted price from an external service.

tiers
Array of PriceTier

The tiered prices for this price.

custom

The custom fields for this category.

Endpoints

Request new Product Data to be Imported

Creates import request for creating new product drafts or updating existing ones.

POST
https://import.europe-west1.gcp.commercetools.com/{projectKey}/product-drafts/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 Products to be Deleted

Deletes the product type given by the resource key.

DELETE
https://import.europe-west1.gcp.commercetools.com/{projectKey}/product-drafts/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}/product-drafts/importSinkKey={importSinkKey}/resourceKey={resourceKey} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'

Get ImportOperations

Get ImportOperations by an ImportSink Key

Retrieves all import operations of an import sink key.

GET
https://import.europe-west1.gcp.commercetools.com/{projectKey}/product-drafts/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}/product-drafts/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}/product-drafts/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}/product-drafts/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"
} ]
}