Why Upstash Workflow
Durable execution that runs inside the app you already deploy.
Durable steps
Each step's result is saved once it completes. If a step fails or the function crashes, the run resumes from the last finished step.
No function timeouts
Every step runs in its own invocation, so a workflow can run for hours or days on platforms with short time limits.
Sleep for days
Pause a run for minutes or days with context.sleep, up to a year on pay as you go. Nothing runs while it waits, and the whole sleep counts as one step.
Wait for events
Stop at a step until a user approves, a webhook arrives, or another service sends a notify, then continue.
Per-step retries
Failed steps retry on their own. Runs that still fail go to a dead letter queue where you can restart or resume them.
Parallel steps
Run steps side by side with Promise.all and wait for them together, each one durable and retried.
Flow control
Limit how many steps run at once and how fast, to protect databases and third-party API quotas.
Just your code
Workflows are plain TypeScript or Python in your existing API routes. No separate worker or orchestration server to deploy.
Write workflows as code
Wrap your logic in steps with the @upstash/workflow SDK and serve it from any API route.
// Step 1: Get the dataset URL
const datasetUrl = await context.run("get-dataset-url", async () => {
return await getDatasetUrl(datasetId)
});
// Step 2: Download the dataset
const { body: dataset } = await context.call("download-dataset", {
url: datasetUrl,
method: "GET"
});
// Step 3: Analyze the dataset with LLM
const response = await context.api.openai.call(
"call-openai",
{
token: "OPENAI_API_KEY",
operation: "chat.completions.create",
body: {
model: "gpt-5.4",
messages: [
{ role: "user", content: `Analyze this data chunk: ${JSON.stringify(dataset)}` },
],
},
}
);What can you build with Workflow?
Common durable execution use cases, with a guide to build each one.
AI agents
Run agents whose LLM and tool calls are durable steps, so a slow model or a failed tool never restarts the whole run.
Human-in-the-loop approvals
Pause a run until a person approves or rejects it, then continue with their answer.
Event-driven flows
Wait for a payment, signup, or external system to send an event before moving to the next step.
Webhook processing
Create a webhook URL inside a run and wait for the third-party callback to arrive.
Scheduled workflows
Trigger multi-step jobs on a CRON schedule, like weekly digests and nightly data pipelines.
Rate-limited batch jobs
Process thousands of items without overwhelming downstream APIs by capping rate and parallelism.
What is durable execution?
Code that finishes what it started, even when the machine running it does not.
Durable execution means a function's progress is saved as it runs. The work is split into steps, and each step's result is recorded once it completes. If the process crashes or times out halfway through, it resumes from the last completed step instead of starting over or leaving work half done.
Serverless functions are the opposite by default. They have short time limits, keep no state between invocations, and a failure in the middle of a multi-step job usually means retrying everything or cleaning up by hand. Teams end up building their own queues, state tables, and retry logic around them.
Upstash Workflow provides that layer on top of QStash. Your workflow is an ordinary endpoint in your app. Workflow calls it once per step, passes in the results of earlier steps, and retries any step that fails. Sleeps and waits use no compute while they last, because nothing is running.
Frequently asked questions
Ship your first workflow today
Start on the free tier with 1,000 steps a day. No credit card required.