**Version: 202201**

# Update Variant

**PUT** `/openapi/2022-01/variants/:variant_id`

Update an existing product variant with the provided details.

## Request

**Path Parameters**

- `variant_id` string (required)

  Variant'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 third style value of the variant
  - `image` object

    Variant image, mandatory if need_variant_image is true

    - `src` string (required)

      Image's URL
    - `width` int32

      Image's width in px
    - `height` int32

      Image's height in px
    - `alt` string

      Image's alt
  - `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
  - `sku` string

    SKU
  - `barcode` string

    The barcode of the variant.
  - `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": {
      "src": "string",
      "width": 0,
      "height": 0,
      "alt": "string"
    },
    "image_id": "string",
    "compare_at_price": "string",
    "price": "string",
    "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 | 422**

200

**application/json**

**Schema | Example | Result**

**Schema**

- `variant` object

  - `id` string

    **Example:** `88e68830-4ef5-4125-bf7d-aef8047176b2`
  - `product_id` string

    **Example:** `a1a88be0-a1d4-47e4-a2f2-ba6e131cf447`
  - `image_id` string

    **Example:** `8ef098c5-5a08-44b4-b5fb-89214bb507dc`
  - `created_at` string

    **Example:** `2024-04-17T02:15:18Z`
  - `updated_at` string

    **Example:** `2024-04-17T02:15:18Z`
  - `title` string

    **Example:** `S-blue-T`
  - `option1` string

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

    **Example:** `blue`
  - `option3` string

    **Example:** `T`
  - `image` object

    - `src` string

      **Example:** `//cdn.shoplazza.com/ccf0794c594bad32a320eea0d6bfe40c.jpeg`
    - `width` integer

      **Default value:** `0`

      **Example:** `174`
    - `height` integer

      **Default value:** `0`

      **Example:** `180`
    - `path` string

      **Example:** `ccf0794c594bad32a320eea0d6bfe40c.jpeg`
    - `alt` string

      **Example:**
  - `position` integer

    **Default value:** `0`

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

    **Example:** `12.10`
  - `price` string

    **Example:** `10.10`
  - `sku` string

    **Example:** `T-M-S-blue-T-A001004`
  - `barcode` string

    **Example:** `6929000212340`
  - `note` string

    **Example:** `node`
  - `inventory_quantity` integer

    **Default value:** `0`

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

    **Example:** `1.10`
  - `weight_unit` string

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

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

    *   Array [

    - `price` string

      **Example:** `10.10`
    - `min_quantity` integer

      **Default value:** `0`

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

    - `length` integer

      **Default value:** `0`

      **Example:** `10`
    - `width` integer

      **Default value:** `0`

      **Example:** `10`
    - `height` integer

      **Default value:** `0`

      **Example:** `10`
    - `dimension_unit` string

      **Example:** `in`
    - `origin_country_code` string

      **Example:** `AG`
    - `hs_code` string

      **Example:** `62114390`

```json
{
  "variant": {
    "id": "88e68830-4ef5-4125-bf7d-aef8047176b2",
    "product_id": "a1a88be0-a1d4-47e4-a2f2-ba6e131cf447",
    "image_id": "8ef098c5-5a08-44b4-b5fb-89214bb507dc",
    "created_at": "2024-04-17T02:15:18Z",
    "updated_at": "2024-04-17T02:15:18Z",
    "title": "S-blue-T",
    "option1": "S",
    "option2": "blue",
    "option3": "T",
    "image": {
      "src": "//cdn.shoplazza.com/ccf0794c594bad32a320eea0d6bfe40c.jpeg",
      "width": 174,
      "height": 180,
      "path": "ccf0794c594bad32a320eea0d6bfe40c.jpeg",
      "alt": ""
    },
    "position": 1,
    "compare_at_price": "12.10",
    "price": "10.10",
    "sku": "T-M-S-blue-T-A001004",
    "barcode": "6929000212340",
    "note": "node",
    "inventory_quantity": 10,
    "weight": "1.10",
    "weight_unit": "kg",
    "cost_price": "1.10",
    "wholesale_price": [
      {
        "price": "10.10",
        "min_quantity": 1
      }
    ],
    "extend": {
      "length": 10,
      "width": 10,
      "height": 10,
      "dimension_unit": "in",
      "origin_country_code": "AG",
      "hs_code": "62114390"
    }
  }
}
```

```json
{
  "variant":
    {
      "id": "88e68830-4ef5-4125-bf7d-aef8047176b2",
      "product_id": "a1a88be0-a1d4-47e4-a2f2-ba6e131cf447",
      "image_id": "8ef098c5-5a08-44b4-b5fb-89214bb507dc",
      "created_at": "2024-04-17T02:15:18Z",
      "updated_at": "2024-04-17T02:15:18Z",
      "title": "S-blue-T",
      "option1": "S",
      "option2": "blue",
      "option3": "T",
      "image": {
        "src": "//cdn.shoplazza.com/ccf0794c594bad32a320eea0d6bfe40c.jpeg",
        "width": 174,
        "height": 180,
        "path": "ccf0794c594bad32a320eea0d6bfe40c.jpeg",
        "alt": ""
      },
      "position": 1,
      "compare_at_price": "12.10",
      "price": "10.10",
      "sku": "T-M-S-blue-T-A001004",
      "barcode": "6929000212340",
      "note": "node",
      "inventory_quantity": 10,
      "weight": "1.10",
      "weight_unit": "kg",
      "cost_price": "1.10",
      "wholesale_price": [
        {
          "price": "10.10",
          "min_quantity": 1
        }
      ],
      "extend": {
        "length": 10,
        "width": 10,
        "height": 10,
        "dimension_unit": "in",
        "origin_country_code": "AG",
        "hs_code": "62114390"
      }
    }
}
```

422

**application/json**

**Schema | Example | Result**

**Schema**

- `errors` string[]

```json
{
  "errors": [
    "No variants found"
  ]
}
```

```json
{
  "errors": [
    "No variants found"
  ]
}
```
