**Version: 202201**

# Create Variant

**POST** `/openapi/2022-01/products/:product_id/variants`

Create a new product variant with the specified details.

## Request

**Path Parameters**

- `product_id` string (required)

  Product's ID

**application/json**

**Body | Example**

**Body**

- `variant` object

  - `option1` string

    The first style value of the variant
  - `option2` string

    The second style value of the variant
  - `option3` string

    The second style value of the variant
  - `image_id` string
  - `compare_at_price` string

    Variant original price, used for comparison with the actual price, can be converted to float64, supports only two decimal places
  - `price` string

    Variant actual price, can be converted to float64, supports only two decimal places, set to "0.00" if price needs to be empty
  - `position` int32 (required)
  - `sku` string
  - `barcode` string
  - `note` string
  - `inventory_quantity` int32
  - `weight` string
  - `weight_unit` string

    Weight unit, supports `kg`, `g`, `lb`, `oz`
  - `cost_price` string
  - `wholesale_price` object[]

    *   Array [

    - `price` string
    - `min_quantity` int32

      Mini Order Quantity
    *   ]

```json
{
  "variant": {
    "option1": "string",
    "option2": "string",
    "option3": "string",
    "image_id": "string",
    "compare_at_price": "string",
    "price": "string",
    "position": 0,
    "sku": "string",
    "barcode": "string",
    "note": "string",
    "inventory_quantity": 0,
    "weight": "string",
    "weight_unit": "string",
    "cost_price": "string",
    "wholesale_price": [
      {
        "price": "string",
        "min_quantity": 0
      }
    ]
  }
}
```

## Responses

**200 | 404 | 422**

200

**application/json**

**Schema | Example | Result**

**Schema**

- `variant` object

  - `id` string

    **Example:** `1b735278-62c7-41ad-9976-b1b63a90590d`
  - `product_id` string

    **Example:** `636a07da-39eb-4829-bde9-b65fae1c28b0`
  - `image_id` string

    **Example:** `91d032e7-bbc8-47e4-8668-9ba6fe714de6`
  - `created_at` string

    **Example:** `2024-04-15T02:00:57Z`
  - `updated_at` string

    **Example:** `2024-04-15T02:00:57Z`
  - `title` string

    **Example:** `S-red`
  - `option1` string

    **Example:** `S`
  - `option2` string

    **Example:** `red`
  - `option3` string

    **Example:**
  - `image` object

    - `src` string

      **Example:** `//cdn.shoplazza.com/efd33b921cacd5311a32dd03a9bc8740.png`
    - `width` integer

      **Default value:** `0`

      **Example:** `1588`
    - `height` integer

      **Default value:** `0`

      **Example:** `2246`
    - `path` string

      **Example:** `efd33b921cacd5311a32dd03a9bc8740.png`
    - `alt` string

      **Example:**
  - `position` integer

    **Default value:** `0`

    **Example:** `1`
  - `compare_at_price` string

    **Example:** `100.00`
  - `price` string

    **Example:** `100.00`
  - `sku` string

    **Example:** `S-RED`
  - `barcode` string

    **Example:** `123`
  - `note` string

    **Example:** `s-red`
  - `inventory_quantity` integer

    **Default value:** `0`

    **Example:** `10`
  - `weight` string

    **Example:** `0.10`
  - `weight_unit` string

    **Example:** `kg`
  - `cost_price` string

    **Example:** `11.00`
  - `wholesale_price` object[]

    *   Array [

    - `price` string

      **Example:** `100.00`
    - `min_quantity` integer

      **Default value:** `0`

      **Example:** `1`
    *   ]
  - `extend`

```json
{
  "variant": {
    "id": "1b735278-62c7-41ad-9976-b1b63a90590d",
    "product_id": "636a07da-39eb-4829-bde9-b65fae1c28b0",
    "image_id": "91d032e7-bbc8-47e4-8668-9ba6fe714de6",
    "created_at": "2024-04-15T02:00:57Z",
    "updated_at": "2024-04-15T02:00:57Z",
    "title": "S-red",
    "option1": "S",
    "option2": "red",
    "option3": "",
    "image": {
      "src": "//cdn.shoplazza.com/efd33b921cacd5311a32dd03a9bc8740.png",
      "width": 1588,
      "height": 2246,
      "path": "efd33b921cacd5311a32dd03a9bc8740.png",
      "alt": ""
    },
    "position": 1,
    "compare_at_price": "100.00",
    "price": "100.00",
    "sku": "S-RED",
    "barcode": "123",
    "note": "s-red",
    "inventory_quantity": 10,
    "weight": "0.10",
    "weight_unit": "kg",
    "cost_price": "11.00",
    "wholesale_price": [
      {
        "price": "100.00",
        "min_quantity": 1
      }
    ],
    "extend": {}
  }
}
```

```json
{
    "variant": {
        "id": "1b735278-62c7-41ad-9976-b1b63a90590d",
        "product_id": "636a07da-39eb-4829-bde9-b65fae1c28b0",
        "image_id": "91d032e7-bbc8-47e4-8668-9ba6fe714de6",
        "created_at": "2024-04-15T02:00:57Z",
        "updated_at": "2024-04-15T02:00:57Z",
        "title": "S-red",
        "option1": "S",
        "option2": "red",
        "option3": "",
        "image": {
            "src": "//cdn.shoplazza.com/efd33b921cacd5311a32dd03a9bc8740.png",
            "width": 1588,
            "height": 2246,
            "path": "efd33b921cacd5311a32dd03a9bc8740.png",
            "alt": ""
        },
        "position": 1,
        "compare_at_price": "100.00",
        "price": "100.00",
        "sku": "S-RED",
        "barcode": "123",
        "note": "s-red",
        "inventory_quantity": 10,
        "weight": "0.10",
        "weight_unit": "kg",
        "cost_price": "11.00",
        "wholesale_price": [
            {
                "price": "100.00",
                "min_quantity": 1
            }
        ],
        "extend": null
    }
}
```

404

**application/json**

**Schema | Example | Result**

**Schema**

- `errors` string[]

```json
{
  "errors": [
    "Product not found"
  ]
}
```

```json
{
  "errors": [
    "Product not found"
  ]
}
```

422

**application/json**

**Schema | Example | Result**

**Schema**

- `errors` string[]

```json
{
  "errors": [
    "Price must be entered."
  ]
}
```

```json
{
  "errors": [
    "Price must be entered."
  ]
}
```
