Create a product variant
Add a variant to a product along one or more option dimensions (e.g.
Add a variant to a product along one or more option dimensions (e.g. Size, Color). Options missing from the product are created automatically; provide a value for every option the product already has. Prices are integers in the smallest currency unit and default to the store currency. Returns the created variant.
API Token authentication
The ID of the store that owns the product.
store_01J8Z5F8W9K8M4A7B3C2D1E0FGThe ID of the product to add the variant to.
prod_01J8Z5F8W9K8M4A7B3C2D1E0FGThe variant title. Defaults to the option values joined with ' / ' (e.g. 'Red / L').
Red / MThe variant SKU.
TSHIRT-RED-MUnits in stock. Defaults to 0.
42Whether stock is tracked for this variant. Defaults to false.
trueCreated response
Unauthenticated response
Validation error response
Error response
POST /api/ecommerce/v1/stores/{store_id}/products/{product_id}/variants HTTP/1.1
Host: developers.hostinger.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 191
{
"title": "Red / M",
"sku": "TSHIRT-RED-M",
"options": [
{
"name": "Size",
"value": "M"
}
],
"prices": [
{
"amount": 1999,
"sale_amount": 1499,
"currency": "usd"
}
],
"inventory_quantity": 42,
"manage_inventory": true
}{
"data": {
"id": "variant_01J8Z5F8W9K8M4A7B3C2D1E0FG",
"title": "Red / M",
"sku": "TSHIRT-RED-M",
"options": [
{
"name": "Size",
"value": "M"
}
],
"prices": [
{
"amount": 1999,
"sale_amount": null,
"currency_code": "usd"
}
],
"inventory_quantity": 42,
"manage_inventory": true
}
}Last updated
Was this helpful?