Run durable workflows
Build workflows with the Workflow SDK that survive restarts, retry steps, sleep for days and wait on hooks, with every run traced in the dashboard.
Workflows lets your functions run long, multi-step work that survives failures: a step that fails is retried, a run can sleep for minutes or days, and it can pause until something outside calls back. Use it for signups, order pipelines, AI agents, or anything that outlasts one request.
Easel implements the same backend as Vercel Workflows, so an app built with the Workflow SDK runs unchanged. There's nothing to set up: no database to bring, and your functions are authenticated automatically. Workflows is in beta.
Write a workflow
Install the SDK and add it to your framework's config (here, Next.js):
A workflow is a function marked "use workflow"; each step it calls is a
function marked "use step":
Start a run from any function:
How runs work
- Steps retry. A step that throws is retried, 3 times by default (set
maxRetrieson the step to change it). ThrowFatalErrorto fail without retrying. - Sleeps cost nothing.
sleep()suspends the run; no function runs while it waits. - Hooks wait for the outside.
createHook()pauses untilresumeHook(token, payload)is called, from a webhook handler for example. A hook's token is unique in your project and environment while it's live.experimental_minRetentionkeeps it claimed after the run ends, andexperimental_forcetakes a token over from the run that holds it. - Duplicate-proof starts.
start(workflow, args, { experimental_hook: { token } })(workflow5.4 or later) starts the run and claims the token in one step: a secondstart()with the same token, an order ID for example, throwsHookConflictErrornaming the run that owns it, and never starts a run. - Streams. A step can write to
getWritable(), andgetRun(runId).getReadable()reads it live from anywhere. - Pinned to the deployment. A run keeps running the code of the deployment that started it, even after you deploy again. See Move runs to new code.
Steps and resumes are delivered by Queues, so a workflow's functions show up in your invocations like any other.
Move runs to new code
A run never switches code partway through, because it replays its history
against the code it started with. To move work onto a newer deployment,
start a new run there with deploymentId: "latest":
"latest" is the latest deployment in the caller's environment:
- Production: the deployment production serves now, so it follows promotions and rollbacks.
- Preview: the newest ready deployment on the same git branch.
The new run starts on code that may differ from the caller's, so keep the
workflow's name, file path, arguments and return value compatible across
the deployments it bridges. To fix runs that are already running, cancel them
and choose Re-run on latest on each, or start them again with
deploymentId: "latest" from your own code.
When a deployment goes offline
A run needs the deployment it started on. If that deployment is spun down,
its runs that are still in progress fail within about a minute with
DEPLOYMENT_MISMATCH, as on Vercel, including runs that are sleeping or
waiting on a hook. Spinning down a deployment with runs in progress asks first
and can start them again on the latest deployment. You can also choose
Re-run on latest on a failed run later.
See your runs
Open Workflows in your project's sidebar. Runs are listed newest first, with counts by status; search by workflow, run ID or hook token, filter by environment and time range, or turn on Live to watch new runs arrive.
Open a run to see its trace: each step, each retry attempt, each sleep and hook on one timeline. Select a span for its details, input, output and events. From a run you can:
- Wake Up Sleep on a sleeping run, to continue it now.
- Resolve Hook on a waiting hook, with a JSON payload, as
resumeHook()would. - Re-run on latest to start it again with the same input on the latest deployment.
- Re-enqueue it if it's stuck, or Cancel it. You can also cancel several from the list.
- See its Events and its output Streams, live while it runs.
- Jump to its function logs with View Logs.
Encryption
Run data (inputs, outputs, errors, hook payloads and streams) is encrypted before it leaves your function, with a key unique to each run, as on Vercel. Your code doesn't change, and Easel only stores the encrypted bytes. In the dashboard, payloads show as Encrypted until you choose Decrypt on a run.
Retention and limits
A run's inputs, outputs, streams and trace are kept while it runs and then for your plan's retention period: 1 day on the Free plan, 7 days on Pro. The run stays listed for 30 days after that, without its data. A run can have up to 25,000 events and 10,000 steps, and each payload can be up to 50 MB.
Pricing
Workflows bill three ways, at Vercel's rates: Workflow Events (each state change of a run or step), Workflow Data Written, and on Pro, Workflow Data Retained. Each plan includes 50,000 events and 1 GB written a month. See Pricing for the rates. The functions that run your steps bill like any other function.