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

# How to Extend a Workflow

> Inject custom logic into an existing Mercur workflow through hooks, without rewriting it.

> [!NOTE]
>
> This guide is being written. The outline below is the intended structure.

> [!NOTE]
>
> **Workflows are Medusa's extension model, and Mercur keeps it.** Unlike the panels (where Mercur ships [its own customization framework](https://docs.mercurjs.com/rc/resources/customization/extending-panels.md)), backend logic follows Medusa conventions unchanged: Mercur's workflows expose hooks you inject steps into, with the same compensation/rollback semantics as any Medusa workflow. Skills learned in plain Medusa transfer here one-to-one.

You extend a Mercur workflow by injecting your own step into a hook it exposes, so your logic runs inside the existing flow instead of a fork of it.

## Why hooks

Hooks let you add behavior without forking or rewriting the workflow.

**1. Pick the target hook**

The `completeCartWithSplitOrdersWorkflow` and where its hooks sit.

**2. Inject a step**

The shape of a hook and how to register your step.

**3. Handle compensation and rollback**

How your step participates in automatic rollback on failure.

## Verify

Confirm the injected behavior runs and rolls back correctly.

## Next steps

> [card] [Add a custom API route](https://docs.mercurjs.com/rc/resources/tutorials/custom-api-route.md)

> [card] [Custom fields](https://docs.mercurjs.com/rc/resources/customization/custom-fields)


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