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

# Upsert Attribute Values

> Create or update values on a product attribute.

Upserts the given values on the attribute. Items with an `id` update an existing value, items without one create a new value.

## Path parameters

**id** `string` *required*

The attribute's ID.

## Body parameters

**values** `object[]` *required*

Values to create or update, one of two shapes per item.

**update existing value (by id)**

**id** `string` *required*

The value's ID.

**name** `string`

Value name.

**handle** `string`

Unique URL-safe handle.

**rank** `number`

Sort rank; must be non-negative.

**is\_active** `boolean`

Whether the value is active.

**metadata** `object`

Custom key-value data.

**create new value (by name)**

**name** `string` *required*

Value name.

**handle** `string`

Unique URL-safe handle.

**rank** `number`

Sort rank; must be non-negative.

**is\_active** `boolean`

Whether the value is active.

**metadata** `object`

Custom key-value data.

## Response

**product\_attribute** `object`

**properties**

**id** `string`

The attribute's ID.

**name** `string`

Attribute name.

**type** `string`

The attribute's type.

**values** `object[]`

All values after the upsert, with `id`, `name`, `handle`, `rank`, and `is_active`.

**updated\_at** `string`

Last update timestamp.

```bash cURL theme={null}
curl -X POST 'http://localhost:9000/admin/product-attributes/pattr_01HXYZABCDEF/values' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"values": [{ "name": "Wool" }, { "id": "pattrval_01HXYZABCDEF", "rank": 1 }]}'
```

```ts JS Client theme={null}
const { product_attribute } = await client.admin.productAttributes.$id.values.mutate({
  $id: "pattr_01HXYZABCDEF",
  values: [{ name: "Wool" }, { id: "pattrval_01HXYZABCDEF", rank: 1 }],
})
```

```json 200 theme={null}
{
  "product_attribute": {
    "id": "pattr_01HXYZABCDEF",
    "name": "Material",
    "type": "single_select",
    "values": [
      { "id": "pattrval_01HXYZABCDEG", "name": "Wool", "rank": 0 },
      { "id": "pattrval_01HXYZABCDEF", "name": "Linen", "rank": 1 }
    ]
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.