> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mercurjs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Product Variant

> Add a variant to a product.

Creates a new variant on the product and returns the updated product.

## Path parameters

<ParamField path="id" type="string" required>The product's ID.</ParamField>

## Body parameters

<ParamField body="title" type="string" required>Variant title.</ParamField>
<ParamField body="sku" type="string">Variant SKU.</ParamField>
<ParamField body="ean" type="string">Variant EAN.</ParamField>
<ParamField body="upc" type="string">Variant UPC.</ParamField>
<ParamField body="isbn" type="string">Variant ISBN.</ParamField>
<ParamField body="asin" type="string">Variant ASIN.</ParamField>
<ParamField body="gtin" type="string">Variant GTIN.</ParamField>
<ParamField body="barcode" type="string">Variant barcode.</ParamField>
<ParamField body="hs_code" type="string">Harmonized System code.</ParamField>
<ParamField body="mid_code" type="string">Manufacturer identification code.</ParamField>
<ParamField body="variant_rank" type="number">Sort rank of the variant.</ParamField>
<ParamField body="weight" type="number">Variant weight.</ParamField>
<ParamField body="length" type="number">Variant length.</ParamField>
<ParamField body="height" type="number">Variant height.</ParamField>
<ParamField body="width" type="number">Variant width.</ParamField>
<ParamField body="origin_country" type="string">Country of origin.</ParamField>
<ParamField body="material" type="string">Variant material.</ParamField>
<ParamField body="options" type="object">Map of option title to option value, for example `{"Size": "L"}`.</ParamField>
<ParamField body="metadata" type="object">Custom key-value data.</ParamField>
<ParamField body="additional_data" type="object">Custom data passed to workflow hooks.</ParamField>

## Response

<ResponseField name="product" type="object">
  <Expandable title="properties">
    <ResponseField name="id" type="string">The product's ID.</ResponseField>
    <ResponseField name="title" type="string">Product title.</ResponseField>
    <ResponseField name="variants" type="object[]">All variants, including the created one.</ResponseField>
    <ResponseField name="updated_at" type="string">Last update timestamp.</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'http://localhost:9000/admin/products/prod_01HXYZABCDEF/variants' \
    -H 'Authorization: Bearer <token>' \
    -H 'Content-Type: application/json' \
    -d '{"title": "L", "sku": "LS-L", "options": {"Size": "L"}}'
  ```

  ```ts JS Client theme={null}
  const { product } = await client.admin.products.$id.variants.mutate({
    $id: "prod_01HXYZABCDEF",
    title: "L",
    sku: "LS-L",
    options: { Size: "L" },
  })
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "product": {
      "id": "prod_01HXYZABCDEF",
      "title": "Linen Shirt",
      "variants": [
        { "id": "variant_01HXYZABCDEF", "title": "M", "sku": "LS-M" },
        { "id": "variant_01HXYZABCDEG", "title": "L", "sku": "LS-L" }
      ]
    }
  }
  ```
</ResponseExample>
