Skip to main content

Preview Variant Combinations

POST 

/api/v2/products/:product/variants/preview

Returns one row per combination of the given attribute values, with the SKU each new variant would get. Nothing is written.

Required scope: products:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Each row reports exists (a variant with that combination already exists and will be skipped), duplicate_sku (two combinations produce the same SKU — fix the pattern), sku_taken (another product, archived ones included, already holds the SKU; sku_conflict explains and sku_holder_id names that product) and combo_key, the stable key used for exclusions and per-row pricing.

Body fields

  • attributes (array, required, 1–3 items) — the matrix to combine
  • attributes[].attribute_id (integer, required) — an existing attribute ID
  • attributes[].values (array of strings, required, each ≤120 chars) — the values to combine
  • sku_pattern (string, required, ≤120 chars) — placeholders {parent_sku}, {v1}, {v2}, {v3} (or {value1}…). Values keep their case; spaces and punctuation are removed.
  • exclusions (array of strings, optional) — combo_key values to leave out

Authentication: Requires Bearer token.

A product that is itself a variant (it has a parent) cannot have variants: the request is refused with 422 on product. Generate variants on its parent instead.

Request​

Responses​

OK

Response Headers
    Content-Type