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

# addProductAttributesToProductWorkflow

> Attach existing or inline attributes (and their values) to a product.

Handles the `add` portion of the attribute batch engine (`createAndLinkProductAttributesToProductWorkflow`). Existing `text`/`unit` attributes get a new value created from `value`; `toggle` links the seeded `true`/`false` value; existing variant-axis `multi_select` attributes have their mirror `ProductOption` attached to the product with the selected value subset. Inline refs create a product-scoped attribute — axis refs also create an exclusive `ProductOption` — and link the values to the product.

## Usage

```ts theme={null}
import { addProductAttributesToProductWorkflow } from "@mercurjs/core/workflows"

await addProductAttributesToProductWorkflow(container).run({
  input: {
    product_id: "prod_123",
    add: [
      { id: "pattr_material", value: "Cotton" },
      { title: "Size", values: ["S", "M", "L"], is_variant_axis: true },
    ],
  },
})
```

Also accepts an array of `{ product_id, add }` items to process several products in one run.

## Input

<ParamField body="product_id" type="string" required>The product to attach the attributes to.</ParamField>

<ParamField body="add" type="ProductAttributeBatchAdd[]" required>
  Attribute refs to attach.

  <Expandable title="properties">
    <ParamField body="id" type="string">Id of an existing attribute (existing form).</ParamField>
    <ParamField body="value_ids" type="string[]">Attribute value ids to link (select types / axis subset).</ParamField>
    <ParamField body="value" type="string | number | boolean">Scalar for `text` / `unit` / `toggle` attributes.</ParamField>
    <ParamField body="title" type="string">Name of the inline attribute to create (inline form).</ParamField>
    <ParamField body="type" type="AttributeType">One of `single_select`, `multi_select`, `unit`, `toggle`, `text`; inferred when omitted (`is_variant_axis` ⇒ `multi_select`, boolean `value` ⇒ `toggle`, else `text`).</ParamField>
    <ParamField body="values" type="string[]">Value names to create for inline multi-value attributes.</ParamField>
    <ParamField body="is_variant_axis" type="boolean">Create the inline attribute as a variant axis with an exclusive product option.</ParamField>
    <ParamField body="is_filterable" type="boolean">Whether the inline attribute is filterable. Defaults to `false`.</ParamField>
    <ParamField body="is_required" type="boolean">Whether the inline attribute is required. Defaults to `false`.</ParamField>
    <ParamField body="description" type="string | null">Description of the inline attribute.</ParamField>
    <ParamField body="metadata" type="object | null">Custom key-value data on the inline attribute.</ParamField>
  </Expandable>
</ParamField>

<ParamField body="additional_data" type="object">Custom data passed through.</ParamField>

## Result

<ResponseField name="result" type="void">No return value.</ResponseField>
