Loop (For Each)
Iterates over an array and executes child nodes sequentially for each item. Supports nesting up to 10 levels. Inner loop: $item/$index, outer loop: $parent_item/$parent_index, any ancestor: $for.{nodeID}.item/$for.{nodeID}.index. Max 100 iterations per loop. Runtime budget: 10,000 total nodes. Loop body nodes go in loopBody field. Post-loop nodes go in children field (execute after all iterations finish).
Logic action Logic
Iterates over an array and executes child nodes sequentially for each item. Supports nesting up to 10 levels. Inner loop: $item/$index, outer loop: $parent_item/$parent_index, any ancestor: $for.{nodeID}.item/$for.{nodeID}.index. Max 100 iterations per loop. Runtime budget: 10,000 total nodes. Loop body nodes go in loopBody field. Post-loop nodes go in children field (execute after all iterations finish).
At a Glance
| Field | Value |
|---|---|
| Action ID | for-each |
| Category | Logic |
| Connector | Not required |
| Requires gas | No |
| Funds movement | None declared |
| Tags | logic, loop, iteration, for-each, control-flow |
Payload Schema
| Field | Type | Required | Description |
|---|---|---|---|
array | array | Yes | Array to iterate over (can be template variable like {{node.result.items}}) |
Result Schema
| Field | Type | Required | Description |
|---|---|---|---|
iterations | array | Yes | Array of iteration results |
iterationCount | integer | Yes | Total number of iterations executed |
lastAdvancedIteration | integer | No | Index of the last iteration that was advanced (iterationCount - 1) |
status | string | Yes | Loop execution status |
Examples
json{ "type": "for-each", "payload": { "array": [] }, "children": []}
bashcurl -X POST "https://api.b3os.org/v1/actions/for-each/test" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inputs": { "array": [] }}'
Payload fields can use workflow expressions such as {{$trigger.body.amount}}, {{$nodes.fetch.result.price}}, and {{$props.asset}} when the value should come from a trigger, prior node, or reusable workflow prop.
