For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create a product variant

Add a variant to a product along one or more option dimensions (e.g.

Create a product variant

post

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.

Authorizations
AuthorizationstringRequired

API Token authentication

Path parameters
store_idstringRequired

The ID of the store that owns the product.

Example: store_01J8Z5F8W9K8M4A7B3C2D1E0FG
product_idstringRequired

The ID of the product to add the variant to.

Example: prod_01J8Z5F8W9K8M4A7B3C2D1E0FG
Body
titlestring · max: 255Optional

The variant title. Defaults to the option values joined with ' / ' (e.g. 'Red / L').

Example: Red / M
skustring · max: 255Optional

The variant SKU.

Example: TSHIRT-RED-M
inventory_quantityintegerOptional

Units in stock. Defaults to 0.

Example: 42
manage_inventorybooleanOptional

Whether stock is tracked for this variant. Defaults to false.

Example: true
Responses
201

Created response

application/json
post/api/ecommerce/v1/stores/{store_id}/products/{product_id}/variants
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?