For Each
The For Each stage processes each element in an array, applies transformations to each value, and collects the transformed results while maintaining the original array order.

Stage Processing
This stage iterates over all values in the provided array.
Returning Values
Use the Return Stage to return a value during each loop iteration.
Note: Each iteration of the For Loop must return a value.
Metadata Chaining
Metadata chaining ensures that updates to metadata are reflected in subsequent loop iterations. By returning modified metadata along with a value, the updated metadata object becomes available in the next iteration.
Metadata
During the loop, the metadata payload includes a loopIndex that indicates the index of the current iteration.
Success and Failure Paths
- Success path: If all iterations complete successfully, the generated output and updated metadata are passed down the success path.
- Failure path: If any iteration fails for reasons other than a timeout, the stage follows the failure path.
Note: If a failure path is specified, all failures except a timeout will not cause the stage to go into an error state.
Settings
Stage Timeout
Defines the maximum time a stage can spend processing an event. If the timeout is reached before processing completes, all remaining operations are canceled.
Example
Use Case: Contextualizing Sensor Data with a Lookup Key

Description
Retrieve a set of sensor readings from a SQL table. Each reading includes a sensor ID and a raw value. The For Each stage is used to contextualize these readings by performing a lookup to retrieve additional metadata (ex. sensor location, unit of measurement) based on the sensor ID. The contextualized data is then passed to the next stage for further processing.
Incoming Value
[
{ "sensorId": "S1", "rawValue": 100 },
{ "sensorId": "S2", "rawValue": 200 },
{ "sensorId": "S3", "rawValue": 300 }
]
Outgoing Value
[
{ "sensorId": "S1", "rawValue": 100, "location": "Line 1", "unit": "Celsius" },
{ "sensorId": "S2", "rawValue": 200, "location": "Line 2", "unit": "Celsius" },
{ "sensorId": "S3", "rawValue": 300, "location": "Line 3", "unit": "Celsius" }
]