# List variants

> Retrieve the variants of a product, with channel- and country-aware pricing.

`GET /rest/api/products/{productId}/variants`

Retrieves the collection of Product Variant resources.

Returns the paginated collection of variants belonging to a product. When `resolveContext` is set, each variant's `resolvedPrice` is computed for the given channel, country and timestamp.

> **Resolving prices**
>
> Set `resolveContext[channel]`, `resolveContext[country]` and `resolveContext[at]` together to populate `resolvedPrice` on every returned variant. Omit all three to get the raw variant data.

## Headers

| Name                         | Type     | Required | Description                                                                                                                                      |
| ---------------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `X-Flowkiwi-Organization-Id` | `string` | Yes      | The organization the request acts as. Determines the identity, permissions and ownership applied when reading or modifying data on the instance. |

## Path parameters

| Name        | Type     | Required | Description                |
| ----------- | -------- | -------- | -------------------------- |
| `productId` | `string` | Yes      | ProductResource identifier |

## Query parameters

| Name                         | Type      | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                            |
| ---------------------------- | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `resolveContext[channel]`    | `string`  | -        | Channel IRI used to resolve the variant price. Required together with `resolveContext[country]`.                                                                                                                                                                                                                                                                                                                       |
| `resolveContext[country]`    | `string`  | -        | Country IRI used to resolve the variant price. Required together with `resolveContext[channel]`.                                                                                                                                                                                                                                                                                                                       |
| `resolveContext[at]`         | `string`  | -        | ISO 8601 UTC timestamp at which the price is resolved. Defaults to the current time when omitted.                                                                                                                                                                                                                                                                                                                      |
| `expand`                     | `string`  | -        | Comma-separated list of relations to embed as full objects instead of IRI strings. Supported values: `optionValues`, `medias`, `metafields`, `metaobject`. Tokens are independent; unknown values are silently ignored. `metaobject` only has a visible effect when combined with `metafields` (it embeds the referenced metaobject on each metafield of type `metaobject_reference` or `list__metaobject_reference`). |
| `page`                       | `integer` | -        | The collection page number                                                                                                                                                                                                                                                                                                                                                                                             |
| `itemsPerPage`               | `integer` | -        | The number of items per page                                                                                                                                                                                                                                                                                                                                                                                           |
| `order[createdAt]`           | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `order[updatedAt]`           | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `createdAt[before]`          | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `createdAt[strictly_before]` | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `createdAt[after]`           | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `createdAt[strictly_after]`  | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `updatedAt[before]`          | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `updatedAt[strictly_before]` | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `updatedAt[after]`           | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `updatedAt[strictly_after]`  | `string`  | -        |                                                                                                                                                                                                                                                                                                                                                                                                                        |

## Response

**200** - Product Variant collection

| Property           | Type                | Required | Description |
| ------------------ | ------------------- | -------- | ----------- |
| `hydra:totalItems` | `integer`           | -        |             |
| `hydra:search`     | `object`            | -        |             |
| `hydra:view`       | `object`            | -        |             |
| `hydra:member`     | `Product.Variant[]` | Yes      |             |

## Errors

**403** - Access denied. The caller is missing one or more identity permissions required for this operation.

| Property             | Type       | Required | Description                                                                                                                                |
| -------------------- | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `@context`           | `object`   | -        |                                                                                                                                            |
| `@id`                | `string`   | Yes      |                                                                                                                                            |
| `@type`              | `string`   | Yes      |                                                                                                                                            |
| `type`               | `string`   | -        |                                                                                                                                            |
| `title`              | `string`   | -        |                                                                                                                                            |
| `status`             | `integer`  | -        |                                                                                                                                            |
| `detail`             | `string`   | -        |                                                                                                                                            |
| `missingPermissions` | `string[]` | -        | Identity permissions that the caller is missing for this operation. Present only when the 403 is caused by a denied identity:* permission. |

## Examples

### Example request

```bash
curl -X GET 'https://<tenant>.product-management.flowkiwi.net/rest/api/products/<product_id>/variants' \
  -H 'Authorization: Bearer {token}' \
  -H 'X-Flowkiwi-Organization-Id: <org_id>' \
  -H 'Accept: application/ld+json'
```

### Example response

```json
{
  "hydra:member": [
    {
      "@context": "/rest/api/contexts/Variant",
      "@id": "/rest/api/Variants/92c6e322-8858-5958-8eec-49e531a86128",
      "@type": "Variant",
      "id": "92c6e322-8858-5958-8eec-49e531a86128",
      "barcode": "BAR-001-A",
      "sku": "SKU-ABC-001",
      "measurement": {
        "measuredType": "volume",
        "quantityUnit": "cl",
        "quantityValue": 70,
        "referenceUnit": "l",
        "referenceValue": 1
      },
      "product": "/rest/api/products/6e404275-f609-5bba-b51f-e9f085283b1b",
      "optionValues": [
        "/rest/api/optionValues/79134ae6-0f2c-5cd2-86cc-336572469a75",
        "/rest/api/optionValues/67bb40b5-3973-5394-b1e3-a422186d0333"
      ],
      "images": [],
      "createdAt": "2024-01-01T00:00:00+00:00",
      "updatedAt": "2024-01-01T00:00:00+00:00"
    }
  ],
  "hydra:totalItems": 1
}
```
