Skip to main content

Generate Variants

POST 

/api/v2/products/:product/variants/generate

Creates a variant (child product) under the parent for every combination that does not already exist, and records the attributes used on the parent as its variation axes. Each variant is created on its own, so one failure does not stop the rest; the response counts created, skipped and failed variants.

Required scope: products:write

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

Optional pricing: default_price is set on the default pricing tier of every new variant and default_unit_cost becomes its unit cost. row_pricing overrides either value for single combinations — a null value inherits the default. Leave all three out and the variants are created without a price or cost. Prices are recorded in price history and reach listings and derived pricing tiers like any other price change. Existing variants are never repriced.

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
  • default_price (number, optional, 0–99999.99)
  • default_unit_cost (number, optional, 0–99999.99)
  • row_pricing (array, optional)
  • row_pricing[].combo_key (string, required) — from the preview
  • row_pricing[].price (number|null, optional, 0–99999.99)
  • row_pricing[].unit_cost (number|null, optional, 0–99999.99)

Returns 422 when duplicate SKUs are in the grid, when a value is out of range, or when a price is sent but no pricing tier is marked as the default.

Authentication: Requires Bearer token.

Copy from parent: every new variant inherits what siblings share from the parent, per group in copy_from_parent.groups: suppliers (supplier links, default supplier, supplier costs, lead time, minimum order quantity; the supplier SKU from supplier_sku_pattern), pricing (every pricing tier price, quantity breaks, unit cost), classification (brand, product type, categories, seasons, HTS and tariff codes, country of origin), physical (weight, dimensions, case quantity/dimensions/weight with units), media (images linked to the parent's files, non-variant attributes such as the description, tags, custom fields), tax_accounting (taxable, default tax rate, sales tax category, nominal code overrides), inventory (backorders, negative inventory, lot and serial tracking, shelf life, minimum stock level, dropship, preferred bins) and channels (not for sale on channels, channel exclusions). A price or unit cost in default_price / default_unit_cost / row_pricing wins over the copied value. Never copied: SKU, name, barcode, MPN, the variant's own attribute values, stock and listings.

  • copy_from_parent (object, optional) — leave it out to copy every group
  • copy_from_parent.groups (array of strings, required with copy_from_parent) — any of suppliers, pricing, classification, physical, media, tax_accounting, inventory, channels; an empty array copies nothing
  • copy_from_parent.supplier_sku_pattern (string, optional, ≤120 chars) — placeholders {parent_supplier_sku}, {parent_sku}, {v1}…; default {parent_supplier_sku}-{v1}. Blank, or a parent link without a supplier SKU, leaves the variant's supplier SKU empty.

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​

Created

Response Headers
    Content-Type