> ## Documentation Index
> Fetch the complete documentation index at: https://docs.royaltyport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Loop

> Iterate over arrays and execute nested steps for each item

## Overview

The Loop step iterates over an array and executes nested child steps for each item. On the canvas, the loop appears as a container node — drag child steps inside it to define the logic that runs per iteration.

## Configuration

| Field              | Description                                                                                             |
| ------------------ | ------------------------------------------------------------------------------------------------------- |
| **Iterator Path**  | Path to the array to iterate over ([template variable](/automations/steps/overview#template-variables)) |
| **Mode**           | Sequential or Parallel (with configurable batch size)                                                   |
| **Delay**          | Milliseconds to wait between iterations                                                                 |
| **Max Iterations** | Maximum number of iterations (capped at 10,000)                                                         |
| **Error Handling** | Continue (skip failed items) or Stop (halt on first error)                                              |

### Execution Modes

| Mode           | Description                                                                         |
| -------------- | ----------------------------------------------------------------------------------- |
| **Sequential** | Items are processed one at a time in order                                          |
| **Parallel**   | Items are processed concurrently. Set a batch size to control how many run at once. |

### Accessing Loop Data

Inside child steps, use these template variables:

| Variable                   | Description                               |
| -------------------------- | ----------------------------------------- |
| `{{iteration.item}}`       | The current item being processed          |
| `{{iteration.item.field}}` | A specific field on the current item      |
| `{{iteration.parent.*}}`   | Parent loop context when loops are nested |

### Nesting Loops

Loops can be nested by placing one loop inside another on the canvas. Use `{{iteration.parent.item}}` to access the outer loop's current item from within the inner loop.

When dragging a step over overlapping loops, the canvas places it in the innermost loop automatically. You can also move a step from one loop to another at any time — drag it to the target loop and release when the loop highlights. To remove it from a loop, drag it outside the loop's boundary.

## Output

| Field           | Type    | Description                     |
| --------------- | ------- | ------------------------------- |
| `data`          | array   | Results from all iterations     |
| `success`       | boolean | Whether the loop completed      |
| `success_count` | number  | Number of successful iterations |
| `error_count`   | number  | Number of failed iterations     |
