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

# createOrderFulfillmentWorkflow

> Create a fulfillment for order items, offer-bundle aware.

Mercur's offer-aware replacement for Medusa's create-order-fulfillment flow. Validates the order and items, creates the fulfillment, registers it on the order, links it, and consumes reservations / adjusts inventory — multiplying quantities by each offer's `required_quantity` inventory links so bundle offers deduct the right stock. Triggered by `POST /vendor/orders/:id/fulfillments`. Emits `order.fulfillment_created`.

## Usage

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

const { result } = await createOrderFulfillmentWorkflow(container).run({
  input: {
    order_id: "order_123",
    items: [{ id: "ordli_123", quantity: 1 }],
  },
})
```

## Input

<ParamField body="order_id" type="string" required>The order to fulfill.</ParamField>
<ParamField body="items" type="{ id: string; quantity: number }[]" required>Order line items and quantities to fulfill; all items must either require shipping or not — mixed requests throw.</ParamField>
<ParamField body="location_id" type="string">Stock location to fulfill from; defaults to the shipping option's linked location.</ParamField>
<ParamField body="shipping_option_id" type="string">Shipping option to fulfill with; defaults to the order's first shipping method.</ParamField>
<ParamField body="created_by" type="string">Id of the user creating the fulfillment.</ParamField>
<ParamField body="labels" type="FulfillmentLabelDTO[]">Tracking labels to attach.</ParamField>
<ParamField body="no_notification" type="boolean">Suppress customer notification for this fulfillment.</ParamField>
<ParamField body="metadata" type="object | null">Custom key-value data on the fulfillment.</ParamField>
<ParamField body="additional_data" type="object">Custom data passed through to the hooks.</ParamField>

## Result

<ResponseField name="result" type="FulfillmentDTO">The created fulfillment.</ResponseField>

## Hooks

* `fulfillmentCreated` — runs after creation with `{ fulfillment, additional_data }`.

```ts theme={null}
createOrderFulfillmentWorkflow.hooks.fulfillmentCreated(async ({ fulfillment }) => {
  // push to a 3PL
})
```
