Vercel
Workflow DevKit LogoWorkflow
  • Docs
  • Examples
GitHub

Getting Started
Next.jsNitro
Foundations
Workflows and StepsControl Flow PatternsErrors & RetryingHooks & WebhooksSerialization
Observability
Deploying
Errors
API Reference
workflow
createHookcreateWebhookdefineHookfetchgetStepMetadatagetWorkflowMetadatagetWritablesleepFatalErrorRetryableError
workflow/api
workflow/next
@workflow/ai
API Referenceworkflow

workflow

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


Installation

npm i workflow

pnpm i workflow

yarn add workflow


Functions

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

getWorkflowMetadata()

A function that returns context about the current workflow execution.

getStepMetadata()

A function that returns context about the current step execution.

sleep()

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

fetch()

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

createHook()

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

defineHook()

Type-safe hook helper for consistent payload types.

createWebhook()

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

getWritable()

Access the current workflow run's default stream.


Error Classes

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

FatalError()

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

RetryableError()

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

PreviousAPI Reference
NextcreateHook

On this page

workflowInstallationFunctionsError Classes