> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# What are Flows?

Flows let you build repeatable, multi-step workflows. Combine steps that call AI models, retrieve or transform data, make decisions, call external APIs, and send results. Use a Flow when you can define the steps and branches before each run.

## How Flows work

You configure each Flow as an ordered set of steps. Runtype runs the enabled steps in that order. A **Conditional Logic** step selects a branch based on its conditions. Later steps can use values from earlier steps through template variables. A step's `when` condition skips that step when it evaluates to false. A bounded `loop` step repeats a sequence of steps until a condition passes or the loop reaches its maximum number of rounds. For details, see [Using conditional steps](/user-guide/flows/using-conditional-steps) and [Using bounded loops](/user-guide/flows/using-bounded-loops).

You can run a Flow from the editor, through the Runtype API, [in a batch over Records](/user-guide/flows/running-flows-in-batch), or [on a schedule](/user-guide/schedules/what-are-schedules).

Most steps have an **Error Handling** setting with three modes: **Continue on error** (the default for most steps), **Stop on error**, and **Use fallbacks**. With **Continue on error**, a failed step does not stop the run, so later steps can receive an empty or default value. Choose **Stop on error** when later steps must not run without that step's output. Some step types handle failures differently. For details, see [When a step fails](/user-guide/flows/flow-step-types-overview#when-a-step-fails) and [Flow execution failures](/user-guide/troubleshooting-faq/flow-execution-failures).

When a step sets an `outputVariable`, reference that value by name in a later step. For example, a step with the output variable `customerLookup` makes `{{customerLookup.tier}}` available to later steps.

## Example: customer support escalation

Dana runs customer support and routes each incoming message to the right response path. Dana's Flow uses this sequence:

1. **Run Task**: Analyze the message for sentiment and intent.
2. **Get Record**: Load the customer's profile Record.
3. **Conditional Logic**: Check whether the sentiment is negative.
   * **If true**: A **Make API Call** step creates a support ticket. A **Run Task** step then writes a response that references the ticket.
   * **Otherwise**: A **Run Task** step writes a response that uses the customer's profile.

To get a typed label with a probability instead of free text for the routing decision, use a [judgment](/user-guide/flows/judgments).

## Example: review moderation

Suppose you need to moderate product reviews before you publish them. Flag spam, profanity, personal attacks, and promotional content without blocking legitimate reviews. Use this Flow pattern:

1. **Run Task**: Send the review text to an AI model. Ask for a JSON object with violation categories and confidence scores. Set `outputVariable` to `analysis`.
2. **Run Code**: Check whether any violation has a confidence score that exceeds your threshold. Set `outputVariable` to `needsReview`.
3. **Conditional Logic**: If `{{needsReview}}` is `true`, route the review to manual review. Otherwise, approve it.
4. **Make API Call**: On the approval path, call your publishing API to publish the review.
5. **Make API Call**: On the manual review path, send the review and `{{analysis}}` to your moderation queue.

To test a Flow and inspect each step's results, see [Debugging flows](/user-guide/flows/debugging-flows). To see past runs of a saved Flow, open the **Save options** menu in the Flow editor and choose **Runs**.

## Available step types

Runtype groups Flow steps into **AI**, **Context**, **Actions**, and **Replies** categories. Common step types include:

* **Run Task**: Send a prompt to an AI model and get a response.
* **Run Agent**: Run a conversational AI step with message history and tool calling.
* **Fetch URL**: Fetch content from a URL.
* **Get Record** and **List Records**: Load one Record or an array of matching Records.
* **Upsert Record** and **Update Record**: Create or update Record data.
* **AI Search**: Search the web with an AI model or search provider.
* **Make API Call**: Send an HTTP request to an external service.
* **Send Email**: Send an email with HTML or plain-text content.
* **Wait Until**: Pause the Flow or poll an API until a condition is met.
* **Render Template** and **Generate PDF**: Create documents from templates or HTML and markdown.
* **Run Code**: Transform data or apply custom JavaScript logic in a sandbox.
* **Conditional Logic**: Route the run through the **If true** or **Otherwise** path.
* **Send Stream of Data**: Stream a response to the caller in real time.

Two more step types are available through the API, the TypeScript SDK, and MCP, but not in the Flow editor: **Bounded Loop**, which repeats a sequence of steps, and **Tool Call**, which runs a tool directly with parameters that you set.

For the complete list and descriptions, see [Flow step types overview](/user-guide/flows/flow-step-types-overview).

## Template variables

Use template variables to pass data between steps and reference Flow inputs.

To provide input through the Runtype API, include values in the `inputs` field. Reference each value by its key. For example, use `{{customerName}}`. For a record-based execution, read the `customer_status` metadata property with `{{_record.metadata.customer_status}}`.

System variables include `{{_flow.name}}`, `{{_execution.timestamp}}`, and `{{_record.id}}`. Use these variables when a step needs Flow, execution, or Record context.

For example, use step outputs and input variables in a prompt:

```text
Summarize this customer message and suggest a response:
Message: {{messageText}}
Customer tier: {{customerLookup.tier}}
Previous interactions: {{customerLookup.count}}
```

In this example, `messageText` is a Flow input, and `customerLookup` is the output object from an earlier step.

## Compare Flows and Agents

The following table compares Flows and Agents by how they choose and run work.

| Aspect    | Flows                                                      | Agents                                              |
| --------- | ---------------------------------------------------------- | --------------------------------------------------- |
| Execution | You define the order and branches before the run.          | The model selects actions during the run.           |
| Control   | You configure each step.                                   | You configure the goal and available tools.         |
| Best for  | Repeatable workflows with defined outputs.                 | Open-ended tasks and dynamic tool use.              |
| Debugging | You inspect each configured step in the execution results. | You inspect model-selected calls and their results. |

Choose a Flow when you can list the required steps and branches before a run. Choose an Agent when the model must select the next action based on the goal, available tools, or earlier results. For hybrid designs and a decision test, see [Choosing between a flow and an agent](/user-guide/flows/choosing-between-a-flow-and-an-agent).

## Next steps

Use these guides to continue:

* [Creating and editing flows](/user-guide/flows/creating-and-editing-flows): create, test, and publish a Flow.
* [Agent and flow templates](/user-guide/flows/agent-and-flow-templates): start from a prebuilt Flow.
* [Using conditional steps](/user-guide/flows/using-conditional-steps): route runs through branches.
* [Judgments](/user-guide/flows/judgments): get typed labels and probabilities to branch on.
* [Flow variables and templates](/user-guide/flows/flow-variables-and-templates): pass data between steps.
* [What are Records?](/user-guide/records/what-are-records): store and retrieve structured data.
* [What are Agents?](/user-guide/agents/what-are-agents): use model-selected actions for dynamic tasks.
* [Flow versioning and publishing](/user-guide/flows/flow-versioning-and-publishing): test drafts and publish changes.
* [Debugging flows](/user-guide/flows/debugging-flows): inspect step results when a Flow misbehaves.
* [Flow validation warnings](/user-guide/flows/flow-validation-warnings): fix issues that Runtype reports when you save.