---
title: workflow
description: Core workflow primitives for steps, streaming, webhooks, and error handling.
docs_index: /llms.txt
lastUpdated: 2026-10-13
type: overview
summary: Explore the core workflow package for steps, streaming, hooks, and error handling.
related:
  - /docs/foundations/workflows-and-steps
  - /docs/foundations/hooks
  - /docs/foundations/streaming
  - /docs/foundations/errors-and-retries
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

Core workflow primitives including steps, context management, streaming, webhooks, and error handling.

## Installation

```bash
npm i workflow
```

```bash
pnpm add workflow
```

```bash
yarn add workflow
```

```bash
bun add workflow
```

## Functions

Workflow SDK contains the following functions you can use inside your workflow functions:

#### [getWorkflowMetadata()](/docs/api-reference/workflow/get-workflow-metadata)

A function that returns context about the current workflow execution.

#### [getStepMetadata()](/docs/api-reference/workflow/get-step-metadata)

A function that returns context about the current step execution.

#### [sleep()](/docs/api-reference/workflow/sleep)

Sleeping workflows for a specified duration. Deterministic and replay-safe.

#### [fetch()](/docs/api-reference/workflow/fetch)

Make HTTP requests from within a workflow with automatic retry semantics.

#### [createHook()](/docs/api-reference/workflow/create-hook)

Create a low-level hook to receive arbitrary payloads from external systems.

#### [defineHook()](/docs/api-reference/workflow/define-hook)

Type-safe hook helper for consistent payload types.

#### [createWebhook()](/docs/api-reference/workflow/create-webhook)

Create a webhook that suspends the workflow until an HTTP request is received.

#### [getWritable()](/docs/api-reference/workflow/get-writable)

Access the current workflow run's default stream.

#### [setAttributes()](/docs/api-reference/workflow/set-attributes)

Attach string metadata to the current workflow run.

## Error classes

Workflow SDK includes error classes that can be thrown in a workflow or step to change the error exit strategy of a workflow.

#### [FatalError()](/docs/api-reference/workflow/fatal-error)

When thrown, marks a step as failed and the step is not retried.

#### [RetryableError()](/docs/api-reference/workflow/retryable-error)

When thrown, marks a step as retryable with an optional parameter.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)