nodes / builtin / flow
Loop
Execute a set of actions repeatedly based on conditions
Repeat a group of steps while your conditions hold, up to a safety limit.
What it does
Section titled “What it does”Loop has two inputs and two outputs:
- Input (top): where the data first comes in.
- Loop Back (bottom input): connect the last step of the repeated part here.
- Loop (output): the steps to repeat start here.
- Done (output): the workflow continues here once the loop ends.
Each time data reaches the node, it checks the Conditions. While they hold, it sends the data out of Loop; your steps run and come back through Loop Back, and the check runs again. As soon as the conditions fail, or the pass count reaches Max Iterations, the data leaves through Done.
Every pass sends { done, currentIndex, inData }, where currentIndex counts the passes from 1 and inData is the data that arrived. Use {{ $input.currentIndex }} in the repeated steps, for example as a page number.
When to use it
Section titled “When to use it”- Page through an API until it returns no more results.
- Retry a step until it reports success.
- Repeat an action a set number of times.
To work through a long list a few items at a time, Split in Batches is simpler. Most nodes already run once per item, so you rarely need Loop just to handle every item of a list.
Inputs and settings
Section titled “Inputs and settings”| Setting | Type | What it does |
|---|---|---|
| Max Iterations | Number | Maximum number of loop iterations. Default: 100 |
| Conditions (required) | Conditions | The conditions to evaluate. |
| Collect results | Toggle | Output everything that came back through Loop Back, in order, on Done. Default: Off |
| One entry per item | Toggle | Used with Collect results: a pass that returns a list adds its items one by one. Off: one entry per pass. Default: On |
Max Iterations accepts 1 to 1,000. The limit stops a loop whose conditions never fail from freezing the tab.
Collect results
Section titled “Collect results”Turn on Collect results to get, on Done, everything that came back through Loop Back during the passes, in order, as results (one entry per item, or per pass). Without it, Done only carries the last data, as before. Up to 10,000 entries (about 2 MB) are kept; beyond that the list is cut, resultsTruncated is set and the run log warns you. Nested loops each keep their own results.
A Loop with no conditions fails with a clear message. When Max Iterations ends it while the conditions still hold, the run log warns you and the output carries stoppedEarly: true.
Outputs
Section titled “Outputs”-
Done -
Loop
Each output item has these fields:
| Field | Type | What it holds |
|---|---|---|
| done | True/false | True when the loop exits through Done |
| currentIndex | Number | |
| inData | Any | The incoming data, unchanged |
| stoppedEarly | True/false | True when Max Iterations ended the loop while its condition still held |
| results | List | With Collect results: what came back through Loop Back on every pass |
| resultsTruncated | True/false | True when Collect results stopped at its limit |
{ "done": true, "currentIndex": 0, "inData": null, "stoppedEarly": true, "results": [], "resultsTruncated": true}When the loop exits through Done, its pass counter resets, so a loop nested inside another loop starts again from 1 on the next outer pass.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
Example workflow
Section titled “Example workflow”Fetch every page of a paginated API:
- A Set Variable node sets
hasMoretotrue. - Loop with the condition
{{ $run.hasMore }}(Boolean) is true, Max Iterations 50. - From Loop: Http Request to
https://api.example.com/items?page={{ $input.currentIndex }}, then Set Variable stores the response’shasMoreflag. Connect it back to Loop Back. - From Done: continue with the collected data.
Common issues
Section titled “Common issues”- The loop stops after one pass. The conditions were false on the second check. Make sure the repeated steps update the value the condition reads, and that the last step is connected to Loop Back, not to the top input.
- The loop always runs exactly Max Iterations times. The conditions never become false. Check the field and operator, or raise the limit if the work really needs more passes.
- Nothing runs after the loop. Connect the next steps to Done, not to Loop.
Related nodes
Section titled “Related nodes”- Split in Batches: work through a list a batch at a time.
- IF: the same kind of conditions, without repeating.
- Poll Until: call a URL repeatedly until the response says it is done.
- Wait: pause between passes.