A loop step is a workflow component that repeats a defined sequence of actions once for each item in a collection, such as every row of a spreadsheet, every file in a folder or every line item in an order. In automation fundamentals, the loop step, also called a loop over items or an iterator step, is the construct that lets a single workflow process lists of variable length without duplicating actions by hand.
The loop step receives an array, exposes the current item and its index to the steps inside the loop body, and continues until the collection is exhausted, a limit is reached or an explicit exit condition is met.
How a loop step executes
A loop step executes by taking an input collection and running its inner steps once per element. The input usually comes from a trigger, a webhook payload or an earlier action that returned a list. On each iteration, the engine binds the element to a loop variable that inner steps reference in their fields.
After the last iteration, the loop either ends silently or produces an aggregated output, such as a list of results or a count of successes and failures, which later steps can use. Most platforms record each iteration separately in the execution log, so a failure on item 37 of 200 can be traced precisely.
| Element | Role | Example |
|---|---|---|
| Input collection | List to iterate over | Array of 150 order lines |
| Loop variable | Holds the current item | currentItem.sku |
| Index | Position of the current item | 0 to 149 |
| Loop body | Actions run per item | Update stock, send notice |
| Exit condition | Optional early stop | Stop when stock is zero |
| Aggregated output | Combined result after the loop | List of updated records |
Types of loop steps
Workflow builders offer several loop variants, and each suits a different shape of problem. Choosing the wrong type is a common source of slow or fragile automations.
| Loop type | How it repeats | When to use it |
|---|---|---|
| For-each loop | Once per item in a list | Processing records from a payload |
| Repeat-count loop | A fixed number of times | Retrying or generating a set of tasks |
| While loop | As long as a condition holds | Paging through an API until no next page |
| Batch loop | Once per chunk of items | Bulk API calls with size limits |
| Parallel loop | Iterations run concurrently | Independent items with high volume |
Sequential iteration preserves order and is easier to debug, but its run time grows linearly with list size. Parallel iteration shortens total duration, yet it can exceed API rate limits and makes ordering and shared workflow variables unreliable, because concurrent iterations may write to the same variable at the same time.
Loop step compared with related constructs
The loop step is often combined with, and sometimes confused with, other control-flow steps in the same workflow. The comparison below clarifies the boundaries.
| Construct | What it does | Relation to the loop step |
|---|---|---|
| Filter step | Removes items or stops a run | Often placed before the loop to shrink the list |
| Conditional branching | Chooses a path by condition | Frequently used inside the loop body |
| Parallel branch | Runs different paths at once | Different actions, not repeated actions |
| Sub-workflow | Calls a reusable workflow | Good container for a complex loop body |
| Delay step | Pauses execution | Used inside loops to respect rate limits |
A practical rule is to filter before looping: removing irrelevant items first reduces both run time and the number of billable tasks, because many platforms count every action inside every iteration toward usage quotas.
Designing reliable loop steps
Reliable loops are idempotent, bounded and observable. Each iteration should be safe to repeat, the total number of iterations should be capped, and every failure should be visible without rerunning the whole collection.
- Set a maximum iteration count so that malformed input cannot create a runaway run.
- Decide on the error policy: stop the whole loop, skip the failed item, or collect failures for later retry.
- Make inner actions idempotent, for example by upserting on a unique key, so that a retried run does not create duplicates.
- Use batching when the target API accepts bulk operations, which can reduce hundreds of calls to a handful.
- Insert a delay or throttle when the target system enforces rate limits.
- Move a long loop body into a sub-workflow to keep the main workflow readable and testable.
Platform limits matter. Many hosted automation tools cap a single run by duration, number of iterations or payload size, so large datasets often need pagination, batch loops or a hand-off to a queue-based process instead of one enormous loop.
Common mistakes with loop steps
Most loop problems come from mismatched data shapes and unhandled limits, not from the loop logic itself. The table pairs frequent symptoms with their causes and fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Loop runs only once | Input is an object, not an array | Map the correct array field |
| Run times out | Too many sequential iterations | Batch items or split the run |
| Duplicate records created | Non-idempotent action on retry | Upsert on a unique key |
| HTTP 429 errors | API rate limit exceeded | Add delays or reduce concurrency |
| Wrong values in later steps | Shared variable overwritten in parallel | Use per-iteration outputs |
A subtle mistake is nesting loops without considering cost. A loop over 200 customers containing a loop over 50 orders runs the inner actions 10,000 times, which can exhaust quotas quickly. Flattening the data or pre-aggregating it often removes the need for nesting entirely.
A non-technical view
Think of a mail clerk with a stack of letters. The clerk follows the same routine for each letter: read the address, add a stamp, drop it in the right tray. The clerk does not need new instructions for every letter, only one routine and a stack to work through.
A loop step gives an automated workflow that same ability. It takes a list of things, applies the same set of actions to each one, and stops when the list is finished.
A concrete example
A small online shop receives a nightly export of new orders as a list in a webhook payload. Each order can contain several products, and the shop wants every buyer to receive a personalized shipping confirmation and every product’s stock level to be updated.
The operations manager builds a workflow with a filter step that keeps only paid orders, followed by a for-each loop step over the remaining orders. Inside the loop, one action updates inventory through an upsert keyed on the order number, and another sends the confirmation email. A one-second delay keeps the email provider within its rate limit, and failed items are collected into a list for a morning retry.
On a typical night, the loop processes about 120 orders in roughly three minutes. Two orders with invalid email addresses are captured in the failure list instead of stopping the run, and the manager fixes them the next morning without touching the other 118.