> ## Documentation Index
> Fetch the complete documentation index at: https://cobalt-55-abhishek.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Loop node

> Execute workflow sections repeatedly with fixed iterations, array processing, or conditional loops

The Loop node enables repetitive execution of workflow sections. It acts as a container for nodes that need to run multiple times with different data or conditions.

## When to use

* Process arrays of records from NetSuite or SAP
* Fetch paginated API results until all data is retrieved
* Create multiple records in bulk operations
* Execute operations a specific number of times

## Actions

<Accordion title="Fixed Iteration" icon="repeat">
  Runs the loop a specified number of times regardless of input data.

  **Parameters:**

  | Field                      | Required | Description                                                                                             |
  | -------------------------- | -------- | ------------------------------------------------------------------------------------------------------- |
  | Number of iteration counts | Yes      | Number of times to execute the loop                                                                     |
  | Output Data                | No       | Data to collect from each iteration using node variables                                                |
  | Concurrent Batches         | No       | Iterations to run in parallel (e.g., 10 total with 3 concurrent runs as 3,3,3,1). Default: 50, max: 100 |

  **Access iteration number:** `{{loop.iteration_number}}`
</Accordion>

<Accordion title="Array Iteration" icon="list">
  Runs the loop once for each element in the provided array.

  **Parameters:**

  | Field              | Required | Description                                                                                     |
  | ------------------ | -------- | ----------------------------------------------------------------------------------------------- |
  | Fanout Array       | Yes      | Array to iterate over. Each element available as `{{array_item}}`                               |
  | Output Data        | No       | Data to collect from each iteration (e.g., `{{process_contact.result}}` or `{{array_item.id}}`) |
  | Concurrent Batches | No       | Array elements to process in parallel. Default: 50, max: 100                                    |

  **Access current element:** `{{array_item}}` or `{{array_item.property}}`
</Accordion>

<Accordion title="Do While" icon="rotate">
  Continues looping while conditions are met and stops when break conditions are satisfied.

  **Parameters:**

  | Field                | Required | Description                                                                                      |
  | -------------------- | -------- | ------------------------------------------------------------------------------------------------ |
  | While Condition Rule | No       | Match logic for the while conditions: `Match All Conditions` (AND) or `Match Any Condition` (OR) |
  | While Condition      | No       | Conditions under which the loop continues executing. Click **+ Add Condition** to add rules      |
  | Break Condition      | No       | Conditions under which the loop stops executing. Click **+ Add Break Case** to define exit rules |
  | Output Data          | No       | Data to collect from each iteration into the loop node's output array                            |

  <Note>Define a **While Condition**, a **Break Condition**, or both — otherwise the loop has no way to stop.</Note>

  **Access iteration count:** `{{loop.iteration_count}}`

  <Warning>Do While loops have no built-in iteration limits. Ensure break conditions are properly configured to prevent infinite loops.</Warning>
</Accordion>

### Custom output

All action types support **Custom Output** to define additional output fields. Click **+ Add Field** to capture specific data from loop execution.

<Info>Failed iterations do not stop the loop. Remaining iterations continue executing.</Info>

<Info>The maximum number of batches per instance is **10,000** (including nested batches). Concurrent batches default to **50** and are capped at **100**.</Info>

## Output

Returns an array of results collected from each iteration.

```json theme={null}
{
  "loop_results": [
    {"id": "12345", "status": "created"},
    {"id": "12346", "status": "created"}
  ],
  "total_iterations": 2,
  "successful_iterations": 2,
  "failed_iterations": 0
}
```

## Adding to your workflow

<Steps>
  <Step title="Add Loop node">
    Drag the Loop node from **Utility Nodes** onto your workflow canvas.
  </Step>

  <Step title="Select action type">
    Choose **Fixed Iteration**, **Array Iteration**, or **Do While**.
  </Step>

  <Step title="Configure parameters">
    Set iteration count, fanout array, or loop/break conditions based on action type.
  </Step>

  <Step title="Add nodes inside the loop">
    Drag nodes into the loop container. These execute for each iteration.
  </Step>

  <Step title="Configure output data">
    Specify data to collect from each iteration using node variables.
  </Step>

  <Step title="Test the node">
    Click the **Run** tab to verify iterations and output collection.
  </Step>
</Steps>

## Examples

<Accordion title="Array Iteration: Process NetSuite Contact IDs">
  Fetch full contact details for each ID returned from a NetSuite query.

  **Fanout Array:** `{{netsuite_contacts.records}}`

  ```json theme={null}
  [
    {"id": "1001", "type": "Contact"},
    {"id": "1002", "type": "Contact"}
  ]
  ```

  **Inside Loop:** NetSuite Node with `Get Contact by ID` using `{{array_item.id}}`

  **Output Data:** `{{get_contact.body}}`

  **Result:**

  ```json theme={null}
  {
    "loop_results": [
      {"id": "1001", "firstName": "John", "email": "john@acme.com"},
      {"id": "1002", "firstName": "Jane", "email": "jane@acme.com"}
    ],
    "total_iterations": 2,
    "successful_iterations": 2,
    "failed_iterations": 0
  }
  ```
</Accordion>

<Accordion title="Do While: Fetch Paginated SAP Vendor Data">
  Continue fetching vendor records until all pages are retrieved.

  **Loop Condition (AND):**

  | Variable                    | Operator | Value  |
  | --------------------------- | -------- | ------ |
  | `{{fetch_vendors.hasMore}}` | Equal To | `true` |

  **Break Conditions:**

  | Variable                          | Operator | Value |
  | --------------------------------- | -------- | ----- |
  | `{{fetch_vendors.nextPageToken}}` | Is Null  | -     |

  **Inside Loop:** HTTP node calling SAP API with pagination token

  **Result:**

  ```json theme={null}
  {
    "loop_results": [
      [{"vendorId": "V001", "name": "Acme Corp"}],
      [{"vendorId": "V002", "name": "TechSupply Inc"}]
    ],
    "total_iterations": 2,
    "successful_iterations": 2,
    "failed_iterations": 0
  }
  ```
</Accordion>

<Accordion title="Fixed Iteration: Create Test Records">
  Create 5 test invoice records in Tipalti for sandbox testing.

  **Configuration:**

  * Number of iteration counts: `5`
  * Concurrent Batches: `2`
  * Inside Loop: Tipalti node with `Create Invoice` using `Test Invoice {{loop.iteration_number}}`
  * Output Data: `{{create_invoice.id}}`

  **Result:**

  ```json theme={null}
  {
    "loop_results": ["INV-001", "INV-002", "INV-003", "INV-004", "INV-005"],
    "total_iterations": 5,
    "successful_iterations": 5,
    "failed_iterations": 0
  }
  ```
</Accordion>

## Troubleshooting

<Accordion title="Loop never stops (Do While)">
  **Problem:** Loop continues indefinitely without reaching break condition.

  **Solutions:**

  * Verify break condition variables are updated inside the loop
  * Add a Custom Code node to inspect condition values during execution
  * Implement fallback break condition based on iteration count
</Accordion>

<Accordion title="High failure rate with concurrent batches">
  **Problem:** Many iterations fail when running in parallel.

  **Solutions:**

  * Reduce concurrent batch size to avoid API rate limiting
  * Add Delay node inside loop between API calls
  * Check external system capacity for concurrent requests
</Accordion>

<Accordion title="Cannot access array element properties">
  **Problem:** Variable syntax errors when accessing array items.

  **Solutions:**

  * Use correct syntax: `{{array_item.property_name}}`
  * Verify array elements contain expected properties
  * Use Custom Code node to inspect `{{array_item}}` structure
</Accordion>

<Accordion title="Output data empty or missing">
  **Problem:** Loop completes but no results collected.

  **Solutions:**

  * Verify output data references valid node outputs inside the loop
  * Check that referenced nodes complete successfully
  * Test output expression with single iteration first
</Accordion>

## Next steps

<CardGroup cols={2}>
  <Card title="Tables node" icon="table" href="/v3/platform/concepts/workflows/nodes/tables">
    Store loop results for use outside the loop.
  </Card>

  <Card title="Rule node" icon="bolt" href="/v3/platform/concepts/workflows/nodes/rule">
    Add conditional logic within loops.
  </Card>

  <Card title="Custom Code node" icon="code" href="/v3/platform/concepts/workflows/nodes/custom-code">
    Process complex data per iteration.
  </Card>
</CardGroup>
