# Flow steps

> Flow steps control the path a workflow takes. Start and end a run, branch, loop, handle errors, wait, keep variables, and call other workflows.

Flow steps decide which way a run goes, repeat work, handle errors, pause, remember values, and hand work to other workflows.

## Start and finish

| Step | What it does |
| --- | --- |
| **Begin** | The single starting point of every workflow. Its outputs are the workflow's inputs. Whatever starts the workflow, whether a button, a schedule, a rule, another workflow, an email, or a manual run, arrives here. |
| **Return** | Ends the run successfully and sets the workflow's result. A workflow that called this one and waited for it receives that result. |
| **Abort** | Stops the run as failed. Use it when continuing would be wrong and no later step should run. |

## Decisions

| Step | What it does |
| --- | --- |
| **Branch** | Follows the **True** or **False** path based on a yes-or-no value, for example "Amount is more than 10,000". |
| **Switch Enum** | Follows the path that matches one of a fixed set of labels. Use it when a decision has more than two outcomes, such as a priority of low, medium, or high. Define the labels with **Make Enum**. |
| **Validate Schema** | Checks a value against a shape you define, such as required fields and formats like email or date. Continues on **Valid**, or on **Invalid** with the list of problems. Use it at the start of workflows whose inputs come from outside, such as an email or an HTTP call. |

## Loops

| Step | What it does |
| --- | --- |
| **For Each** | Runs the **Body** path once for each item in a list, then continues on **After**. This is how you handle every record from a read, or every file on a record. |
| **For Loop** | Runs the **Body** path a set number of times, then continues on **After**. Use it when there's no list to walk. |

## Errors

**Try / Catch / Finally** protects a group of steps.

- **Body** holds the steps that might fail, such as a call to another system.
- **Catch** runs if something in the body fails. Add **Break Error** to read the error's code, message, and the step that failed.
- **Finally** runs on the way out, whether the body failed or not. Keep it short. It can't contain a wait.
- **After** continues the workflow.

Use it to record a failure, undo earlier work, or carry on with a fallback instead of failing the whole run.

## Waiting

**Wait** pauses the run for a set time, then continues. The duration is in milliseconds, so one hour is 3,600,000. A waiting run is kept safely and continues even after a restart, so it suits "remind them in three days".

To retry a failed call, use **Try / Catch / Finally** instead of a wait.

## Variables

Variables hold values while the run goes on. Create them in the **Variables** panel.

| Step | What it does |
| --- | --- |
| **Set Variable** | Stores a value under the variable's name. |
| **Get Variable** | Reads a variable's current value. |
| **Push to Array Variable** | Adds one item to a list variable. Use it to collect results inside a loop, such as the files to put in a ZIP. |

## Logging

**Log** writes a message into the run's log, so whoever looks at the run later can see what happened and what values the workflow had.

## Other workflows and functions

| Step | What it does |
| --- | --- |
| **Subflow Call** | Starts another workflow. Pick the workflow, then fill in its inputs. Under **Wait for completion?**, choose whether this run waits for the other one to finish and uses its result, or starts it and carries on. |
| **Function Call** | Runs a function inside this same run and uses its outputs. |
| **Function In**, **Function Out** | The start and end of a function. They appear only when you edit a function, and hold the function's inputs and outputs. |

Use a function when the same group of steps appears in several places. Create it in the **Functions** panel, and use **Make global** to share it with other workflows. Use **Subflow Call** when the work should be a separate run with its own history.

## Plan the flow

Name each branch and what it means for the business. Name the list a loop walks, such as "each open invoice". Give each wait its duration, and say whether a called workflow is waited for.

  - [Workflow steps](/docs/workflows/nodes): How steps work and how to add them.
  - [Data steps](/docs/workflows/nodes/data): Read and write records.

---

Source: https://community.sapugo.app/docs/workflows/nodes/flow
