# Retrieve a variant

> Retrieve a single variant by its identifier.

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

Retrieves a Product Variant resource.

Returns a single variant of a product by id. Pass `resolveContext[*]` to populate `resolvedPrice` for the chosen channel, country and timestamp.

## 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 |
| `variantId` | `string` | Yes      | Product Variant 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`). |

## Response

**200** - Product Variant resource

| Property        | Type                                  | Required | Description                                                                                                                                                                                     |
| --------------- | ------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `@context`      | `object`                              | -        |                                                                                                                                                                                                 |
| `@id`           | `string`                              | Yes      |                                                                                                                                                                                                 |
| `@type`         | `string`                              | Yes      |                                                                                                                                                                                                 |
| `id`            | `string`                              | -        | The resource's unique identifier (UUID).                                                                                                                                                        |
| `barcode`       | `string`                              | Yes      | The barcode, unique UPC, or ISBN number for the product.                                                                                                                                        |
| `sku`           | `string`                              | Yes      | A unique identifier for the product variant.                                                                                                                                                    |
| `measurement`   | `EmbeddedMeasurementResource \| null` | -        | The measurement used to compute per-unit prices for the variant.                                                                                                                                |
| `product`       | `string`                              | Yes      | The product resource it belongs to.                                                                                                                                                             |
| `optionValues`  | `string[]`                            | -        | A list of `Option Value`, each one representing an option value associated with the variant.                                                                                                    |
| `medias`        | `string[]`                            | -        | A list of `Media`, ordered by position. Only media of type "image" can be associated with a variant. Returned as IRI strings by default; pass `?expand=medias` to embed full `Media` objects.   |
| `resolvedPrice` | `ResolvedPriceResource \| null`       | -        | The price resolved for the current `resolveContext` (country, channel and instant). Null unless `resolveContext[country]`, `resolveContext[channel]` and `resolveContext[at]` are all provided. |
| `metafields`    | `string[]`                            | -        | Metafields owned by this variant. Serialized as IRI strings by default; pass `?expand=metafields` to embed full `MetafieldResource` objects.                                                    |
| `createdAt`     | `string`                              | -        | The date and time when the resource was created (ISO 8601 format).                                                                                                                              |
| `updatedAt`     | `string`                              | -        | The date and time when the resource was last modified (ISO 8601 format).                                                                                                                        |

## 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. |

**404** - Not found

| Property   | Type             | Required | Description                                                                                                                          |
| ---------- | ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `@context` | `object`         | -        |                                                                                                                                      |
| `@id`      | `string`         | Yes      |                                                                                                                                      |
| `@type`    | `string`         | Yes      |                                                                                                                                      |
| `title`    | `string \| null` | -        | A short, human-readable summary of the problem.                                                                                      |
| `detail`   | `string \| null` | -        | A human-readable explanation specific to this occurrence of the problem.                                                             |
| `status`   | `number \| null` | -        |                                                                                                                                      |
| `instance` | `string \| null` | -        | A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. |
| `type`     | `string`         | -        | A URI reference that identifies the problem type                                                                                     |

## Examples

### Example request

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

### Example response

```json
{
  "@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"
}
```
