Loop step

Also known as: loop over items · iterator step

On this page 7

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.

ElementRoleExample
Input collectionList to iterate overArray of 150 order lines
Loop variableHolds the current itemcurrentItem.sku
IndexPosition of the current item0 to 149
Loop bodyActions run per itemUpdate stock, send notice
Exit conditionOptional early stopStop when stock is zero
Aggregated outputCombined result after the loopList of updated records
Core elements of a loop step

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 typeHow it repeatsWhen to use it
For-each loopOnce per item in a listProcessing records from a payload
Repeat-count loopA fixed number of timesRetrying or generating a set of tasks
While loopAs long as a condition holdsPaging through an API until no next page
Batch loopOnce per chunk of itemsBulk API calls with size limits
Parallel loopIterations run concurrentlyIndependent items with high volume
Loop variants in workflow automation

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.

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.

ConstructWhat it doesRelation to the loop step
Filter stepRemoves items or stops a runOften placed before the loop to shrink the list
Conditional branchingChooses a path by conditionFrequently used inside the loop body
Parallel branchRuns different paths at onceDifferent actions, not repeated actions
Sub-workflowCalls a reusable workflowGood container for a complex loop body
Delay stepPauses executionUsed inside loops to respect rate limits
Loop step and neighboring workflow constructs

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.

SymptomLikely causeFix
Loop runs only onceInput is an object, not an arrayMap the correct array field
Run times outToo many sequential iterationsBatch items or split the run
Duplicate records createdNon-idempotent action on retryUpsert on a unique key
HTTP 429 errorsAPI rate limit exceededAdd delays or reduce concurrency
Wrong values in later stepsShared variable overwritten in parallelUse per-iteration outputs
Loop step symptoms, causes and fixes

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.