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

# Create Variant

> Add variants to a product

<Note>
  There is **no variant endpoint on the OAuth App API** (`/api/v1/`). This is
  the merchant Admin API route, authenticated with a **merchant access token**
  (not an app OAuth access token). To create variants from an app, send them in
  the `variants[]` array of [Create Product](/api-reference/products/create).
</Note>

# Create Variant

There is no OAuth App API route for creating variants individually. Variants
are created in one of two ways:

1. **Merchant dashboard API** — `POST /variants/bulk-add-variant/{product_id}`
   adds one or more variants to an existing product (described below).
2. **App API product create** — pass a nested `variants` array inside the body
   of `POST /api/v1/products.json` ([Create Product](/api-reference/products/create)).

This page documents the merchant `bulk-add-variant` route. It requires a
merchant (or staff) JWT and accepts a **multipart/form-data** body (so an
optional `mainImage` file can be attached). The `variants` field is a JSON
array of variant objects.

## Path Parameters

<ParamField path="product_id" type="string" required>
  The product ID to add variants to.
</ParamField>

## Body Parameters

<ParamField body="variants" type="array" required>
  Array of variant objects. Each object accepts the fields below.
</ParamField>

<ParamField body="append" type="boolean" default="false">
  When `true`, append the supplied variants to the product's existing set.
  When `false` (default), the supplied set replaces the product's variants.
</ParamField>

<ParamField body="mainImage" type="file">
  Optional variant image (multipart file part).
</ParamField>

### Variant object fields

<ParamField body="name" type="string" required>
  Option name (e.g. `"Size"`).
</ParamField>

<ParamField body="value" type="string">
  Option value (e.g. `"Medium"`).
</ParamField>

<ParamField body="price" type="number" required>
  Variant price.
</ParamField>

<ParamField body="discountPrice" type="number">
  Discounted / compare-at price.
</ParamField>

<ParamField body="stock" type="number">
  Stock quantity.
</ParamField>

<ParamField body="stockStatus" type="string">
  Stock status (e.g. `in_stock`).
</ParamField>

<ParamField body="skuId" type="string">
  Stock keeping unit.
</ParamField>

<ParamField body="weight" type="number">
  Variant weight.
</ParamField>

<ParamField body="weightUnit" type="string">
  Weight unit (e.g. `kg`).
</ParamField>

## Request

```bash theme={null}
curl -X POST "https://api.launchmystore.io/variants/bulk-add-variant/prod_xyz789" \
  -H "Authorization: Bearer YOUR_MERCHANT_JWT" \
  -F 'variants=[{"name":"Size","value":"Large","price":29.99,"discountPrice":39.99,"stock":100,"skuId":"TSHIRT-BLUE-L","weight":0.24,"weightUnit":"kg"}]' \
  -F "append=true"
```

## Response

Responses use the platform response envelope: `status`, `state`, `message`,
`data`.

<ResponseExample>
  ```json theme={null}
  {
    "status": 200,
    "state": "success",
    "message": "Variants added successfully",
    "data": {
      "variants": [
        {
          "varientId": "var_new123",
          "productId": "prod_xyz789",
          "name": "Size",
          "value": "Large",
          "price": 29.99,
          "discountPrice": 39.99,
          "stock": 100,
          "skuId": "TSHIRT-BLUE-L",
          "weight": 0.24,
          "weightUnit": "kg"
        }
      ]
    }
  }
  ```
</ResponseExample>
