Menu
For Loop Connector
Iterate over an array (For Each) or repeat until a condition is met (Do While), running nested workflow steps each time.
Browse 2 For Loop actions workflowOn this page
What this connector is for
Repeats a sequence of nested steps, either once per item in an array (For Each) or while a condition stays true (Do While). To stop a loop early from inside its own body, see Break Loop; to skip an iteration based on a condition without stopping the loop, wrap the relevant nested steps in a Conditional Branch instead.
All fields are listed in the action reference.
Inside the loop body, the current item and index are available two ways: as bare template variables using the names you chose ({{item}}, {{index}}), and via this step's own reference ({{<stepReference>.item}}, or under the uniform envelope {{<stepReference>.response.data.item}}). Both work identically; bare access is simpler unless an outer loop uses the same variable name.
For Each
Iterates over an array, running the nested steps once per item. The array can be a {{...}} expression or a JSON array string, which is parsed automatically. The index is 0-based.
- Record Identity gives each iteration a stable business key (e.g.
{{item.sku}}) for cross-run history, per-record filtering and record-scoped rerun in batch jobs; it falls back to the iteration index. - Progress: with exactly one loop anywhere in the call graph (including loops inside called workflows/routes), it is picked automatically as the batch job's primary progress source. With more than one, exactly one must set Primary Progress Source, otherwise the job's top-level progress follows whichever loop reports first.
Reading the response
{{<stepReference>.response.data.iterations}}— items actually processed.{{<stepReference>.response.data.items}}— the original array.{{<stepReference>.response.data.results}}— each iteration's last-step output, in order.{{<stepReference>.response.data.failedIterations}}— nonzero only when a batch job's Continue On Iteration Error behavior kept the loop running past a failed item.{{<stepReference>.response.data.stoppedEarly}}— true if the loop stopped before consuming the whole array (execution deadline reached, or a Break Loop fired);remainingCountis how many items were never reached.{{<stepReference>.response.data.brokenEarly}}— true specifically when Break Loop stopped it, as opposed to the deadline.
Example
A loop named "For Each Line Item" (reference forEachLineItem) with Array Source {{trigger.body.lineItems}}: inside its body, {{item.sku}} and {{forEachLineItem.item.sku}} both read the current line item's sku; after the loop, {{forEachLineItem.response.data.iterations}} is how many ran.
Do While
Runs the loop body first, then repeats it while the Continue Condition stays true; no array is needed, so there is an index variable but no item variable.
- The condition is evaluated after each iteration, so the body always runs at least once. It uses the same condition shape as Conditional Branch (single comparison or nested AND/OR groups) and is commonly a
{{runtimeVariables.x}}value set by a step earlier in the loop body (see Variable). - Leaving the condition unset evaluates to false, so an unconfigured loop safely runs exactly one iteration.
- Max Iterations (default 1000, range 1 to 100000) is a hard cap so a condition that never turns false can't run forever.
Reading the response
{{<stepReference>.response.data.iterations}},.resultsand.failedIterationsbehave as in For Each.{{<stepReference>.response.data.reason}}— why the loop stopped:"condition_false","break","max_iterations"or"deadline".{{<stepReference>.response.data.stoppedEarly}}— true only when truncated by Max Iterations or the execution deadline. A false condition or a Break Loop are intentional, successful terminations, not "stopped early".{{<stepReference>.response.data.brokenEarly}}— true whenreasonis"break".
Example
Poll a job until it finishes, giving up after 50 attempts:
Continue Condition: {{runtimeVariables.jobStatus}} equals "pending"
Max Iterations: 50
Index Variable Name: attempt
Also applies here
Step Name
What it's for
Every step in a workflow gets a name — either one you set or a default based on the connector and action (e.g. "Get Order Details", "Send Welcome Email"). It's shown throughout the UI and in your execution history, and it's also the source for the step's Reference — a camelCase identifier auto-generated from the name (e.g. "Get Order Details" → getOrderDetails) — which is what you actually use in {{...}} expressions to read this step's output from later steps. See Step Reference.
Rules
- Must be at least 2 characters, and 50 characters or fewer.
- Must be unique within the workflow — reusing a name that's already taken will be rejected, with a suggested alternative (e.g.
"Get Order Details 2"). - Can't be empty.
Tips
- Prefer a descriptive, human-readable name over a generic one — "Get Order Details" is easier to work with later than "HTTP Request 2", especially once a workflow has a dozen steps.
- Renaming a step updates every reference to it elsewhere in the workflow automatically.
Step Reference
Syntax
Any input field can reference earlier data using {{expression}}. The expression is evaluated as JSONata — so simple dot-paths and more advanced queries (filters, functions) both work.
Referencing a step's output
Use the step's Reference — a camelCase identifier auto-generated from its Name (e.g. "Get Order Details" → getOrderDetails), shown read-only wherever the step's fields are configured — followed by the field path. Elsewhere in these docs this general pattern is written as {{<stepReference>.field.path}}:
{{getOrderDetails.response.data.id}}
{{getOrderDetails.response.status}}
The raw display name won't work here even though it's what you see in the UI — {{Get Order Details.response.data.id}} isn't valid, since a bare name containing spaces isn't a single JSONata identifier. Always use the camelCase Reference.
You can also reference steps by position instead of by reference:
{{steps[0].response.data.id}}
Referencing trigger data
{{trigger.headers.authorization}}
{{trigger.body.customerId}}
{{trigger.query.page}}
{{trigger.params.orderId}}
{{trigger.method}}
{{trigger.path}}
Referencing workflow variables
{{variables.myVariable}}
See Variables for the full list of variable types and more examples, including connection-type variables.
Referencing runtime variables
A separate, mutable namespace written by the Variable connector while a run is in progress — not the same as the workflow-level variables above:
{{runtimeVariables.myVariable}}
Notes
- If an expression can't be resolved (a typo in a step name, a field that doesn't exist), it resolves to an empty string rather than failing the workflow — check your execution history if a value comes through blank.
- Object values are automatically JSON-stringified when interpolated into a string field.
Last updated 9 October 2026