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

# stageProductChangeWorkflow

> Stage a pending ProductChange with its actions and optionally auto-confirm it.

Creates a `pending` `ProductChange` for one product, attaches the given actions to it, then runs `autoConfirmProductChangeWorkflow` — so the change is applied immediately when `auto_confirm` is `true` or the `product_request` feature flag is disabled. This is the engine behind the vendor product-edit workflows (`productEditUpdateProduct`, `productEditUpdateVariants`, `productEditUpdateAttributes`, `productEditDeleteProduct`). Emits `product-change.created`.

## Usage

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

const { result } = await stageProductChangeWorkflow(container).run({
  input: {
    product_id: "prod_01H...",
    created_by: "sel_01H...",
    actions: [
      {
        product_id: "prod_01H...",
        action: "UPDATE",
        details: { title: "Linen Shirt v2" },
      },
    ],
  },
})
```

## Input

<ParamField body="product_id" type="string" required>
  Id of the product the change targets.
</ParamField>

<ParamField body="actions" type="object[]" required>
  Actions to stage on the change (`CreateProductChangeActionDTO` without `product_change_id`, which is stamped automatically).

  <Expandable title="properties">
    <ParamField body="product_id" type="string" required>
      Id of the product the action applies to.
    </ParamField>

    <ParamField body="action" type="string" required>
      Action type, e.g. `UPDATE`, `VARIANT_ADD`, `VARIANT_UPDATE`, `VARIANT_REMOVE`, `ATTRIBUTE_ADD`, `ATTRIBUTE_UPDATE`, `ATTRIBUTE_REMOVE`, `PRODUCT_DELETE`, `STATUS_CHANGE`.
    </ParamField>

    <ParamField body="details" type="object">
      Operation payload applied when the change is confirmed.
    </ParamField>

    <ParamField body="internal_note" type="string">
      Operator-only note on the action.
    </ParamField>

    <ParamField body="applied" type="boolean">
      Whether the action is already applied; leave unset for staged edits.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="created_by" type="string">
  Actor id who staged the change; also used as `confirmed_by` on auto-confirm.
</ParamField>

<ParamField body="internal_note" type="string">
  Operator-only note stored on the change.
</ParamField>

<ParamField body="external_note" type="string">
  Vendor-facing note stored on the change.
</ParamField>

<ParamField body="auto_confirm" type="boolean">
  Force immediate confirmation even when the `product_request` feature flag is enabled.
</ParamField>

## Result

<ResponseField name="result" type="ProductChangeDTO">
  The created change record; still `pending` unless it was auto-confirmed.
</ResponseField>
