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

# Get Product Variants

> Retrieve the full variant tree for a product.

# Get Product Variants

Returns the complete variation → sub-variation → sub-variant tree for a product, as written by [Create/Replace Product Variants](/api-reference/marketplace/create-variants).

## Path Parameters

<ParamField path="productId" type="integer" required>
  A product you own, or a product owned by an active sub-merchant in your marketplace.
</ParamField>

## Response

<Note>
  If the product has no variants configured yet, this returns `200` with `data: null` — it is **not** a `404`. Treat `data === null` as "no variants," not as an error.
</Note>

```json theme={null}
{
  "success": true,
  "message": "Variants retrieved successfully",
  "data": {
    "id": "b6b6c2b0-...-uuid",
    "product_id": 501,
    "variation_type": "size",
    "variation_custom_label": "Size",
    "has_sub_variants": true,
    "total_quantity": 40,
    "variations": [
      {
        "id": "v-11111111-1111-1111-1111-111111111111",
        "sku": "SHIRT-M",
        "variant_label": "Medium",
        "variant_object": "{\"size\":\"M\"}",
        "variation_quantity": 20,
        "variation_add_price": 0,
        "variation_cost_price": 0,
        "order_index": 0,
        "sub_variation": {
          "id": "sv-...-uuid",
          "sub_variation_type": "color",
          "sub_variation_custom_label": "Color",
          "sub_variation_total_quantity": 20,
          "sub_variants": [
            {
              "id": "svt-...-uuid",
              "sku": "SHIRT-M-RED",
              "variant_label": "Red",
              "variant_quantity": 20,
              "subvariant_add_price": 0,
              "subvariant_cost_price": 0
            }
          ]
        }
      }
    ]
  }
}
```

`variations` is ordered by `order_index` ascending; `sub_variants` is ordered by creation time. `createdAt`/`updatedAt` timestamps are stripped at every level of this response.

## Error Codes

| Status | Error Code          | Cause                                                                           |
| ------ | ------------------- | ------------------------------------------------------------------------------- |
| `404`  | `PRODUCT_NOT_FOUND` | Product doesn't exist, or you don't own it and aren't its marketplace operator. |

<RequestExample>
  ```bash cURL theme={null}
  curl https://api.khaime.com/api/v1/partner/marketplace/products/501/variants \
    -H "X-API-Key: pk_sandbox_your_key"
  ```
</RequestExample>
