Creating variant products

Create variants (color, size...) each with its own SKU, price and stock under a single product card, then update variant stock and price individually.

Required scopes

products:write to create, inventory:write for variant stock, prices:write for variant price. products:read to read.

1. Create a product with two variants

Add options (option name + allowed values) and variants (each with sku, price, stock, option_values) to the POST /products body. Each variant's option_values keys must match options exactly and every value must be defined in options. At most 100 variants and 3 options. The product-level sku is optional.

cURL
curl -X POST "https://api.stokzone.com/api/v1/web-api/v1/products" \
  -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
  -d '{
    "name": "Tisort",
    "sku": "TS",
    "price": 100,
    "options": [
      {"name": "Renk",  "values": ["Mavi", "Kirmizi"]},
      {"name": "Beden", "values": ["M", "L"]}
    ],
    "variants": [
      {"sku": "TS-MAVI-M", "price": 100, "stock": 5,
       "option_values": {"Renk": "Mavi", "Beden": "M"}},
      {"sku": "TS-KIR-L", "barcode": "869000000001", "price": 110, "stock": 7,
       "option_values": {"Renk": "Kirmizi", "Beden": "L"}}
    ]
  }'
JSON
HTTP 201
{
  "id": "ef9abfcc-...",
  "sku": "TS",
  "name": "Tisort",
  "price": 100.0,
  "product_type": "variable",
  "stock": 12,
  "variants": [
    {"id": "3a2cebbc-...", "sku": "TS-MAVI-M", "name": "Tisort - Mavi / M",
     "attributes": {"Renk": "Mavi", "Beden": "M"}, "price": 100.0, "stock": 5, "is_active": true},
    {"id": "80586737-...", "sku": "TS-KIR-L", "name": "Tisort - Kirmizi / L",
     "attributes": {"Renk": "Kirmizi", "Beden": "L"}, "price": 110.0, "stock": 7, "is_active": true}
  ]
}

The response is 201; variants[].id are the variant IDs. The same option combination cannot be sent twice.

Error behavior

409: the product SKU or any variant SKU already exists in the workspace (resending the same request does not create a second card). 422: duplicate SKU in the request, option/value mismatch, repeated combination or limit exceeded. 403: missing scope.

2. Read the variants

variants[] in GET /products/{sku} returns id, sku, barcode, name, attributes, price, stock and is_active per variant. If price is null the product's base price applies.

cURL
curl -H "X-API-Key: $KEY" \
  "https://api.stokzone.com/api/v1/web-api/v1/products/TS"

3. Update variant stock

The path parameter is the variant SKU or the variant ID. Stock is written as an absolute value and queued for marketplace push (queued_push). If the same SKU exists on several variants the call returns 409; use the variant ID or product_id in the body. Another workspace's variant returns 404.

cURL
# varyant SKU'su ile
curl -X PATCH "https://api.stokzone.com/api/v1/web-api/v1/products/variants/TS-MAVI-M/stock" \
  -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
  -d '{"stock": 20}'

# varyant kimligi ile
curl -X PATCH "https://api.stokzone.com/api/v1/web-api/v1/products/variants/3a2cebbc-.../stock" \
  -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
  -d '{"stock": 21}'

# yanit
{"variant_id": "3a2cebbc-...", "sku": "TS-MAVI-M", "product_id": "ef9abfcc-...",
 "stock": 20, "price": null, "queued_push": true}

4. Update variant price

Writes the variant price and queues the price push. The same targeting rules apply.

cURL
curl -X PATCH "https://api.stokzone.com/api/v1/web-api/v1/products/variants/TS-KIR-L/price" \
  -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
  -d '{"price": 125.5}'

# yanit
{"variant_id": "80586737-...", "sku": "TS-KIR-L", "product_id": "ef9abfcc-...",
 "stock": null, "price": 125.5, "queued_push": true}

5. Bulk update

Up to 100 rows. Target each row with variant_id or sku and provide stock and/or price. A failing row does not stop the others: the response has updated, failed and per-row results. Rows with price also need prices:write on the key.

cURL
curl -X PATCH "https://api.stokzone.com/api/v1/web-api/v1/products/variants/bulk" \
  -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
  -d '{"items": [
    {"sku": "TS-MAVI-M", "stock": 30, "price": 101},
    {"variant_id": "80586737-...", "stock": 8},
    {"sku": "YOK", "stock": 1}
  ]}'

# yanit (kismi basari)
{"updated": 2, "failed": 1, "results": [
  {"index": 0, "ok": true, "variant_id": "3a2cebbc-...", "sku": "TS-MAVI-M", "error": null},
  {"index": 1, "ok": true, "variant_id": "80586737-...", "sku": "TS-KIR-L", "error": null},
  {"index": 2, "ok": false, "variant_id": null, "sku": "YOK", "error": "404: Varyant bulunamadi"}
]}

Note

On a variant product the total stock is the sum of its variants and is synchronized shortly after; use the stock field on each variant row as the sellable quantity.