# @medusajs/workflows-sdk

> Set of workflows tooling for Medusa

Latest version **2.22.7** (published 2026-11-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @medusajs/workflows-sdk
pnpm add @medusajs/workflows-sdk
yarn add @medusajs/workflows-sdk
bun add @medusajs/workflows-sdk
```

## Health

**Score 80/100 (A)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.22.7 |
| Published | 2026-11-13 |
| First published | 2023-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.22.0 |
| Dependencies | 5 |
| Unpacked size | 177.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 36474 |
| Author | Medusa |
| Maintainers | sebrindom, nicolas-gorga, sradevski, olijuhl, shahednasser |

## Links

- npm: https://www.npmjs.com/package/@medusajs/workflows-sdk
- Repository: https://github.com/medusajs/medusa
- Homepage: https://github.com/medusajs/medusa#readme
- Issues: https://github.com/medusajs/medusa/issues
- npm.io page: https://npm.io/package/@medusajs/workflows-sdk

## Dependencies (5)

- [ulid](https://npm.io/package/ulid.md) ^3.0.2
- [@medusajs/deps](https://npm.io/package/@medusajs/deps.md) 2.22.7
- [@medusajs/utils](https://npm.io/package/@medusajs/utils.md) 2.22.7
- [@medusajs/modules-sdk](https://npm.io/package/@medusajs/modules-sdk.md) 2.22.7
- [@medusajs/orchestration](https://npm.io/package/@medusajs/orchestration.md) 2.22.7

## Recent versions

- 2.22.7 (latest) — 2026-11-13
- 2.22.8-preview-20261117142131 (preview) — 2026-11-17
- 2.22.7-snapshot-20261113105900 (snapshot) — 2026-11-13
- 2.16.0-options-preview-20260605124754 (options-preview) — 2026-06-05
- 2.0.0-rc-20241022183311 (rc) — 2024-10-22
- 0.1.7-next-20240505114610 (next) — 2024-05-05
- 2.22.7-preview-20261113113415 — 2026-11-13
- 2.22.7-preview-20261113102906 — 2026-11-13
- 2.22.7-snapshot-20261113095001 — 2026-11-13
- 2.22.7-preview-20261113085903 — 2026-11-13
- 2.22.7-preview-20261113084204 — 2026-11-13
- 2.22.7-snapshot-20261112111749 — 2026-11-12
- 2.22.7-snapshot-20261111153147 — 2026-11-11
- 2.22.6 — 2026-11-09
- 2.22.5 — 2026-11-09
- … 241 more at https://npm.io/package/@medusajs/workflows-sdk/versions

## README

<p align="center">
  <a href="https://www.medusajs.com">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/59018053/229103275-b5e482bb-4601-46e6-8142-244f531cebdb.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/59018053/229103726-e5b529a3-9b3f-4970-8a1f-c6af37f087bf.svg">
    <img alt="Medusa logo" src="https://user-images.githubusercontent.com/59018053/229103726-e5b529a3-9b3f-4970-8a1f-c6af37f087bf.svg">
    </picture>
  </a>
</p>
<h1 align="center">
  @medusajs/workflows-sdk
</h1>

<h4 align="center">
  <a href="https://docs.medusajs.com">Documentation</a> |
  <a href="https://www.medusajs.com">Website</a>
</h4>

<p align="center">
  Building blocks for digital commerce
</p>
<p align="center">
  <a href="https://github.com/medusajs/medusa/blob/develop/LICENSE">
    <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Medusa is released under the MIT license." />
  </a>
  <a href="https://github.com/medusajs/medusa/blob/develop/CONTRIBUTING.md">
    <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="PRs welcome!" />
  </a>
  <a href="https://discord.gg/xpCwq3Kfn8">
    <img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Discord Chat" />
  </a>
  <a href="https://twitter.com/intent/follow?screen_name=medusajs">
    <img src="https://img.shields.io/twitter/follow/medusajs.svg?label=Follow%20@medusajs" alt="Follow @medusajs" />
  </a>
</p>

Workflows SDK for Medusa: the tools to define durable, multi-step workflows with steps, compensation (rollback), hooks, and conditions. Use it to build custom commerce flows in a Medusa application, module, or plugin. Applications import it through `@medusajs/framework/workflows-sdk`, which re-exports this package; importing `@medusajs/workflows-sdk` directly is discouraged.

## At a glance

| | |
| --- | --- |
| Package | `@medusajs/workflows-sdk` |
| Type | Core library |
| Import from | `@medusajs/framework/workflows-sdk` |
| Entry points | `.`, `./composer` (available as `@medusajs/framework/workflows-sdk/composer`) |

## Features

- `createStep` and `StepResponse` to define steps with an optional compensation function.
- `createWorkflow` and `WorkflowResponse` to compose steps into a workflow.
- `transform`, `when`, and `parallelize` to manipulate data, run steps conditionally, and run steps in parallel inside a workflow.
- `createHook` to expose hooks that other code can consume to extend a workflow.

## Installation

No separate installation is needed in a Medusa application. It's installed with `@medusajs/framework`.

## Usage

```ts
import {
  createStep,
  createWorkflow,
  StepResponse,
  WorkflowResponse,
} from "@medusajs/framework/workflows-sdk"

type WorkflowInput = {
  name: string
}

const greetStep = createStep(
  "greet-step",
  async ({ name }: WorkflowInput) => {
    return new StepResponse(`Hello ${name}!`)
  }
)

const helloWorldWorkflow = createWorkflow(
  "hello-world",
  function (input: WorkflowInput) {
    const message = greetStep(input)

    return new WorkflowResponse({ message })
  }
)

export default helloWorldWorkflow
```

Execute the workflow by passing it the Medusa container, for example in an API route:

```ts
const { result } = await helloWorldWorkflow(req.scope).run({
  input: { name: "John" },
})
```

## Resources

- [Workflows](https://docs.medusajs.com/learn/fundamentals/workflows)
- [Compensation function](https://docs.medusajs.com/learn/fundamentals/workflows/compensation-function)
- [Workflow hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks)
- [Long-running workflows](https://docs.medusajs.com/learn/fundamentals/workflows/long-running-workflow)

---
_Source: https://npm.io/package/@medusajs/workflows-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
