# Loop (/docs/workflows/reference/category/controlFlow/loop)

> For the complete documentation index, see [llms.txt](https://docs.tandemcx.ai/llms.txt). Any page on this site can be fetched as Markdown by appending `.md` to its URL.

Run a block of nodes once for each element of an array.

Loop walks an array one element at a time. Wire the `onIterate` exit to the first node of the body and wire the end of the body back to this node: each pass writes the current element to the variable named in `Item Variable`, then routes out `onIterate` again. When the array runs out, or the list is empty, the flow takes `onFinished` instead. `Maximum Iterations` is a runaway guard rather than a batch size: tripping it takes `invalidInput`, with a message naming the limit and the length of the array, so a cap set below the length of the list is reported instead of quietly dropping the rest. The body is a plain run of nodes on the canvas, so nothing constrains where it goes — a body that never routes back to the loop simply runs once. Use Loop Group instead when you want the body boxed on the canvas and a break exit.

**Category:** Control Flow  
**Provider:** Core  
**Latest version:** 1.0.0

## Fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| Array (`array`) | string | Yes | The list to walk. A variable holding a JSON array, or a JSONPath that resolves to one. Example: `$(order.items)` |
| Item Variable (`itemVariable`) | string · variableName | Yes | The variable name the current element is written to before each pass. Read it in the body with the $(name) syntax. Example: `item` |
| Maximum Iterations (`maxIterations`) | number | Yes | The most passes this loop may make. A runaway guard, not a batch size: reaching it with items still unprocessed stops the loop on the invalid input exit, naming the limit and the length of the array, rather than reporting a run that dropped most of its work as finished. Example: `100` |

## Exits

- `onIterate` (required)
- `onFinished` (required)
- `invalidInput` (system)
- `fallback` (system)

System exits (auto-injected, hidden when unwired): `invalidInput`, `fallback`.
