# How a Workflow runs

URL: /workflows/how-workflows-run · Id: `page:workflows/how-workflows-run`

> Each Workflow runs as an Action, step by step, under its Roles' Permissions, and retries, escalates or undoes a step that fails.

Each time a [Trigger](/business/nouns/trigger) fires, its [Workflow](/business/nouns/workflow) runs as one [Action](/business/nouns/action), step by step, and the record is kept forever. A deploy or a crash never loses a finished step: the Action resumes at the next one.

## One Action, start to finish
[Dunning](/workflows/processes/billing/dunning) runs every day for the [Billing Specialist](/agents/finance/billing-specialist). Each run is one Action with four steps:

1. **Retry.** [`Invoice.collect`](/business/nouns/invoice/collect) charges each unpaid [Invoice](/business/nouns/invoice) again. The seat's dunning [Mandate](/business/nouns/mandate) covers it, so no one is asked.
2. **Tell.** [`Message.create`](/business/nouns/message/create) writes to the [Customer](/business/nouns/customer) once per retry, with a link to update the card.
3. **Pause.** When the last attempt fails, [`Subscription.pause`](/business/nouns/subscription/pause) stops access. The step names its undo, `Subscription.resume`.
4. **Write off.** Thirty days after service pauses unpaid, [`Invoice.void`](/business/nouns/invoice/void) closes the Invoice.

When the card has expired, no retry can succeed, so the Action skips straight to step 2. The rest of the chapter explains each rule that run follows.

## What a step does
A step calls one [Verb](/business/nouns/verb) as one [Role](/business/nouns/role). It runs under that Role's [Permissions](/business/nouns/permission) and [Limits](/business/nouns/limit), whether an agent or a person fills the seat. The Verb decides whether the step waits:

| The Verb is | The step |
| --- | --- |
| Two-way, inside the Role's Limits | runs at once |
| Granted by a [Mandate](/business/nouns/mandate) the Role holds | runs, and waits out the Verb's delay window first if it is one-way |
| Past a Limit | waits on an [Approval](/business/nouns/approval) from the accountable Role or the [Founder](/agents/founding/founder) |

Each step has a stable id, so an Action resumes on the right step. Every [Process](/business/nouns/process) page shows who does each step.

## When a step fails
A failed step retries first. When retries run out, the step does what it declares:

| On failure | What happens |
| --- | --- |
| `retry` | Tries again with backoff; the default |
| `escalate` | Hands the step to a named Role as a [Task](/business/nouns/task) |
| `compensate` | Calls the step's undo Verb, such as [`Subscription.resume`](/business/nouns/subscription/resume) after a pause |
| `fail` | Ends the Action `failed`, with the reason on record |

A step can also name exceptions: known outcomes that leave the happy path and continue at a later step, as Dunning's expired card does. A `timeout` caps how long a step waits before its failure rule applies.

## On time
A Process can promise a service level: a target time, a business-hours or calendar clock, and the Role that hears when an Action runs late. Waiting on someone outside, such as `awaitingInput`, can stop the clock.

[Support](/workflows/processes/support) promises a first answer within one business hour, and the clock stops while it waits on the Customer. [Privacy](/workflows/processes/privacy) promises 30 calendar days.

## Turn a Process on, change it, pause it
A Process is `off`, `on` or `paused`. Each [Product Template](/business/nouns/product-template) turns its Processes on when the [Startup](/business/nouns/startup) is created. The rest wait for [`Process.enable`](/business/nouns/process/enable) or for the [Event](/business/nouns/event) that wakes them, such as the first [Bill](/business/nouns/bill) waking [Payables](/workflows/processes/payables).

[`Process.pause`](/business/nouns/process/pause) stops new Actions, and Actions already running finish. Each Process lists its [Settings](/business/nouns/setting), each with the sentence that changes it and the call it makes. A changed Setting applies to the next Action, never to one already running.

## What an Action records
An Action is `pending` while it runs, with a reason such as `awaitingInput` or `awaitingTime`, then ends `done`, `failed`, `canceled` or `refused`. It keeps every step's input, output, Role, cost and [Events](/business/nouns/event).

[`Action.retry`](/business/nouns/action/retry), [`Action.pause`](/business/nouns/action/pause), [`Action.resume`](/business/nouns/action/resume) and [`Action.cancel`](/business/nouns/action/cancel) steer one that is running. Canceling runs the compensation of every step that declared one.

To write a Workflow of your own, see [Workflow files](/code/file-conventions/workflows), or ask your agent for one: [automate a workflow](/workflows/automate-a-workflow).

## Next
Part 4 of [six chapters on how the business works](/start/with-your-agent#how-it-works-in-six-chapters). Each step runs on a [System](/business/nouns/system), and [how to read a System page](/systems/how-to-read) is next.