BETA

Importing Product Variants

This page documents the API under the product variant endpoint /{projectKey}/product-variants. Namely, we document ProductVariantImportRequest and the endpoint methods for ImportOperations for Products Variants.

ProductVariantImportRequest

Representations

ProductVariantImportRequest

An import request for multiple product variant import resources.

type
String
"product-variant"

The product variant import resource type.

resources

The product variant import resources of this request.

MaxItems: 20
Example: json
{
"type" : "product-variant",
"resources" : [ {
"typeId" : "product-variant",
"key" : "red-t-shirt",
"sku" : "red-t-shirt",
"product" : {
"key" : "t-shirt",
"typeId" : "product"
},
"isMasterVariant" : true,
"attributes" : [ {
"name" : "new",
"type" : "boolean",
"value" : true
}, {
"name" : "weight",
"type" : "number",
"value" : 12.5
} ],
"assets" : [ {
"id" : "uuid-kafar7545792sd6r",
"key" : "uuid-kafar7545792sd6r",
"sources" : [ {
"uri" : "http://www.example.com"
} ],
"name" : {
"en" : "asset name"
}
} ],
"images" : [ {
"url" : "https://www.commercetools.com/cli/data/253234387_1.jpg",
"dimensions" : {
"w" : 1400,
"h" : 1400
},
"label" : "tank top image Font"
} ]
} ]
}

ProductVariantImport

Import representation for a product variant. Use this type for importing new product variants into a commercetools project.

key
String
sku
String

Maps to ProductVariant.sku.

isMasterVariant
Boolean

Maps to ProductVariant.isMasterVariant.

attributes
Array of Attribute

Maps to ProductVariant.attributes.

Each attribute referenced must be defined in an already existing product type in the commercetools project, or the import operation state is set to Unresolved.

images
Array of Image

Maps to ProductVariant.images.

assets
Array of Asset

Maps to ProductVariant.assets.

publish
Boolean

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

Default: false

The product in which this product variant is contained. Maps to ProductVariant.product.

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

Endpoints

Request Product Variants to be Imported

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

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

Deletes the product variant given by the resource key.

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

Get ImportOperations

Get ImportOperations by an ImportSink Key

Retrieves all product-variant import operations of an import sink key.

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