Stop Loop
Use the Stop Loop stage inside a loop to exit early based on how many times the stage has been triggered. It acts like a counter, giving you control over when the loop should stop. This is especially useful when you want to limit how many items are processed.
Each time the Stop Loop stage runs, usually based on a condition inside the loop, it increases an internal counter. When that counter reaches the maximum value you’ve set, the loop exits.
Field | Description |
Max stop count | Set the maximum number of times this stage can be reached before the loop stops. |
Examples
Let's say you're looping through a list of users:
[
{ "name": "Alice", "isActive": true },
{ "name": "Ben", "isActive": false },
{ "name": "Cara", "isActive": true },
{ "name": "Dan", "isActive": true }
]
You only want to find the first two active users.
Set the Loop item name to user
.
Inside the loop, add a Route Flow stage that checks:
user.isActive == true
Then connect that condition to a Stop Loop stage, and set Max stop count to 2
.
The flow will
- Loop through each user
- Increase the stop count each time an active user is found
- Exit the loop once two active users are matched
In this case, the loop stops after checking Cara
—even though there's still one more user left (Dan
). If only one user matches the condition, the loop keeps running until all items are processed.
Outputs
When the stop count hits the defined max, the loop exits and continues down the green path.