Products

Products represent the sellable goods in an e-commerce project.

Products contain ProductVariants, which represent a single sellable product (often an individual SKU). Efficiently mapping your goods to Products and ProductVariants is an important part of working with the API. For more information, see the Product Modeling Guide.

The ProductPriceMode controls whether the prices are embedded into the Product Variants (up to 100 per Product Variant) or stored separately as StandalonePrice (up to 50 000 per Product Variant).

Representations

Product-ProductDraft-ProductPagedQueryResponse-ProductReference-ProductResourceIdentifier-ProductCatalogData-ProductData-CategoryOrderHints-SearchKeywords-SearchKeyword-SuggestTokenizer-Whitespace Tokenizer-Custom Tokenizer
ProductVariant-ProductVariantDraft-Attribute-Image-ImageDimensions-ProductVariantAvailability-ProductVariantChannelAvailabilityMap-ProductVariantChannelAvailability

Product

An abstract sellable good with a set of Attributes defined by a Product Type. Products themselves are not sellable. Instead, they act as a parent structure for Product Variants. Each Product must have at least one Product Variant, which is called the Master Variant. A single Product representation contains the current and the staged representation of its product data.

id
String

Unique identifier of the Product.

version
Int

Current version of the Product.

key
String

User-defined unique identifier of the Product.

This is different from the key of a ProductVariant.

productType

The Product Type defining the Attributes of the Product. Cannot be changed.

masterData

Contains the current and the staged representation of the product information.

taxCategory

The TaxCategory of the Product.

state

State of the Product.

reviewRatingStatistics

Review statistics of the Product.

priceMode

Type of Price to be used when looking up a price for the Product.

Default: Embedded
createdAt

Date and time (UTC) the Product was initially created.

createdByBETA

Present on resources created after 1 February 2019 except for events not tracked.

lastModifiedAt

Date and time (UTC) the Product was last updated.

lastModifiedByBETA

Present on resources created after 1 February 2019 except for events not tracked.

Example: json
{
"id" : "e7ba4c75-b1bb-483d-94d8-2c4a10f78472",
"version" : 2,
"masterData" : {
"current" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
},
"hasStagedChanges" : false,
"published" : true,
"staged" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
}
},
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"taxCategory" : {
"id" : "f1e10e3a-45eb-49d8-ad0b-fdf984202f59",
"typeId" : "tax-category"
},
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z"
}

ProductDraft

key
String

User-defined unique identifier for the Product.

productType

The Product Type defining the Attributes for the Product. Cannot be changed later.

name

Name of the Product.

slug

User-defined identifier used in a deep-link URL for the Product. It must be unique across a Project, but a Product can have the same slug in different Locales. It must match the pattern [a-zA-Z0-9_-]{2,256}.

description

Description of the Product.

categories

Categories assigned to the Product.

categoryOrderHints

Numerical values to allow ordering of Products within a specified Category.

metaTitle

Title of the Product displayed in search results.

metaDescription

Description of the Product displayed in search results.

metaKeywords

Keywords that give additional information about the Product to search engines.

masterVariant

The Product Variant to be the Master Variant for the Product. Required if variants are provided also.

variants

The additional Product Variants for the Product.

taxCategory

The Tax Category to be assigned to the Product.

searchKeywords

Used by Product Suggestions, but is also considered for a full text search.

state

State to be assigned to the Product.

publish
Boolean

If true, the Product is published immediately to the current projection.

Default: false
priceMode

Specifies the type of prices used when looking up a price for the Product.

Default: Embedded
Example: json
{
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"categories" : [ {
"typeId" : "category",
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919"
} ],
"name" : {
"en" : "Some Product"
},
"slug" : {
"en" : "product_slug_<random-uuid>"
},
"masterVariant" : {
"sku" : "SKU-1",
"prices" : [ {
"value" : {
"currencyCode" : "EUR",
"centAmount" : 4200
}
} ],
"images" : [ {
"url" : "http://my.custom.cdn.net/master.png",
"label" : "Master Image",
"dimensions" : {
"w" : 303,
"h" : 197
}
} ]
},
"variants" : [ {
"images" : [ {
"url" : "http://my.custom.cdn.net/variant.png",
"label" : "Variant Image",
"dimensions" : {
"w" : 303,
"h" : 197
}
} ]
} ]
}

ProductPagedQueryResponse

PagedQueryResult with results containing an array of Product.

limit
Int

Number of results requested.

offset
Int

Number of elements skipped.

count
Int

Actual number of results returned.

total
Int

Total number of results matching the query. This number is an estimation that is not strongly consistent. This field is returned by default. For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. When the results are filtered with a Query Predicate, total is subject to a limit.

results
Array of Product

Products matching the query.

ProductReference

id
String

Unique identifier of the referenced Product.

typeId
String
"product"

References a Product.

obj

Contains the representation of the expanded Product. Only present in responses to requests with Reference Expansion for Products.

ProductResourceIdentifier

ResourceIdentifier to a Product. Either id or key is required.

id
String

Unique identifier of the referenced Product.

key
String

User-defined unique identifier of the referenced Product.

typeId
String
"product"

References a Product.

ProductCatalogData

Contains the current and staged ProductData.

published
Boolean

true if the Product is published.

current

Current (published) data of the Product.

staged

Staged (unpublished) data of the Product.

hasStagedChanges
Boolean

true if the staged data is different from the current data.

ProductData

Contains all the data of a Product and its Product Variants.

name

Name of the Product.

categories
Array of CategoryReference

Categories assigned to the Product.

categoryOrderHints

Numerical values to allow ordering of Products within a specified Category.

description

Description of the Product.

slug

User-defined identifier used in a deep-link URL for the Product. Must be unique across a Project, but can be the same for Products in different Locales. Matches the pattern [a-zA-Z0-9_-]{2,256}.

metaTitle

Title of the Product displayed in search results.

metaDescription

Description of the Product displayed in search results below the meta title.

metaKeywords

Keywords that give additional information about the Product to search engines.

masterVariant

The Master Variant of the Product.

variants
Array of ProductVariant

Additional Product Variants.

searchKeywords

Used by Product Suggestions, but is also considered for a full text search.

CategoryOrderHints

JSON object where the key is a Category id and the value is an order hint. Allows controlling the order of Products and how they appear in Categories. Products with no order hint have an order score below 0. Order hints are non-unique. If a subset of Products have the same value for order hint in a specific category, the behavior is undetermined.

/[0-9].[0-9]*[1-9]/
Any string property matching this regular expression

A string representing a number between 0 and 1 that must start with 0. and cannot end with 0.

Example: json
{
"categoryOrderHints" : {
"7bcd33e6-c1c7-4b96-8d70-9b9b18b19b70" : "0.992"
}
}

SearchKeywords

Search keywords are primarily used by Product Suggestions, but are also considered for a full-text search. SearchKeywords is a JSON object where the keys are of type Locale and the values are an array of SearchKeyword.

{
"en": [
{ "text": "Multi tool" },
{ "text": "Swiss Army Knife", "suggestTokenizer": { "type": "whitespace" } }
],
"de": [
{
"text": "Schweizer Messer",
"suggestTokenizer": {
"type": "custom",
"inputs": ["schweizer messer", "offiziersmesser", "sackmesser"]
}
}
]
}

SearchKeyword

text
String

Text to return in the result of a suggest query.

suggestTokenizer

If no tokenizer is defined, the text is used as a single token.

SuggestTokenizer

Defines tokens that are used to match against the suggest query input. Can be differentiated by the type field.

Whitespace Tokenizer

Creates tokens by splitting the text field in SearchKeyword by whitespaces.

type
String
"whitespace"

Custom Tokenizer

Define arbitrary tokens that are used to match the input.

type
String
"custom"
inputs
Array of String

Contains custom tokens.

ProductVariant

A concrete sellable good for which inventory can be tracked. Product Variants are generally mapped to specific SKUs.

id
Int

A unique, sequential identifier of the Product Variant within the Product.

key
String

User-defined unique identifier of the ProductVariant.

This is different from Product key.

sku
String

User-defined unique SKU of the Product Variant.

prices
Array of Price

The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

attributes
Array of Attribute

Attributes of the Product Variant.

price

Only available when Price selection is used. Cannot be used in a Query Predicate.

images
Array of Image

Images of the Product Variant.

assets
Array of Asset

Media assets of the Product Variant.

availability

Set if the Product Variant is tracked by Inventory. Can be used as an optimization to reduce calls to the Inventory service. May not contain the latest Inventory State (it is eventually consistent).

isMatchingVariant
Boolean

true if the Product Variant matches the search query. Only available in response to a Product Projection Search request.

scopedPrice

Only available in response to a Product Projection Search request with price selection. Can be used to sort, filter, and facet.

scopedPriceDiscounted
Boolean

Only available in response to a Product Projection Search request with price selection.

ProductVariantDraft

Creates a Product Variant when included in the masterVariant and variants fields of the ProductDraft.

key
String

User-defined unique identifier for the ProductVariant.

sku
String

User-defined unique SKU of the Product Variant.

prices
Array of PriceDraft

The Embedded Prices for the Product Variant. Each Price must have its unique Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

MaxItems: 100
attributes
Array of Attribute

Attributes according to the respective AttributeDefinition.

images
Array of Image

Images for the Product Variant.

assets
Array of AssetDraft

Media assets for the Product Variant.

Attribute

When using attributes with GraphQL API mutations, you must escape any strings in the value field: "value" : "\"A value\"".

name
String

Name of the Attribute.

value
Any

The AttributeType determines the format of the Attribute value to be provided:

  • For Enum Type and Localized Enum Type, use the key of the Plain Enum Value or Localized Enum Value objects, or the complete objects as value.
  • For Localizable Text Type, use the LocalizedString object as value.
  • For Money Type Attributes, use the Money object as value.
  • For Set Type Attributes, use the entire set object as value.
  • For Nested Type Attributes, use the list of values of all Attributes of the nested Product as value.
  • For Reference Type Attributes, use the Reference object as value.

Image

Product images can be uploaded using the image upload endpoint or the Merchant Center. An image uploaded to commercetools Composable Commerce is stored in a Content Delivery Network and is available in several pre-defined sizes.

If you already have an image stored on an external service, you can save the URL when creating a new Product or adding a ProductVariant, or you can add it later. An image is represented in the following way:

url
String

URL of the image in its original size that must be unique within a single ProductVariant.

dimensions

Dimensions of the original image.

label
String

Custom label for the image.

Images in specific sizes are obtained by adding a size suffix before the filename extension:

Images will never be scaled up. If the original image is tiny, it will keep its original size, even in the "large" and "zoom" sizes.

ProductVariants do not share images. To use the same set of images for multiple ProductVariants, you can implement this in your application by always showing the images of the Master Variant, regardless of the selected ProductVariant.

ImageDimensions

w
Int

Width of the image.

h
Int

Height of the image.

ProductVariantAvailability

The InventoryEntry information of the Product Variant. If there is a supply Channel for the InventoryEntry, then channels is returned. If not, then isOnStock, restockableInDays, and quantityOnStock are returned.

channels

For each InventoryEntry with a supply Channel, an entry is added to channels.

isOnStock
Boolean

Indicates whether a Product Variant is in stock.

restockableInDays
Int

Number of days to restock a Product Variant once it is out of stock.

availableQuantity
Int

Number of items of the Product Variant that are in stock.

ProductVariantChannelAvailabilityMap

A JSON object where the key is a supply Channel id and the value is the ProductVariantChannelAvailability of the InventoryEntry.

{
"cd724bd4-52fa-4d6d-b4b0-bb1560d70475": {
"isOnStock": true,
"restockableInDays": 10,
"availableQuantity": 20,
"version": 1,
"id": "f64af276-a1ad-4eea-a8bc-89c453742a40"
}
}

ProductVariantChannelAvailability

id
String

Unique identifier of the InventoryEntry.

version
Int

Current version of the InventoryEntry.

isOnStock
Boolean

Indicates whether a Product Variant is in stock in a specified Channel.

restockableInDays
Int

Number of days to restock a Product Variant once it is out of stock in a specified Channel.

availableQuantity
Int

Number of items of this Product Variant that are in stock in a specified Channel.

ProductPriceMode

This mode determines the type of Prices used for Product Price Selection as well as for LineItem Price selection.

Embedded

Composable Commerce uses the Embedded Prices located inside the prices field in ProductVariant.

Standalone

Composable Commerce uses StandalonePrices, which are associated with the ProductVariant through the sku field.

Changing the Price mode does not change the behavior of the update actions Add Embedded Price, Set Embedded Prices, Change Embedded Price and Remove Embedded Price, which are only meant for managing Embedded Prices.

The prices array in ProductVariant contains only Embedded Prices regardless of the current Price mode.

No migration from Embedded Prices to StandalonePrices (or vice versa) takes place when changing the Price mode of a Product.

Price Selection

The Cart addLineItem update action selects a price associated with the Product as indicated by priceMode and based on the currency, country, Customer Group, Channel, and a date. Product-related endpoints also provide the same price selection logic to help the shop to show the right price to Customers.

If priceCurrency and any other Price selection parameter priceCountry, priceCustomerGroup or priceChannel are provided as a query parameter and a matching Price exists, a price field containing the matching Price is added to the ProductVariant of the returned Product Projections.

Price validity dates are taken into account (see validFrom and validUntil in Embedded Price and StandalonePrice).

The Price is shown only when the timestamp of the request is within validFrom - ValidUntil range.

ScopedPrice

Scoped Price is contained in a ProductVariant which is returned in response to a Search Product Projection request when Price Selection is used.

id
String

Platform-generated unique identifier of the Price.

value

Original value of the Price.

currentValue

If available, either the original price value or discounted value.

country

Country code of the geographic location.

Pattern: ^[A-Z]{2}$
customerGroup

Reference to a CustomerGroup.

channel

Reference to a Channel.

validFrom

Date and time from which the Price is valid.

validUntil

Date and time until which the Price is valid.

discounted

Is set if a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.

When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

custom

Custom Fields for the Price.

Changing the Date for Price Selection

The priceDate parameter overrides the request's timestamp, selecting a valid Price from the past or the future.

When priceDate does not equal the current date, Product Discounts are not taken into account. For example, if you create a Product Discount with validity dates in the future, and use priceDate in the Product Discount's timeframe, the future Price selected will not include the Product Discount, even if the discount is valid for the date specified in the priceDate parameter.

Get Product

Get Product by ID

GET
https://api.{region}.commercetools.com/{projectKey}/products/{id}

If Price selection query parameters are provided, the selected Prices are added to the response.

OAuth 2.0 Scopes:
view_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

id
String

id of the Product.

Query parameters:
expand
The parameter can be passed multiple times.
priceCurrency
priceCountry

Use for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceCustomerGroup
String

id of an existing CustomerGroup used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceChannel
String

id of an existing Channel used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

Response:

200Product

Request Example:cURL
curl -X GET https://api.{region}.commercetools.com/{projectKey}/products/{id} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: Productjson
{
"id" : "e7ba4c75-b1bb-483d-94d8-2c4a10f78472",
"version" : 2,
"masterData" : {
"current" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
},
"hasStagedChanges" : false,
"published" : true,
"staged" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
}
},
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"taxCategory" : {
"id" : "f1e10e3a-45eb-49d8-ad0b-fdf984202f59",
"typeId" : "tax-category"
},
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z"
}

Get Product by Key

GET
https://api.{region}.commercetools.com/{projectKey}/products/key={key}

If Price selection query parameters are provided, the selected Prices are added to the response.

OAuth 2.0 Scopes:
view_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

key
String

key of the Product.

Query parameters:
expand
The parameter can be passed multiple times.
priceCurrency
priceCountry

Use for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceCustomerGroup
String

id of an existing CustomerGroup used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceChannel
String

id of an existing Channel used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

Response:

200Product

Request Example:cURL
curl -X GET https://api.{region}.commercetools.com/{projectKey}/products/key={key} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: Productjson
{
"id" : "e7ba4c75-b1bb-483d-94d8-2c4a10f78472",
"version" : 2,
"masterData" : {
"current" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
},
"hasStagedChanges" : false,
"published" : true,
"staged" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
}
},
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"taxCategory" : {
"id" : "f1e10e3a-45eb-49d8-ad0b-fdf984202f59",
"typeId" : "tax-category"
},
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z"
}

Check existence of Products

Check existence of Product by ID

HEAD
https://api.{region}.commercetools.com/{projectKey}/products/{id}

Check if a Product exists with a specified id. Responds with a 200 OK status if the Product exists or 404 Not Found otherwise.

OAuth 2.0 Scopes:
view_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

id
String

id of the Product.

Response:

200No body is returned.

Request Example:cURL
curl -X HEAD https://api.{region}.commercetools.com/{projectKey}/products/{id} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'

Check existence of Product by Key

HEAD
https://api.{region}.commercetools.com/{projectKey}/products/key={key}

Check if a Product exists with a specified key. Responds with a 200 OK status if the Product exists or 404 Not Found otherwise.

OAuth 2.0 Scopes:
view_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

key
String

key of the Product.

Response:

200No body is returned.

Request Example:cURL
curl -X HEAD https://api.{region}.commercetools.com/{projectKey}/products/key={key} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'

Check existence of Products by Query Predicate

HEAD
https://api.{region}.commercetools.com/{projectKey}/products

Check if Products exist. Responds with a 200 OK status if any Products match the Query Predicate, or 404 Not Found otherwise.

OAuth 2.0 Scopes:
view_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

Query parameters:
where

Query Predicates on Product Attributes are limited to Text, Enum, Boolean, Number, Date, Time, and DateTime attribute types.

The parameter can be passed multiple times.
Response:

200No body is returned.

Request Example:cURL
curl -X HEAD https://api.{region}.commercetools.com/{projectKey}/products -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'

Query Products

Querying Product Attributes should not be used in high-volume use cases as it is an inefficient pattern.

We recommend using the performance-optimized Search Product Projections endpoint, which provides some functionalities that the query API lacks (including sorting by custom Attributes).

GET
https://api.{region}.commercetools.com/{projectKey}/products

If Price selection query parameters are provided, the selected Prices are added to the response.

OAuth 2.0 Scopes:
view_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

Query parameters:
where

Query Predicates on Product Attributes are limited to Text, Enum, Boolean, Number, Date, Time, and DateTime attribute types.

The parameter can be passed multiple times.
/^var[.][a-zA-Z0-9]+$/
Any string parameter matching this regular expression

Predicate parameter values.

The parameter can be passed multiple times.
sort
The parameter can be passed multiple times.
expand
The parameter can be passed multiple times.
limit
Int
offset
Int

Number of elements skipped.

withTotal
Boolean

Controls the calculation of the total number of query results. Set to false to improve query performance when the total is not needed.

priceCurrency
priceCountry

Use for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceCustomerGroup
String

id of an existing CustomerGroup used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceChannel
String

id of an existing Channel used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

Response:

200ProductPagedQueryResponse

Request Example:cURL
curl -X GET https://api.{region}.commercetools.com/{projectKey}/products -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: ProductPagedQueryResponsejson
{
"limit" : 20,
"offset" : 0,
"count" : 1,
"total" : 1,
"results" : [ {
"id" : "e7ba4c75-b1bb-483d-94d8-2c4a10f78472",
"masterData" : {
"current" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
},
"hasStagedChanges" : false,
"published" : true,
"staged" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
}
},
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"taxCategory" : {
"id" : "f1e10e3a-45eb-49d8-ad0b-fdf984202f59",
"typeId" : "tax-category"
},
"version" : 2,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z"
} ]
}

Query Product Selections for Product BETA

Retrieves Product Selections that contain the given Product.

Query Product Selections for Product by ID

GET
https://api.{region}.commercetools.com/{projectKey}/products/{id}/product-selections
OAuth 2.0 Scopes:
view_product_selections:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

id
String

id of the Product.

Query parameters:
where
The parameter can be passed multiple times.
/^var[.][a-zA-Z0-9]+$/
Any string parameter matching this regular expression

Predicate parameter values.

The parameter can be passed multiple times.
sort
The parameter can be passed multiple times.
expand
The parameter can be passed multiple times.
limit
Int
offset
Int

Number of elements skipped.

withTotal
Boolean

Controls the calculation of the total number of query results. Set to false to improve query performance when the total is not needed.

Response:

200AssignedProductSelectionPagedQueryResponse

Request Example:cURL
curl -X GET https://api.{region}.commercetools.com/{projectKey}/products/{id}/product-selections -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: AssignedProductSelectionPagedQueryResponsejson
{
"limit" : 20,
"offset" : 0,
"count" : 1,
"results" : [ {
"productSelection" : {
"typeId" : "product-selection",
"id" : "2e89d89b-bdfb-4339-8e53-7638966a97c2"
}
} ]
}

Create Product

POST
https://api.{region}.commercetools.com/{projectKey}/products

To create a new Product, send a representation that is going to become the initial staged representation of the new Product in the master catalog. If Price Selection query parameters are provided, selected Prices will be added to the response. Produces the ProductCreated Message.

OAuth 2.0 Scopes:
manage_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

Query parameters:
expand
The parameter can be passed multiple times.
priceCurrency
priceCountry

Use for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceCustomerGroup
String

id of an existing CustomerGroup used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceChannel
String

id of an existing Channel used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

Request Body:ProductDraft
Response:

201Product

Request Example:cURL
curl -X POST https://api.{region}.commercetools.com/{projectKey}/products -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}' \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"categories" : [ {
"typeId" : "category",
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919"
} ],
"name" : {
"en" : "Some Product"
},
"slug" : {
"en" : "product_slug_<random-uuid>"
},
"masterVariant" : {
"sku" : "SKU-1",
"prices" : [ {
"value" : {
"currencyCode" : "EUR",
"centAmount" : 4200
}
} ],
"images" : [ {
"url" : "http://my.custom.cdn.net/master.png",
"label" : "Master Image",
"dimensions" : {
"w" : 303,
"h" : 197
}
} ]
},
"variants" : [ {
"images" : [ {
"url" : "http://my.custom.cdn.net/variant.png",
"label" : "Variant Image",
"dimensions" : {
"w" : 303,
"h" : 197
}
} ]
} ]
}
DATA
201 Response Example: Productjson
{
"id" : "e7ba4c75-b1bb-483d-94d8-2c4a10f78472",
"version" : 2,
"masterData" : {
"current" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
},
"hasStagedChanges" : false,
"published" : true,
"staged" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
}
},
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"taxCategory" : {
"id" : "f1e10e3a-45eb-49d8-ad0b-fdf984202f59",
"typeId" : "tax-category"
},
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z"
}

Update Product

Update Product by ID

POST
https://api.{region}.commercetools.com/{projectKey}/products/{id}

If Price selection query parameters are provided, the selected Prices are added to the response.

OAuth 2.0 Scopes:
manage_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

id
String

id of the Product.

Query parameters:
expand
The parameter can be passed multiple times.
priceCurrency
priceCountry

Use for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceCustomerGroup
String

id of an existing CustomerGroup used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceChannel
String

id of an existing Channel used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

Request Body:
version
Int

Expected version of the Product on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned.

actions

Update actions to be performed on the Product.

Response:

200Product

Request Example:cURL
curl -X POST https://api.{region}.commercetools.com/{projectKey}/products/{id} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}' \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 2,
"actions" : [ {
"action" : "setDescription",
"description" : {
"en" : "The best product ever!"
}
} ]
}
DATA
200 Response Example: Productjson
{
"id" : "e7ba4c75-b1bb-483d-94d8-2c4a10f78472",
"version" : 2,
"masterData" : {
"current" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
},
"hasStagedChanges" : false,
"published" : true,
"staged" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
}
},
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"taxCategory" : {
"id" : "f1e10e3a-45eb-49d8-ad0b-fdf984202f59",
"typeId" : "tax-category"
},
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z"
}

Specific Error Codes:

  • DuplicatePriceScope
  • DuplicateVariantValues
  • DuplicateAttributeValue
  • DuplicateAttributeValues

Update Product by Key

POST
https://api.{region}.commercetools.com/{projectKey}/products/key={key}
OAuth 2.0 Scopes:
manage_products:{projectKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

key
String

key of the Product.

Query parameters:
expand
The parameter can be passed multiple times.
priceCurrency
priceCountry

Use for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceCustomerGroup
String

id of an existing CustomerGroup used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

priceChannel
String

id of an existing Channel used for Price selection. Can only be used in conjunction with the priceCurrency parameter.

Request Body:
version
Int

Expected version of the Product on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned.

actions

Update actions to be performed on the Product.

Response:

200Product

Request Example:cURL
curl -X POST https://api.{region}.commercetools.com/{projectKey}/products/key={key} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}' \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 2,
"actions" : [ {
"action" : "setDescription",
"description" : {
"en" : "The best product ever!"
}
} ]
}
DATA
200 Response Example: Productjson
{
"id" : "e7ba4c75-b1bb-483d-94d8-2c4a10f78472",
"version" : 2,
"masterData" : {
"current" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
},
"hasStagedChanges" : false,
"published" : true,
"staged" : {
"categories" : [ {
"id" : "cf6d790a-f027-4f46-9a2b-4bc9a31066fb",
"typeId" : "category"
} ],
"description" : {
"en" : "Sample description"
},
"masterVariant" : {
"attributes" : [ ],
"id" : 1,
"images" : [ {
"dimensions" : {
"h" : 1400,
"w" : 1400
},
"url" : "https://commercetools.com/cli/data/253245821_1.jpg"
} ],
"prices" : [ {
"value" : {
"type" : "centPrecision",
"fractionDigits" : 2,
"centAmount" : 10000,
"currencyCode" : "EUR"
},
"id" : "753472a3-ddff-4e0f-a93b-2eb29c90ba54"
} ],
"sku" : "sku_MB_PREMIUM_TECH_T_variant1_1369226795424"
},
"name" : {
"en" : "MB PREMIUM TECH T"
},
"slug" : {
"en" : "mb-premium-tech-t1369226795424"
},
"variants" : [ ],
"searchKeywords" : { }
}
},
"productType" : {
"id" : "24f510c3-f334-4099-94e2-d6224a8eb919",
"typeId" : "product-type"
},
"taxCategory" : {
"id" : "f1e10e3a-45eb-49d8-ad0b-fdf984202f59",
"typeId" : "tax-category"
},
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z"
}

Specific Error Codes:

  • DuplicatePriceScope
  • DuplicateVariantValues
  • DuplicateAttributeValue
  • DuplicateAttributeValues

Update actions

Set Product Key

action
String
"setKey"
key
String

Value to set. If empty, any existing value will be removed.

Example: json
{
"action" : "setKey",
"key" : "DefaultKey"
}

Change Product Name

action
String
"changeName"
name

Value to set. Must not be empty.

staged
Boolean

If true, only the staged name is updated. If false, both the current and staged name are updated.

Default: true
Example: json
{
"action" : "changeName",
"name" : {
"de" : "Mein neuer Produkt Name",
"en" : "My new product name"
}
}

Set Product Description

action
String
"setDescription"
description

Value to set. If empty, any existing value will be removed.

staged
Boolean

If true, only the staged description is updated. If false, both the current and staged description are updated.

Default: true
Example: json
{
"action" : "setDescription",
"description" : {
"de" : "Dies ist eine neue Produktbeschreibung",
"en" : "This is a new product description"
}
}

Change Slug

Produces the ProductSlugChanged Message.

action
String
"changeSlug"
slug

Value to set. Must not be empty. A Product can have the same slug for different Locales, but it must be unique across the Project. Must match the pattern ^[A-Za-z0-9_-]{2,256}+$.

staged
Boolean

If true, only the staged slug is updated. If false, both the current and staged slug are updated.

Default: true
Example: json
{
"action" : "changeSlug",
"slug" : {
"de" : "mein-neuer-produkt-slug",
"en" : "my-new-product-slug"
}
}

Add ProductVariant

action
String
"addVariant"
key
String

Value to set. Must be unique.

sku
String

Value to set. Must be unique.

prices
Array of PriceDraft

Embedded Prices for the Product Variant.

MaxItems: 100
images
Array of Image

Images for the Product Variant.

attributes
Array of Attribute

Attributes for the Product Variant.

staged
Boolean

If true the new Product Variant is only staged. If false the new Product Variant is both current and staged.

Default: true
assets
Array of Asset

Media assets for the Product Variant.

Example: json
{
"action" : "addVariant",
"key" : "VariantKey",
"sku" : "VariantSKU"
}

Remove ProductVariant

Either id or sku is required. Produces the ProductVariantDeleted Message.

id
Int

The id of the ProductVariant to remove.

action
String
"removeVariant"
sku
String

The sku of the ProductVariant to remove.

staged
Boolean

If true, only the staged ProductVariant is removed. If false, both the current and staged ProductVariant is removed.

Default: true
Example: json
{
"action" : "removeVariant",
"id" : 2
}

Change Master Variant

Assigns the specified Product Variant to the masterVariant and removes the same from variants at the same time. The current Master Variant becomes part of the variants array. Either variantId or sku is required.

action
String
"changeMasterVariant"
variantId
Int

The id of the ProductVariant to become the Master Variant.

sku
String

The sku of the ProductVariant to become the Master Variant.

staged
Boolean

If true, only the staged Master Variant is changed. If false, both the current and staged Master Variant are changed.

Default: true
Example: json
{
"action" : "changeMasterVariant",
"variantId" : 1
}

Set PriceMode

Controls whether the Prices of a Product Variant are embedded into the Product or standalone.

action
String
"setPriceMode"
priceMode

Specifies which type of Prices should be used when looking up a price for the Product.

Default: Embedded
Example: json
{
"action" : "setPriceMode",
"priceMode" : "Standalone"
}

Add Embedded Price

Adds the given Price to the prices array of the ProductVariant. Either variantId or sku is required.

action
String
"addPrice"
variantId
Int

The id of the ProductVariant to update.

sku
String

The sku of the ProductVariant to update.

price

Embedded Price to add to the Product Variant.

staged
Boolean

If true, only the staged prices is updated. If false, both the current and staged prices are updated.

Default: true
Example: json
{
"action" : "addPrice",
"variantId" : 1,
"price" : {
"value" : {
"currencyCode" : "EUR",
"centAmount" : 4000
}