Skip to main content
The For command (Command Type: EXECUTION_FLOW, id 1101) walks a JSON array on the previous command’s data field, one element at a time. Each iteration runs the nested body: allowlisted PARSE commands, optionally ending with one sink. With a sink, each element is published as its own sink payload; without one, For only transforms and collects the results. For does not create Items or set children.

Command Type

Command Type: EXECUTION_FLOW Command Type ID: 1101

Input

data from the previous command must already be a JSON array. For has no selector of its own.
If data is an object, null, or a scalar, For fails before any sink runs. Extract the array first.

Parameters

There is no selector field and no operator-configurable iteration cap. The cap is 1000 elements.

Locals

Each iteration binds these local variables (they do not write to state): JSONata 1022 receives the current item as its input. The same names are also available in local_variables (${local.item}, ${local.index}, ${local.parent}) and in the JSONata environment. Copy envelope fields you still need (for example a bookmaker id) into state before you extract the array onto data.

Output

For returns the same shape as HTTP parallel 1002 / 1004:
Each entry is the body’s result for that element (or the element itself if the body returned nothing). When the body throws for an element, its slot holds the failure instead:
Filter on error after For to separate failed elements from results, the same way as failed requests in HTTP parallel 1002. For does not create Items and does not set children. Hash, miss, and retry stay on the listing Item. To fan out into children, add an explicit PARSE after For. Commands after For are allowed, including another PARSE over aggregatedResults or another sink. A sink inside the body and a sink after For is two deliveries of related data.

Iteration rules

Publish counts in this table assume the body ends with a sink. Without one, the same rules decide the job status, and nothing is published until a sink after For. Iterations are sequential: one body in flight per For job. Wall time is about N × body duration.

Timings (Test Step and ClickHouse)

For does not introduce a second clock. Test Step badges and ClickHouse timings read the same JobResult.commandTimings rows as every other command:
  • Wrapper row: command type execution_flow for the For command itself
  • Body rows: paths .body.N (N is the command index inside the body)
  • Across iterations, body rows with the same path are coalesced: durations sum; start is the earliest; end is the latest

Usage Examples

Extract events[], then For (JSONata + RabbitMQ sink)

Synthetic listing envelope:
Extract the array onto data, then iterate:
Each sink message is one event. For output data is { "aggregatedResults": [ ... ] } with one entry per event; failed events hold an error entry.

Extract HTTP parallel aggregatedResults

After HTTP parallel 1002 or 1004, data looks like { "aggregatedResults": [ ... ] }. Put the inner array onto data before For:
Then the For command from the previous example.

Common Use Cases

  • Per-event JSONata: Write 1022 against one listing event instead of the whole envelope
  • One sink message per event: Publish independent records without creating child Items
  • HTTP parallel follow-on: Extract aggregatedResults, then For each response payload
  • Transform only: Leave the sink out of the body and sink aggregatedResults once after For
  • Partial listings: Keep the job VALID when some events fail, with each failure and its input in aggregatedResults