Creating Variation
Endpoint: POST /admin/variations
Purpose
The POST/admin/variations
is used to create a new product variation along with its corresponding options. A variation defines a customizable product attribute such as size, color, material, etc. Each option includes display labels, values, display order, default status, and can include an image reference. This endpoint helps administrators set up new configurable attributes for products to enable flexible product customization.
Path Parameters
No path parameters for this endpoint.
Query Parameters
No query parameters for this endpoint.
Use Case
Administrators use this endpoint to define a new variation and add its available options. Each option is set with values like label, order, and default status. Once created, the system assigns unique IDs to the variation and its options, including auto-generated values or references. This API is crucial for expanding product configuration and enabling customer-facing customization on the storefront.
Request Body
Parameter | Type | Description |
---|---|---|
name | String | The name of the variation. |
standard | String | The type of input for the variation (text). |
is_disposable | Boolean | Indicates whether the variation can be discarded after use. |
options | Array | A list of variation options. |
{
"variation": {
"name": "VARIATION_NAME",
"standard": "VARIATION_STANDARD",
"is_disposable": "VARIATION_IS_DISPOSABLE",
"options": [
{
"id": "VARIATION_OPTION_ID_1",
"label": "VARIATION_OPTION_LABEL_1",
"value": "VARIATION_OPTION_VALUE_1",
"order": "VARIATION_OPTION_ORDER_1",
"default": "VARIATION_OPTION_DEFAULT_1"
},
{
"id": "VARIATION_OPTION_ID_2",
"label": "VARIATION_OPTION_LABEL_2",
"value": "VARIATION_OPTION_VALUE_2",
"order": "VARIATION_OPTION_ORDER_2",
"default": "VARIATION_OPTION_DEFAULT_2"
}
]
}
}
Response
The response returns a structured variation object containing the newly created variation's unique ID, name, input type (standard), and a flag indicating whether it's disposable. It also includes an array of variation options, each with details such as option ID, label, value, display order, whether it is the default selection, and its associated image (if any). This response helps confirm successful creation and allows the client to immediately reflect the variation in the UI or use it in product configurations.
{
"variation": {
"id": "VARIATION_ID",
"name": "VARIATION_NAME",
"standard": "VARIATION_STANDARD",
"is_disposable": "VARIATION_IS_DISPOSABLE",
"options": [
{
"id": "VARIATION_OPTION_ID_1",
"label": "VARIATION_OPTION_LABEL_1",
"value": "VARIATION_OPTION_VALUE_1",
"order": "VARIATION_OPTION_ORDER_1",
"default": "VARIATION_OPTION_DEFAULT_1",
"image": "VARIATION_OPTION_IMAGE_1"
},
{
"id": "VARIATION_OPTION_ID_2",
"label": "VARIATION_OPTION_LABEL_2",
"value": "VARIATION_OPTION_VALUE_2",
"order": "VARIATION_OPTION_ORDER_2",
"default": "VARIATION_OPTION_DEFAULT_2",
"image": "VARIATION_OPTION_IMAGE_2"
}
]
}
}