Manage Variants independently from Products as a standalone entity.
Each Variant contains current, published data. Staged (draft) data is only present when there are unpublished changes, allowing you to manage changes before publishing them. When you create a Variant, only the current version is created. When you update a Variant, you can choose to update either the current or staged data. When you publish a Variant, the staged data is copied to the current data.
-
This endpoint is only available for Projects with productCatalogModel set to
Modular. -
In the
Modularcatalog model, pricing is exclusively handled through Standalone Prices. Embedded Prices are not supported, and the Project's price mode is fixed toStandalone. -
To query read-only Variant data optimized for storefront display, use the Variant Projections API instead.
Representations
Variant
A Variant represents a single Variant with both current (published) and staged (draft) data. Variants are writable resources that support create, update, and delete operations.
idString | Unique identifier of the Variant. |
versionInt | Current version of the Variant. |
keyString | User-defined unique identifier of the Variant.
This is different from Product key. |
variantIdInt | A unique, sequential identifier of the Variant within the parent Product. |
product | Reference to the parent Product the Variant belongs to. |
publishedBoolean | true if the Variant is published, false if it is unpublished. |
current | The current data of the Variant. |
staged | The staged data of the Variant. Only present if there are staged changes that differ from the current data. |
createdAt | Date and time (UTC) the Variant was initially created. |
createdByBETA | IDs and references that created the Variant. |
lastModifiedAt | Date and time (UTC) the Variant was last updated. |
lastModifiedByBETA | IDs and references that last modified the Variant. |
VariantDraft
Draft for creating a new Variant. When a Variant is created, only the current version is set. The staged version is only set when the Variant is updated with different current and staged data.
keyString | User-defined unique identifier for the Variant. This field is optional, but we strongly recommend setting it. |
skuString | User-defined unique SKU of the Variant. |
product | ResourceIdentifier of the Product the Variant belongs to. |
publishBoolean | Indicates whether the Variant is published.
If Default: true, the Variant will be immediately available in the current published state.false |
imagesArray of Image | Images for the Variant. |
attributesArray of Attribute | Variant Attributes according to the respective AttributeDefinition. |
assetsArray of AssetDraft | Media assets for the Variant. |
VariantPagedQueryResponse
limitInt | Number of results requested. Default: 20Minimum: 0Maximum: 500 |
offsetInt | Number of elements skipped. Default: 0Maximum: 10000 |
countInt | Actual number of results returned. |
totalInt | Total number of results matching the query.
This number is an estimation that is not strongly consistent.
This field is returned by default.
Unless absolutely necessary, use the query parameter withTotal=false to improve performance by deactivating the calculation of this field.
When the results are filtered with a Query Predicate, total is subject to a limit. |
resultsArray of Variant | Variants matching the query. |
VariantData
Contains the actual data for a Variant in either current (published) or staged (draft) state.
skuString | User-defined unique SKU of the Variant. |
imagesArray of Image | Images of the Variant. |
attributesArray of Attribute | Attributes of the Variant according to the respective AttributeDefinition. |
assetsArray of Asset | Media assets of the Variant. |
VariantBulkUpdate
The request body for a bulk update of Variants.
itemsArray of VariantBulkUpdateItem | List of Variants to update. Each item must identify the Variant by MaxItems: id or key.1000 |
actionsArray of VariantUpdateAction |
{
"items": [
{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 1
},
{
"key": "my-variant-key",
"version": 3
}
],
"actions": [
{
"action": "publish"
}
]
}VariantBulkUpdateItem
id or key to identify the Variant.idString | Unique identifier of the Variant to update. Either id or key must be provided. |
versionInt | Expected version of the Variant. Required when the versionControl query parameter is On (the default).
If the version does not match, a ConcurrentModification error is returned for that item.
Not required when versionControl=Off. |
keyString | User-defined unique identifier of the Variant to update. Either id or key must be provided. |
{
"key": "my-variant-key",
"version": 1
}VariantBulkUpdateResponse
The response body for a bulk update of Variants. Contains the individual result for each Variant in the request.
successCountInt | Number of Variants that were successfully updated. |
failureCountInt | Number of Variants that failed to update. |
resultsArray of VariantBulkUpdateResult | Results for each Variant in the request, in the same order as the items in the request body. |
{
"successCount": 1,
"failureCount": 1,
"results": [
{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"status": "Success",
"resource": {
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2
}
},
{
"id": "2c3d4e5f-6a7b-8c9d-0e1f-2a3b4c5d6e7f",
"status": "Fail",
"errors": [
{
"code": "ConcurrentModification",
"message": "Object 2c3d4e5f-6a7b-8c9d-0e1f-2a3b4c5d6e7f has a different version than expected. Expected: 0 - Actual: 3.",
"currentVersion": 3
}
]
}
]
}VariantBulkUpdateResult
status to determine whether the update succeeded or failed.idString | Unique identifier of the Variant from the request. Present when the Variant was identified by id. |
keyString | User-defined unique identifier of the Variant from the request. Present when the Variant was identified by key. |
statusString | Indicates whether the update succeeded or failed. Can be"Success", or "Fail" |
VariantBulkUpdateSuccessResult
Result for a Variant that was successfully updated in a bulk update request.
idString | Unique identifier of the Variant from the request. Present when the Variant was identified by id. |
keyString | User-defined unique identifier of the Variant from the request. Present when the Variant was identified by key. |
statusString | "Success"Indicates whether the update succeeded or failed. |
resource | A lightweight reference containing the id and updated version of the Variant. |
{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"status": "Success",
"resource": {
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2
}
}VariantBulkUpdateResource
id and updated version of a Variant after a successful bulk update.idString | Unique identifier of the updated Variant. |
versionInt | The new version of the Variant after the update. |
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"version": 2
}VariantBulkUpdateFailResult
Result for a Variant that failed to update in a bulk update request.
idString | Unique identifier of the Variant from the request. Present when the Variant was identified by id. |
keyString | User-defined unique identifier of the Variant from the request. Present when the Variant was identified by key. |
statusString | "Fail"Indicates whether the update succeeded or failed. |
errorsArray of ErrorObject | Errors that caused the update to fail for this Variant. |
{
"id": "2c3d4e5f-6a7b-8c9d-0e1f-2a3b4c5d6e7f",
"status": "Fail",
"errors": [
{
"code": "ConcurrentModification",
"message": "Object 2c3d4e5f-6a7b-8c9d-0e1f-2a3b4c5d6e7f has a different version than expected. Expected: 0 - Actual: 3.",
"currentVersion": 3
}
]
}Get Variant
Get Variant by ID
Retrieves a Variant by its ID.
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
idString | id of the Variant. |
expand | The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/variants/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" {
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2,
"createdAt": "2024-01-15T10:30:00.000Z",
"lastModifiedAt": "2024-01-16T14:20:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-blue-medium",
"variantId": 2,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": false,
"current": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/variant-blue-medium.jpg",
"label": "Blue Medium Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/variant-demo-video.mp4",
"key": "demo-video"
}
],
"name": {
"en-US": "Variant Demo Video",
"de-DE": "Variant-Demonstrationsvideo"
},
"description": {
"en-US": "Detailed demonstration of the variant features",
"de-DE": "Detaillierte Demonstration der Variant-Merkmale"
},
"tags": ["video", "demo", "tutorial"]
}
]
},
"staged": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/product-blue-medium-updated.jpg",
"label": "Blue Medium Variant - Updated",
"dimensions": {
"w": 1200,
"h": 900
}
},
{
"url": "https://example.com/images/product-blue-medium-detail.jpg",
"label": "Blue Medium Variant - Detail",
"dimensions": {
"w": 1200,
"h": 900
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
},
{
"name": "material",
"value": "cotton"
},
{
"name": "weight",
"value": 250
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/product-video-v2.mp4",
"key": "product-video-v2"
}
],
"name": {
"en-US": "Product Video - Updated",
"de-DE": "Produktvideo - Aktualisiert",
"fr-FR": "Vidéo du produit - Mise à jour",
"es-ES": "Video del producto - Actualizado"
},
"description": {
"en-US": "Updated product demonstration video with new features",
"de-DE": "Aktualisiertes Produktdemonstrationsvideo mit neuen Funktionen",
"fr-FR": "Vidéo de démonstration mise à jour avec de nouvelles fonctionnalités",
"es-ES": "Video de demostración actualizado con nuevas características"
},
"tags": ["video", "demo", "updated"]
}
]
}
}Get Variant by Key
Retrieves a Variant by its key.
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
keyString | key of the Variant. |
expand | The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/variants/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" {
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2,
"createdAt": "2024-01-15T10:30:00.000Z",
"lastModifiedAt": "2024-01-16T14:20:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-blue-medium",
"variantId": 2,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": false,
"current": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/variant-blue-medium.jpg",
"label": "Blue Medium Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/variant-demo-video.mp4",
"key": "demo-video"
}
],
"name": {
"en-US": "Variant Demo Video",
"de-DE": "Variant-Demonstrationsvideo"
},
"description": {
"en-US": "Detailed demonstration of the variant features",
"de-DE": "Detaillierte Demonstration der Variant-Merkmale"
},
"tags": ["video", "demo", "tutorial"]
}
]
},
"staged": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/product-blue-medium-updated.jpg",
"label": "Blue Medium Variant - Updated",
"dimensions": {
"w": 1200,
"h": 900
}
},
{
"url": "https://example.com/images/product-blue-medium-detail.jpg",
"label": "Blue Medium Variant - Detail",
"dimensions": {
"w": 1200,
"h": 900
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
},
{
"name": "material",
"value": "cotton"
},
{
"name": "weight",
"value": 250
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/product-video-v2.mp4",
"key": "product-video-v2"
}
],
"name": {
"en-US": "Product Video - Updated",
"de-DE": "Produktvideo - Aktualisiert",
"fr-FR": "Vidéo du produit - Mise à jour",
"es-ES": "Video del producto - Actualizado"
},
"description": {
"en-US": "Updated product demonstration video with new features",
"de-DE": "Aktualisiertes Produktdemonstrationsvideo mit neuen Funktionen",
"fr-FR": "Vidéo de démonstration mise à jour avec de nouvelles fonctionnalités",
"es-ES": "Video de demostración actualizado con nuevas características"
},
"tags": ["video", "demo", "updated"]
}
]
}
}Query Variants
Queries Variants matching the provided predicates. This endpoint returns both current (published) and staged (draft) data for each Variant.
attribute-name and attribute-value details in the QueryPredicate. Otherwise, a 400 Bad Request error will occur.view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
where | |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limitInt | Number of results requested. Default: 20Minimum: 0Maximum: 500 |
offsetInt | Number of elements skipped. Default: 0Maximum: 10000 |
withTotalBoolean | Controls the calculation of the total number of query results. Set to false to improve query performance when the total is not needed.Default: true |
var.<varName>String | Predicate parameter values. The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/variants -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" {
"limit": 20,
"offset": 0,
"count": 2,
"total": 2,
"results": [
{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 1,
"createdAt": "2024-01-15T10:30:00.000Z",
"lastModifiedAt": "2024-01-15T10:30:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-blue-medium",
"variantId": 2,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": true,
"current": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/product-blue-medium.jpg",
"label": "Blue Medium Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/product-blue-video.mp4",
"key": "product-blue-video"
}
],
"name": {
"en-US": "Blue Variant Video",
"de-DE": "Blaue Variante Video"
},
"description": {
"en-US": "Product demonstration video for blue variant",
"de-DE": "Produktdemonstrationsvideo für blaue Variante"
},
"tags": ["video", "blue", "medium"]
}
]
}
},
{
"id": "8b4c6d9e-2f3a-5b6c-9d0e-1f2a3b4c5d6e",
"version": 1,
"createdAt": "2024-01-15T11:00:00.000Z",
"lastModifiedAt": "2024-01-15T11:00:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-red-large",
"variantId": 3,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": true,
"current": {
"sku": "SKU-RED-L-002",
"images": [
{
"url": "https://example.com/images/product-red-large.jpg",
"label": "Red Large Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "red"
},
{
"name": "size",
"value": "L"
}
],
"assets": [
{
"id": "8e7d6c5b-4a3c-2d1e-0f1a-2b3c4d5e6f7a",
"sources": [
{
"uri": "https://example.com/assets/product-red-video.mp4",
"key": "product-red-video"
}
],
"name": {
"en-US": "Red Variant Video",
"de-DE": "Rote Variante Video"
},
"description": {
"en-US": "Product demonstration video for red variant",
"de-DE": "Produktdemonstrationsvideo für rote Variante"
},
"tags": ["video", "red", "large"]
}
]
}
}
]
}Check if Variant exists
Check if Variant exists by ID
200 status if the Variant exists, or a 404 status otherwise.view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
idString | id of the Variant. |
curl --head https://api.{region}.commercetools.com/{projectKey}/variants/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" Check if Variant exists by Key
200 status if the Variant exists, or a 404 status otherwise.view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
keyString | key of the Variant. |
curl --head https://api.{region}.commercetools.com/{projectKey}/variants/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" Check if Variant exists by Query Predicate
200 status if any Variants match, or a 404 status otherwise.view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
where |
curl --head https://api.{region}.commercetools.com/{projectKey}/variants?where={where} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"Create Variant
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
expand | The parameter can be passed multiple times. |
application/jsonapplication/jsoncurl https://api.{region}.commercetools.com/{projectKey}/variants -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"product" : {
"typeId" : "product",
"id" : "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"publish" : false,
"sku" : "SKU-BLUE-M-001",
"key" : "blue-medium-variant",
"images" : [ {
"url" : "https://example.com/images/variant-blue-medium.jpg",
"label" : "Blue Medium Variant",
"dimensions" : {
"w" : 800,
"h" : 600
}
} ],
"attributes" : [ {
"name" : "color",
"value" : "blue"
}, {
"name" : "size",
"value" : "M"
} ],
"assets" : [ {
"sources" : [ {
"uri" : "https://example.com/assets/variant-demo-video.mp4",
"key" : "demo-video"
} ],
"name" : {
"en-US" : "Variant Demo Video",
"de-DE" : "Variant-Demonstrationsvideo"
},
"description" : {
"en-US" : "Detailed demonstration of the variant features",
"de-DE" : "Detaillierte Demonstration der Variant-Merkmale"
},
"tags" : [ "video", "demo", "tutorial" ]
} ]
}
DATA{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 1,
"createdAt": "2024-01-15T10:30:00.000Z",
"lastModifiedAt": "2024-01-16T14:20:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-blue-medium",
"variantId": 1,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": false,
"current": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/variant-blue-medium.jpg",
"label": "Blue Medium Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/variant-demo-video.mp4",
"key": "demo-video"
}
],
"name": {
"en-US": "Variant Demo Video",
"de-DE": "Variant-Demonstrationsvideo"
},
"description": {
"en-US": "Detailed demonstration of the variant features",
"de-DE": "Detaillierte Demonstration der Variant-Merkmale"
},
"tags": ["video", "demo", "tutorial"]
}
]
}
}Update Variant
Update Variant by ID
Updates a Variant identified by its ID.
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
idString | id of the Variant. |
expand | The parameter can be passed multiple times. |
application/jsonversionInt | Expected version of the Variant on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actionsArray of VariantUpdateAction | Update actions to be performed on the Variant. |
application/jsoncurl https://api.{region}.commercetools.com/{projectKey}/variants/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 1,
"actions" : [ {
"action" : "setSku",
"sku" : "SKU-BLUE-M-002",
"staged" : true
} ]
}
DATA{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2,
"createdAt": "2024-01-15T10:30:00.000Z",
"lastModifiedAt": "2024-01-17T09:15:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-blue-medium",
"variantId": 2,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": false,
"current": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/variant-blue-medium.jpg",
"label": "Blue Medium Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/variant-demo-video.mp4",
"key": "demo-video"
}
],
"name": {
"en-US": "Variant Demo Video",
"de-DE": "Variant-Demonstrationsvideo"
},
"description": {
"en-US": "Detailed demonstration of the variant features",
"de-DE": "Detaillierte Demonstration der Variant-Merkmale"
},
"tags": ["video", "demo", "tutorial"]
}
]
},
"staged": {
"sku": "SKU-BLUE-M-002"
}
}Update Variant by Key
Updates a Variant identified by its key.
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
keyString | key of the Variant. |
expand | The parameter can be passed multiple times. |
application/jsonversionInt | Expected version of the Variant on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actionsArray of VariantUpdateAction | Update actions to be performed on the Variant. |
application/jsoncurl https://api.{region}.commercetools.com/{projectKey}/variants/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 1,
"actions" : [ {
"action" : "setSku",
"sku" : "SKU-BLUE-M-002",
"staged" : true
} ]
}
DATA{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2,
"createdAt": "2024-01-15T10:30:00.000Z",
"lastModifiedAt": "2024-01-17T09:15:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-blue-medium",
"variantId": 2,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": false,
"current": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/variant-blue-medium.jpg",
"label": "Blue Medium Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/variant-demo-video.mp4",
"key": "demo-video"
}
],
"name": {
"en-US": "Variant Demo Video",
"de-DE": "Variant-Demonstrationsvideo"
},
"description": {
"en-US": "Detailed demonstration of the variant features",
"de-DE": "Detaillierte Demonstration der Variant-Merkmale"
},
"tags": ["video", "demo", "tutorial"]
}
]
},
"staged": {
"sku": "SKU-BLUE-M-002"
}
}Bulk update Variants
207 Multi-Status response with the result for each Variant.
Each Variant is updated independently, so some may succeed while others fail.manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
versionControlString | Controls whether optimistic concurrency is enforced for each item.
Default: On |
application/jsonapplication/jsoncurl https://api.{region}.commercetools.com/{projectKey}/variants/bulk -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"items" : [ {
"id" : "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version" : 1
}, {
"key" : "my-variant-key",
"version" : 3
} ],
"actions" : [ {
"action" : "publish"
} ]
}
DATA{
"successCount": 1,
"failureCount": 1,
"results": [
{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"status": "Success",
"resource": {
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2
}
},
{
"id": "2c3d4e5f-6a7b-8c9d-0e1f-2a3b4c5d6e7f",
"status": "Fail",
"errors": [
{
"code": "ConcurrentModification",
"message": "Object 2c3d4e5f-6a7b-8c9d-0e1f-2a3b4c5d6e7f has a different version than expected. Expected: 0 - Actual: 3.",
"currentVersion": 3
}
]
}
]
}Update actions
on Variant
Set SKU
actionString | "setSku" |
skuString | Value to set. Must be unique. |
stagedBoolean | If Default: true, only the staged sku is updated. If false, both the current and staged sku are updated.true |
{
"action": "setSku",
"sku": "SKU-12345",
"staged": true
}Set Key
actionString | "setKey" |
keyString | Value to set. Must be unique. |
{
"action": "setKey",
"key": "my-variant-key"
}Set Images
actionString | "setImages" |
imagesArray of Image | Images to set for the Variant. |
stagedBoolean | If Default: true, only the staged images are updated. If false, both the current and staged images are updated.true |
{
"action": "setImages",
"images": [
{
"url": "https://example.com/product-image.jpg",
"dimensions": {
"w": 1024,
"h": 76
},
"label": "Main product image"
}
],
"staged": true
}Add External Image
actionString | "addExternalImage" |
image | Value to add to images. |
stagedBoolean | If Default: true, only the staged images is updated. If false, both the current and staged images is updated.true |
{
"action": "addExternalImage",
"image": {
"url": "//myimage.jpg",
"dimensions": {
"w": 1400,
"h": 1400
},
"label": "myImage"
}
}Remove Image
Removes a Variant's image.
actionString | "removeImage" |
imageUrlString | The URL of the image to remove. |
stagedBoolean | If Default: true, only the staged image is removed. If false, both the current and staged image is removed.true |
{
"action": "removeImage",
"imageUrl": "//myimage2.jpg"
}Set Assets
Sets the assets of the Variant. Existing assets will be replaced with the new ones.
actionString | "setAssets" |
assetsArray of AssetDraft | Assets to set for the Variant. |
stagedBoolean | If Default: true, only the staged assets are set. If false, both the current and staged assets are updated.true |
{
"action": "setAssets",
"assets": [
{
"sources": [
{
"uri": "https://example.com/asset.jpg",
"key": "main-image"
}
],
"name": {
"en-US": "Product Image",
"de-DE": "Produktbild",
"fr-FR": "Image du produit",
"es-ES": "Imagen del producto"
},
"description": {
"en-US": "Main product image",
"de-DE": "Hauptproduktbild",
"fr-FR": "Image principale du produit",
"es-ES": "Imagen principal del producto"
},
"tags": [
"product",
"main"
],
"key": "main-product-asset"
}
],
"staged": true
}Add Asset
Adds an asset to existing variant's assets.
actionString | "addAsset" |
stagedBoolean | If Default: true, only the staged assets are updated. If false, both the current and staged assets are updated.true |
asset | Value to append. |
positionInt | Position in assets where the Asset should be put. When specified, the value must be between 0 and the total number of Assets minus 1. |
{
"action": "addAsset",
"asset": {
"sources": [
{
"uri": "//asset.mp4"
}
],
"name": {
"de": "FirstAssetDE",
"en": "FirstassetEN"
}
}
}Remove Asset
assetId or assetKey.actionString | "removeAsset" |
stagedBoolean | If Default: true, only the staged Asset is removed. If false, both the current and staged Asset is removed.true |
assetIdString | The id of the Asset to remove. |
assetKeyString | The key of the Asset to remove. |
{
"action": "removeAsset",
"assetId": "{{assetId}}"
}Set Attributes
Sets the attributes of the Variant. Existing attributes will be replaced with the new ones.
actionString | "setAttributes" |
attributesArray of Attribute | Attributes to set for the Variant according to the respective AttributeDefinition. |
stagedBoolean | If Default: true, only the staged attributes are updated. If false, both the current and staged attributes are updated.true |
{
"action": "setAttributes",
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"staged": true
}Set Attribute
Set a specific Variant attribute.
actionString | "setAttribute" |
nameString | Name of the Attribute to set. |
valueAny | Value to set for the Attribute. If empty, any existing value will be removed. The AttributeType determines the format of the Attribute
value to be provided:
|
stagedBoolean | If Default: true, only the staged Attribute is set. If false, both the current and staged Attributes are set.true |
{
"action": "setAttribute",
"name": "ExampleStringTypeAttribute",
"value": "TextString"
}Remove Staged Changes
actionString | "removeStagedChanges" |
{
"action": "removeStagedChanges"
}Publish
published flag to true. Staged will be empty.
The parent Product must be published before a Variant can be published.
Generates the VariantPublished Message.actionString | "publish" |
{
"action": "publish"
}Unpublish
published flag to false.
Generates the VariantUnpublished Message.actionString | "unpublish" |
{
"action": "unpublish"
}on Asset
Set Asset Key
Sets the key of an existing Asset on a Variant.
actionString | "setAssetKey" |
stagedBoolean | If Default: true, only the staged Asset is updated. If false, both the current and staged Asset is updated.true |
assetIdString | The id of the Asset to update. |
assetKeyString | Value to set. If empty, any existing value will be removed. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
{
"action": "setAssetKey",
"assetId": "{{assetId}}",
"assetKey": "my-asset-key"
}Change Asset Order
Changes the order of Assets on a Variant.
actionString | "changeAssetOrder" |
stagedBoolean | If Default: true, only the staged assets is updated. If false, both the current and staged assets are updated.true |
assetOrderArray of String | All existing Asset ids of the Variant in the desired new order. |
{
"action": "changeAssetOrder",
"assetOrder": [
"{{assetId1}}",
"{{assetId2}}"
]
}Change Asset Name
assetId or assetKey.actionString | "changeAssetName" |
stagedBoolean | If Default: true, only the staged Asset is updated. If false, both the current and staged Asset is updated.true |
assetIdString | The id of the Asset to update. |
assetKeyString | The key of the Asset to update. |
name | New value to set. Must not be empty. |
{
"action": "changeAssetName",
"assetId": "{{assetId}}",
"name": {
"de": "Mein Asset",
"en": "My asset"
}
}Set Asset Description
assetId or assetKey.actionString | "setAssetDescription" |
stagedBoolean | If Default: true, only the staged Asset is updated. If false, both the current and staged Asset is updated.true |
assetIdString | The id of the Asset to update. |
assetKeyString | The key of the Asset to update. |
description | Value to set. If empty, any existing value will be removed. |
{
"action": "setAssetDescription",
"assetId": "{{assetId}}",
"description": {
"de": "Dies ist eine Asset-Beschreibung",
"en": "This is an asset description"
}
}Set Asset Sources
assetId or assetKey.actionString | "setAssetSources" |
stagedBoolean | If Default: true, only the staged Asset is updated. If false, both the current and staged Asset is updated.true |
assetIdString | The id of the Asset to update. |
assetKeyString | The key of the Asset to update. |
sourcesArray of AssetSource | Value to set. MinItems:1 |
{
"action": "setAssetSources",
"assetId": "{{assetId}}",
"sources": [
{
"uri": "https://www.example.com/logo.svg",
"key": "vector"
}
]
}Set Asset Custom Type
assetId or assetKey.actionString | "setAssetCustomType" |
stagedBoolean | If Default: true, only the staged Asset is updated. If false, both the current and staged Asset is updated.true |
assetIdString | The id of the Asset to update. |
assetKeyString | The key of the Asset to update. |
type | Defines the Type that extends the Asset with Custom Fields.
If absent, any existing Type and Custom Fields are removed from the Asset. |
fields | Sets the Custom Fields fields for the Asset. |
{
"action": "setAssetCustomType",
"assetId": "{{assetId}}",
"type": {
"id": "{{type-id}}",
"typeId": "type"
},
"fields": {
"exampleStringField": "TextString"
}
}Set Asset Custom Field
assetId or assetKey.actionString | "setAssetCustomField" |
stagedBoolean | If Default: true, only the staged Asset is updated. If false, both the current and staged Asset is updated.true |
assetIdString | The id of the Asset to update. |
assetKeyString | The key of the Asset to update. |
nameString | Name of the Custom Field. |
value | If value is absent or null, this field will be removed if it exists.
Removing a field that does not exist returns an InvalidOperation error.
If value is provided, it is set for the field defined by name. |
{
"action": "setAssetCustomField",
"assetId": "{{assetId}}",
"name": "exampleStringField",
"value": "TextString"
}Delete Variant
DefaultVariantDeleted warning.Delete Variant by ID
Deletes a Variant identified by its ID.
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
idString | id of the Variant. |
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/jsoncurl -X DELETE https://api.{region}.commercetools.com/{projectKey}/variants/{id}?version={version} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2,
"createdAt": "2024-01-15T10:30:00.000Z",
"lastModifiedAt": "2024-01-16T14:20:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-blue-medium",
"variantId": 2,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": false,
"current": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/variant-blue-medium.jpg",
"label": "Blue Medium Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/variant-demo-video.mp4",
"key": "demo-video"
}
],
"name": {
"en-US": "Variant Demo Video",
"de-DE": "Variant-Demonstrationsvideo"
},
"description": {
"en-US": "Detailed demonstration of the variant features",
"de-DE": "Detaillierte Demonstration der Variant-Merkmale"
},
"tags": ["video", "demo", "tutorial"]
}
]
},
"staged": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/product-blue-medium-updated.jpg",
"label": "Blue Medium Variant - Updated",
"dimensions": {
"w": 1200,
"h": 900
}
},
{
"url": "https://example.com/images/product-blue-medium-detail.jpg",
"label": "Blue Medium Variant - Detail",
"dimensions": {
"w": 1200,
"h": 900
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
},
{
"name": "material",
"value": "cotton"
},
{
"name": "weight",
"value": 250
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/product-video-v2.mp4",
"key": "product-video-v2"
}
],
"name": {
"en-US": "Product Video - Updated",
"de-DE": "Produktvideo - Aktualisiert",
"fr-FR": "Vidéo du produit - Mise à jour",
"es-ES": "Video del producto - Actualizado"
},
"description": {
"en-US": "Updated product demonstration video with new features",
"de-DE": "Aktualisiertes Produktdemonstrationsvideo mit neuen Funktionen",
"fr-FR": "Vidéo de démonstration mise à jour avec de nouvelles fonctionnalités",
"es-ES": "Video de demostración actualizado con nuevas características"
},
"tags": ["video", "demo", "updated"]
}
]
}
}Delete Variant by Key
Deletes a Variant identified by its key.
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
keyString | key of the Variant. |
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/jsoncurl -X DELETE https://api.{region}.commercetools.com/{projectKey}/variants/key={key}?version={version} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"{
"id": "7a3b5c8d-1e2f-4a5b-8c9d-0e1f2a3b4c5d",
"version": 2,
"createdAt": "2024-01-15T10:30:00.000Z",
"lastModifiedAt": "2024-01-16T14:20:00.000Z",
"lastModifiedBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"createdBy": {
"clientId": "abc123xyz789",
"isPlatformClient": false
},
"key": "variant-blue-medium",
"variantId": 2,
"product": {
"typeId": "product",
"id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
},
"published": false,
"current": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/variant-blue-medium.jpg",
"label": "Blue Medium Variant",
"dimensions": {
"w": 800,
"h": 600
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/variant-demo-video.mp4",
"key": "demo-video"
}
],
"name": {
"en-US": "Variant Demo Video",
"de-DE": "Variant-Demonstrationsvideo"
},
"description": {
"en-US": "Detailed demonstration of the variant features",
"de-DE": "Detaillierte Demonstration der Variant-Merkmale"
},
"tags": ["video", "demo", "tutorial"]
}
]
},
"staged": {
"sku": "SKU-BLUE-M-001",
"images": [
{
"url": "https://example.com/images/product-blue-medium-updated.jpg",
"label": "Blue Medium Variant - Updated",
"dimensions": {
"w": 1200,
"h": 900
}
},
{
"url": "https://example.com/images/product-blue-medium-detail.jpg",
"label": "Blue Medium Variant - Detail",
"dimensions": {
"w": 1200,
"h": 900
}
}
],
"attributes": [
{
"name": "color",
"value": "blue"
},
{
"name": "size",
"value": "M"
},
{
"name": "material",
"value": "cotton"
},
{
"name": "weight",
"value": 250
}
],
"assets": [
{
"id": "9f8e7d6c-5b4a-3c2d-1e0f-1a2b3c4d5e6f",
"sources": [
{
"uri": "https://example.com/assets/product-video-v2.mp4",
"key": "product-video-v2"
}
],
"name": {
"en-US": "Product Video - Updated",
"de-DE": "Produktvideo - Aktualisiert",
"fr-FR": "Vidéo du produit - Mise à jour",
"es-ES": "Video del producto - Actualizado"
},
"description": {
"en-US": "Updated product demonstration video with new features",
"de-DE": "Aktualisiertes Produktdemonstrationsvideo mit neuen Funktionen",
"fr-FR": "Vidéo de démonstration mise à jour avec de nouvelles fonctionnalités",
"es-ES": "Video de demostración actualizado con nuevas características"
},
"tags": ["video", "demo", "updated"]
}
]
}
}