# Durable beside Upstash Workflow

The shape: a queue-driven workflow. [Why Durable](https://durablesdk.com/why/vs/upstash-workflow) steps this walk
beat by beat; this page is the walk in prose, with the page each beat
reads under Sources, and [Compared](https://durablesdk.com/docs/compare.md) is the table of every
product.

## What Upstash Workflow gives, as its documentation describes

**Each step is its own HTTP call.** Each step runs as its own HTTP call to your endpoint. A finished step's result is stored on the vendor's side and restored on the next call, so a finished step is skipped. A failed step is retried under your retry setting, the finished steps left alone. [1][2]

**A step's work can run twice.** Your endpoint runs many times per run, and only the code inside a step is meant to run once. A step can be retried all the same, and the docs ask that a step run twice have the same effect as run once. [3]

**Retries with backoff, then a dead letter queue.** A failed step retries a few times with exponential backoff. When the retries are spent the run moves to a dead letter queue. There a person restarts it from the beginning with every step's result cleared, resumes it from the failed step with the successful steps' results kept, or re-runs the failure callback. [4]

**A failure function that cannot add steps.** A failure function runs once after the retries are spent, before the run moves to the dead letter queue. It receives the run's context and the failing step's status, body and headers, and it cannot define further steps. [5]

**A run id reserved while running.** A trigger with a run id already in progress is refused with an error. After the run ends a new trigger starts a new run even with the same body. [6]

**Steps bounded, logs for days.** A run may hold a bounded number of steps, the same on every plan, and its logs are kept for days, the count set by the plan. [7][8]

## The same work under Durable

**One function, one database.** The engine is a library inside your app's own functions on the Postgres the app already has; a minute cron is the one moving part outside the request path, and no vendor's queue calls your endpoint step by step.

**The key is a field list.** `key: ["orderId", "requestId"]`, clock-free, refused at the door otherwise; the same intent twice is one run for the row's life, with no reserved id to catch and no new run after the first ends.

**A finished step is served from its row.** Each step's input and output land on a row before the body goes on; after a crash the next attempt replays the finished rows and re-invokes only what did not finish.

**The undo in reverse, then the ledger.** Every step declares its undo with its effect or says why it cannot, refused at the door otherwise; when a later step fails the undos run in reverse, each a ledger row with what it found and restored. Every write leaves a before and after image on an append-only, hash-chained ledger that is never pruned; `durable-sdk ledger verify --file <export>` walks an export offline.

**The agent asks the graph.** `durable-sdk explain <workflow>` prints what the door admits, every step with its undo and its writes, the facts and who listens; `durable-sdk graph walk <subject>` prints the closure from any node; `durable-sdk graph impact --changed` prints what a change reaches before it is made. Offline, over a committed index: an AI coding agent asks before it edits, never guesses.

**Nothing to write but the steps.** No failure function, no dead letter queue to sweep, no stop of traffic before a deploy: a changed body patches a branch or bumps its version, and a run that meets a reordered step is refused on its row before anything runs twice, a person's to redrive; a failed run waits in limbo for a person, and `durable-sdk doctor --host` runs every rule before a deploy.

## What you write yourself

| What you write yourself                        | Upstash Workflow                                                                                                                                                                                | Durable                                                                                    |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| Each step is its own HTTP call                 | The endpoint, with the vendor's two signing keys set in its environment so the SDK verifies every call. A long outbound call goes through the vendor's own call step rather than your function. | none; the engine is a library inside your functions, no endpoint called step by step       |
| A step's work can run twice                    | The idempotency of every step's work, and the same answer from every read outside a step on every call. The page names no key, no upsert and no technique, only the rule.                       | a finished step is served from its row; a provider write reads before it writes            |
| Retries with backoff, then a dead letter queue | The failure callback that tells someone, and any undo of what the failed step did before a resume.                                                                                              | bounded redrives of a transient cause, then limbo with the rows; no second queue           |
| A failure function that cannot add steps       | The compensation, by hand, outside the run. The docs describe no undo of the steps that completed.                                                                                              | the undo declared on the step, run in reverse, each a ledger row                           |
| A run id reserved while running                | The id derived from the intent, and the check of the run's state before you skip or retry.                                                                                                      | the intent key, for the row's life; a resend joins the one run                             |
| Steps bounded, logs for days                   | The new route or the stop of traffic before a deploy that reorders steps, and the record of what a step changed.                                                                                | the ledger: before and after images, never pruned; a change over runs in flight by version |

When Upstash Workflow wins: a step-by-step run driven from a queue you do not operate with nothing to install beside your endpoint, a dead letter queue with bulk resume and restart, and a Python SDK beside TypeScript.

## Sources

1. https://upstash.com/docs/workflow/basics/how
2. https://upstash.com/docs/workflow/howto/security
3. https://upstash.com/docs/workflow/basics/caveats
4. https://upstash.com/docs/workflow/howto/failures
5. https://upstash.com/docs/workflow/features/failure-callback
6. https://upstash.com/docs/workflow/howto/singleton
7. https://upstash.com/pricing/workflow
8. https://upstash.com/docs/workflow/howto/changes

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/compare/upstash-workflow.md, then decide between Durable and Upstash Workflow for a keyed multi-step job that outlives a request; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
