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

# Batch Product Attributes

> Stage attribute additions, removals, and updates on a product.

Stages attribute operations as a pending change request instead of applying them directly.

> [!NOTE]
>
> The endpoint responds with `202 Accepted` and a `product_change` record containing `ATTRIBUTE_ADD` / `ATTRIBUTE_REMOVE` / `ATTRIBUTE_UPDATE` actions.

> [!WARNING]
>
> Adding, updating, or removing an internal attribute returns a `400`. Internal attributes are managed by operators only.

## Path parameters

**id** `string` *required*

The product's ID.

## Body parameters

**add** `object[]`

Attributes to attach; each entry references an existing attribute by `id` or defines one inline by `title`.

**properties**

**id** `string`

Existing attribute ID (referencing form).

**value\_ids** `string[]`

IDs of attribute values to select (referencing form).

**value** `string | number | boolean`

Scalar value for `text`, `unit`, or `toggle` attributes.

**title** `string`

Attribute title (inline form).

**type** `string`

One of `single_select`, `multi_select`, `text`, `toggle`, `unit`. Required for inline non-axis attributes unless `value` is a boolean.

**values** `string[]`

Value names to create and select (inline form).

**is\_variant\_axis** `boolean`

Whether the attribute drives variant combinations; only allowed on `multi_select` attributes.

**is\_filterable** `boolean`

Whether the attribute is filterable (inline form).

**is\_required** `boolean`

Whether the attribute is required (inline form).

**description** `string`

Attribute description (inline form).

**metadata** `object`

Custom key-value pairs (inline form).

**remove** `string[]`

IDs of attributes to detach from the product.

**update** `object[]`

Changes to attributes already attached to the product.

**properties**

**id** `string` *required*

The attribute's ID.

**title** `string`

New attribute title.

**add** `(string | object)[]`

Values to select, plain strings or `{ "value": "..." }` objects.

**remove** `string[]`

Value IDs to deselect.

**value\_ids** `string[]`

The complete set of value IDs the product should hold for this attribute. Resolved into the equivalent `add` / `remove` delta, so it cannot be combined with either.

**value** `string | number | boolean`

New scalar value for `text`, `unit`, or `toggle` attributes.

## Response

**product\_change** `object`

**properties**

**id** `string`

The change request's ID.

**product\_id** `string`

ID of the product the change targets.

**status** `string`

One of `pending`, `confirmed`, `declined`, `canceled`.

**actions** `object[]`

Staged attribute operations, each with `id`, `action`, `details`, `ordering`, and `applied`.

```bash cURL theme={null}
curl -X POST 'http://localhost:9000/vendor/products/prod_01HXYZ/attributes/batch' \
  -H 'Authorization: Bearer <token>' \
  -H 'x-seller-id: <seller_id>' \
  -H 'Content-Type: application/json' \
  -d '{
    "add": [{ "id": "pattr_01HXYZ", "value_ids": ["pattrval_01HXYZ"] }],
    "remove": ["pattr_01HABC"]
  }'
```

```ts JS Client theme={null}
const { product_change } =
  await client.vendor.products.$id.attributes.batch.mutate({
    $id: "prod_01HXYZ",
    add: [{ id: "pattr_01HXYZ", value_ids: ["pattrval_01HXYZ"] }],
    remove: ["pattr_01HABC"],
  })
```

```json 202 theme={null}
{
  "product_change": {
    "id": "prodch_01HXYZ",
    "product_id": "prod_01HXYZ",
    "status": "pending",
    "actions": [
      {
        "id": "prodchact_01HXYZ",
        "action": "ATTRIBUTE_ADD",
        "details": { "id": "pattr_01HXYZ", "value_ids": ["pattrval_01HXYZ"] },
        "applied": false
      }
    ]
  }
}
```


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