*Workflows › Build*

# Branches and loops

> Three steps repeat work (and a fourth, Try, keeps a run going after a failure): Loop repeats while a condition holds, Iterate steps run their body once per item of a collection, and Jump goes back to an earlier step. Each has a limit, and each limit is enforced.

## Loop

The «Loop» step repeats the steps inside it while a condition is true, up to a maximum number of laps that you set (a new loop starts at 100; the highest you can enter is 500).

- Before each lap the engine checks the limit, and then the condition. A loop with a maximum of N laps therefore succeeds only if the condition turns false after at most N-1 laps of the body. If the condition would only turn false after N laps, the step fails with "the loop exceeded the N laps allowed".
- That failure ends the run as failed, with no automatic retry, unless the loop is inside a Try. Pressing Retry runs it again, which hits the same limit.
- The loop does not have an item variable. The condition sees what the body produced in earlier laps; later laps overwrite same-named values, and the last value stays after the loop ends.
- A wait inside the body parks the whole run; when it resumes, earlier laps are replayed from the record.
- Each lap uses at least one of the 1000 steps a run may take, for the condition alone. A loop of 500 laps with three steps in its body would need 2000, so the run limit usually stops a loop before its own limit.
- The loop step itself costs no credit; the steps in its body cost one per lap.

> **The first lap:** On the first lap, a variable created inside the body does not exist yet. A condition "X is equal to true" is then false and the loop never starts; "X is not equal to true" is true and the loop runs; "has at least one item" fails the step. To stop a loop when a step inside it gives a result, compare with «is not equal to».

## Iterate (for-each)

An Iterate step resolves a collection once, then runs its body once for each item. Inside the body, the item is a variable (the step's own value). The collection is read once and recorded, so a resumed run goes through the same items even if the data changed.

| Step | Collection | Item |
| --- | --- | --- |
| «Iterate list» | Any list in your workflow: the result of a search, a list field of a record. | The item of the list |
| «Iterate attachments» | The attachments of an email message (needs the message id). | Id, file name, content type, size |
| «Iterate thread messages» | The messages of an email thread. | The message |
| «Iterate channel members» | The members of a Slack channel. | User id, name, real name, whether it is a bot |

- An empty collection is not an error: the body is skipped.
- A collection of more than 500 items is rejected before the first one is processed: the run fails with "resolved more than 500 elements", and is not retried. It never processes only the first 500. Narrow the source (a filter, a date range) before iterating.
- A search that returns a page of results gives you only that page.
- Variables created in the body accumulate across items, and the last item's value stays.
- Every step in the body counts towards the 1000 steps of the run, and costs credits for every item.

The email and Slack iterators are described in [Integrations](https://docs.filmo.io/workflows/integrations).

## Jump

The «Jump to an earlier step» step sends the run back to an earlier step, for retry-style flows ("check again"). It has no condition of its own: put it inside a «Condition» to jump conditionally.

- The target must be a step before the jump: an earlier step at the same level or any level above it, or a step that contains the jump. A step inside the branches of an earlier composite is not a valid target. Saving rejects a target that does not exist or is not earlier.
- You set the maximum number of jumps (default 3, between 1 and 500). When they are used up, the run is not failed: it simply continues with the next step.
- Each jump uses one of the 1000 steps of the run and costs no credit itself. The steps between the target and the jump run again on every pass; each one counts towards the 1000 steps and costs its own credit.
- Variables made on the way are kept; the last pass wins.

## Try

The «Try» step is not a repeat but belongs with the other steps that hold a body. It has no fields: it runs the steps inside it, and if one fails the run goes on with the step after the Try instead of ending. Its outcome («Has failed» and «Error message») is what the next steps can read. A Try around a loop or an Iterate step catches the loop limit as a step failure, but not the 500-item limit of Iterate, which ends the run. In the run viewer, the step that failed inside shows as «Caught error». The details, the pattern and what it does not catch are in [Errors and retries](https://docs.filmo.io/workflows/errors-and-retries#try).

## Nesting

There is no maximum number of steps and no maximum nesting declared for a workflow. The one structural limit is that the stored definition cannot be more than 100 levels deep, counting every wrapper (each nested step adds a couple of levels).

## The numbers

| Limit | Value | At the limit |
| --- | --- | --- |
| Laps of a Loop | 500 at most (default 100) | The step fails, the run fails |
| Items of an Iterate step | 500 | The run fails before processing any item |
| Jumps of one Jump step | 500 at most (default 3) | The run continues with the next step |
| Steps of a run | 1000 | The run fails, with no retry |

All hard limits, with what happens at each, are in [Limits and credits](https://docs.filmo.io/workflows/limits).

---

Canonical URL: https://docs.filmo.io/workflows/branches-and-loops  
Last updated: 2026-10-09