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

# upsertProductAttributeValuesWorkflow

> Create or update attribute values in one call, keyed by id presence.

Splits the given values by `id`: entries without an id are created on the attribute, entries with an id are updated in place. Unlike the create/update value workflows it does not touch the mirror `ProductOption` (renaming a value in place does not re-sync the mirrored option) and it emits no events.

## Usage

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

const { result } = await upsertProductAttributeValuesWorkflow(container).run({
  input: {
    attribute_id: "pattr_color",
    values: [
      { name: "Teal" },
      { id: "pattrval_123", name: "Navy Blue" },
    ],
  },
})
```

## Input

<ParamField body="attribute_id" type="string" required>The attribute the values belong to.</ParamField>

<ParamField body="values" type="UpsertProductAttributeValueDTO[]" required>
  Values to create (no `id`) or update (with `id`).

  <Expandable title="properties">
    <ParamField body="id" type="string">Existing value id; omit to create a new value.</ParamField>
    <ParamField body="name" type="string">Display name of the value.</ParamField>
    <ParamField body="handle" type="string">URL-safe handle.</ParamField>
    <ParamField body="rank" type="number">Sort rank.</ParamField>
    <ParamField body="is_active" type="boolean">Whether the value is active.</ParamField>
    <ParamField body="product_option_value_id" type="string | null">Bound mirror option value.</ParamField>
    <ParamField body="metadata" type="object | null">Custom key-value data.</ParamField>
  </Expandable>
</ParamField>

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

## Result

<ResponseField name="result" type="ProductAttributeValueDTO[]">The created values followed by the updated values.</ResponseField>
