BETA

Importing Product Drafts

The ProductDraft Import endpoint allows you to import Products as well as Product Variants and Prices in a single import request. The data to import is represented by ProductDraftImport and loaded in ProductDraftImportRequest, which is posted to initiate the import process.

While using the present endpoint (instead of calling three separate endpoints for Products, Product Variants, and Prices) reduces the number of API calls, this endpoint requires a relatively large payload.

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

To take advantage of this endpoint, the import data needs to be large enough in the sense that the payload does not leave a large number of fields unused. In particular, this endpoint is suitable to import a complete set of Product data including Product Variants and Prices.

Other suitable instances include, for example:

  • when you want to update a Product with, say, 10 new Product Variants and 20 Prices for each Product Variant.
  • when you want to update all Product Variant (that is, 20) with new attribute values and also change the price values for all the variants, while each variant has, say, 20 Prices.

Representations

ProductDraftImportRequest

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

type
String
"product-draft"

The type of the import resource.

resources
Array of ProductDraftImport

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" : {
"key" : "master-variant-key",
"attributes" : [ {
"type" : "reference",
"name" : "product-ref-attribute",
"value" : {
"key" : "greatTestCat",
"typeId" : "category"
}
}, {
"type" : "reference",
"name" : "product-custom-object-ref-attribute",
"value" : {
"key" : "custom-object-key",
"container" : "custom-object-container-key",
"typeId" : "key-value-document"
}
} ]
}
} ]
}

ProductDraftImport

The representation of a Product Draft for the import purpose.

key
String
productType

The productType of a Product. Maps to Product.productType. The Reference to the ProductType with which the ProductDraft is associated. If referenced ProductType does not exist, the state of the ImportOperation will be set to unresolved until the necessary ProductType is created.

name
slug

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

Maps to Product.description.

categories

The Reference to the Categories with which the ProductDraft is associated. If referenced Categories do not exist, the state of the ImportOperation will be set to unresolved until the necessary Categories are created.

metaTitle
metaDescription
metaKeywords
masterVariant

The master Product variant. Required if the variants array contains a Product Variant.

variants

An array of related Product Variants.

taxCategory

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

searchKeywords
SearchKeywords

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

publish
Boolean

If publish is set to either true or false, both staged and current projections are set to the same value provided by the import data. If publish is not set, the staged projection is set to the provided import data, but the current projection stays unchanged. However, if the import data contains no update, that is, if it matches the staged projection of the existing Product in the platform, the import induces no change in the existing Product whether publish is set or not.

ProductVariantDraftImport

The representation of a Product Variant Draft for the import purpose.

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

PriceDraftImport

The representation of a Price Draft for the import purpose.

key
String
value
country
CountryCode

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

customerGroup

References a customer group by key.

channel

References a channel by key.

validFrom
validUntil
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.

Import ProductDrafts

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

POST
https://import.{region}.commercetools.com/{projectKey}/product-drafts/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: