Menu
createProduct
Create a new product.
Use it in a workflow
- Add a step and choose the Commercetools connector.
- Pick the createProduct action (under Create).
- Fill in the fields below, then reference the result from later steps as
{{createproduct.response.data}}.
Query
This is the mutation the action sends by default. Edit it in the step's Query field to change which fields come back.
mutation CreateProduct($draft: ProductDraft!) {
createProduct(draft: $draft) {
id
key
version
productTypeRef {
typeId
id
}
productType {
key
name
description
id
version
createdAt
lastModifiedAt
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
}
masterData {
current {
nameAllLocales
descriptionAllLocales
slugAllLocales
categoryOrderHints
categoriesRef
categories
searchKeywords
metaTitleAllLocales
metaKeywordsAllLocales
metaDescriptionAllLocales
masterVariant
skus
attributesRaw
defaultVariantRef
defaultVariant
}
staged {
nameAllLocales
descriptionAllLocales
slugAllLocales
categoryOrderHints
categoriesRef
categories
searchKeywords
metaTitleAllLocales
metaKeywordsAllLocales
metaDescriptionAllLocales
masterVariant
skus
attributesRaw
defaultVariantRef
defaultVariant
}
published
hasStagedChanges
}
skus
createdAt
lastModifiedAt
stateRef {
typeId
id
}
state {
id
version
key
type
roles
nameAllLocales {
locale
value
}
descriptionAllLocales {
locale
value
}
builtIn
transitionsRef {
typeId
id
}
transitions
initial
createdAt
lastModifiedAt
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
}
priceMode
taxCategoryRef {
typeId
id
}
taxCategory {
name
description
rates {
name
amount
includedInPrice
country
state
id
key
subRates
}
key
id
version
createdAt
lastModifiedAt
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
}
reviewRatingStatistics {
averageRating
highestRating
lowestRating
count
ratingsDistribution
}
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef {
typeId
id
}
userRef {
typeId
id
}
associateRef {
typeId
id
}
attributedTo {
clientId
source
userRef
}
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef {
typeId
id
}
userRef {
typeId
id
}
associateRef {
typeId
id
}
attributedTo {
clientId
source
userRef
}
}
}
}
Variables
Pass these as a JSON object in the step's Variables field.
{
"draft": {
"name": [
{
"locale": "string",
"value": "string"
}
],
"productType": {
"typeId": "string",
"id": "string",
"key": "string"
},
"slug": [
{
"locale": "string",
"value": "string"
}
],
"key": "string",
"description": [
{
"locale": "string",
"value": "string"
}
],
"categories": [
{
"typeId": "string",
"id": "string",
"key": "string"
}
],
"categoryOrderHints": [
{
"uuid": "string",
"orderHint": "string"
}
],
"metaTitle": [
{
"locale": "string",
"value": "string"
}
],
"metaDescription": [
{
"locale": "string",
"value": "string"
}
],
"metaKeywords": [
{
"locale": "string",
"value": "string"
}
],
"masterVariant": {
"sku": "string",
"key": "string",
"prices": [
"string"
],
"images": [
"string"
],
"attributes": [
"string"
],
"assets": [
"string"
]
},
"attributes": [
{
"name": "string",
"value": "string"
}
]
}
}
Response
Read the result with {{createproduct.response.data.data.createProduct}}. If the API returns errors, the step fails and they are at {{createproduct.response.data.errors}}.
Need more? See the Commercetools guide for connection setup and behaviour shared by every action.
Was this page helpful?