- Getting started
- For administrators
- RPA workflow projects
- Creating an RPA workflow from an idea
- Creating a project
- How to start an RPA workflow
- Managing project files and folders
- Connecting RPA workflows to your accounts
- Configuring activities
- Managing the activities in a project
- Passing values between activities
- Iterating through items
- Managing the data in a project
- Configuring a project to use your data
- Using file and folder resources
- App projects
- Agentic processes
- Agents
- Solutions
- API workflows
- Tests

Studio Web user guide
For Each
The For Each activity iterates over arrays and executes a defined set of steps for each array element. Use the For each activity to handle API responses containing object arrays, such as lists of users, orders, or records that require individual processing.
How to aggregate data in an array
A common use case for the For Each activity is aggregating data from multiple API calls into a structured array using the Script activity.
The For Each activity automatically collects the output of the last activity within its Body flow, and compiles it into an array available in its own output.
Using the For Each activity
To add a For each activity to your workflow:
- On your API workflow designer canvas, select the plus (+) icon. The Add activity menu appears.
- Select Loop, then ForEach.
- In the Properties panel, configure the following fields:
- In—Use the Expression editor to specify the array for iteration. Usually, this array comes from a previous API response.
- Item name—Assign a reference name for array elements (default is
currentItem). Use this reference to access each item during iteration.
- In the Body of the ForEach loop, add the activities to process the array items.
- Add activities to the Then and Else branches as needed.
- Debug the workflow to execute the activity and generate output fields for later use.
For Each activity example
The following example iterates over an array of employee objects, combines the first and last names of each employee, and returns the aggregated results in a structured response.
Open the Debug configuration window, then paste and save the following JSON syntax:
{
"employees": [
{
"first_name": "Bobbie",
"last_name": "Draper",
"position": "administration",
"email": "[email protected]"
},
{
"first_name": "James",
"last_name": "Holden",
"position": "manager",
"email": "[email protected]"
}
]
}
{
"employees": [
{
"first_name": "Bobbie",
"last_name": "Draper",
"position": "administration",
"email": "[email protected]"
},
{
"first_name": "James",
"last_name": "Holden",
"position": "manager",
"email": "[email protected]"
}
]
}
- On your API workflow designer canvas, add a For Each activity.
- Configure the For Each fields as follows:
- In—Use the Expression editor to reference the
employeesarray from the run configuration:$workflow.input.employees$workflow.input.employees - Item name—Assign a reference name for array elements (default is
currentItem). Use this reference to access each item during iteration.
- In—Use the Expression editor to reference the
- In the Body of the For Each loop, add a Script activity.
- For the Script activity, use Expression editor to create a JSON that combines the
first_nameandlast_nameproperties into an object:return { "name": $currentItem.first_name + " " + $currentItem.last_name }return { "name": $currentItem.first_name + " " + $currentItem.last_name } - Save the configuration.
- At the end of the workflow, add a Response activity.
- Configure the response as follows:
- Type—Success
- Details—Open the Expression editor and write the following:
This step adds a validation at the beginning of the workflow to confirm a valid transaction exists before processing.
$context.outputs.For_Each_2$context.outputs.For_Each_2
- Debug the workflow to execute the activity.
- Check the Output panel to review the response.