Skip to main content

Documentation Index

Fetch the complete documentation index at: https://hypha-docs.plinqx.app/llms.txt

Use this file to discover all available pages before exploring further.

The FOREACH node iterates over an array and executes a subgraph for each item.

Overview

FOREACH nodes enable:
  • Array Iteration: Loop over arrays of any size
  • Item Access: Access current item and index in loop
  • Subgraph Execution: Execute nodes for each iteration
  • Concurrency Control: Limit parallel iterations

How It Works

1

Resolve Collection

FOREACH node resolves the collection expression to an array.
2

Iterate Items

For each item in the array, execute the loop subgraph.
3

Access Item

Current item and index available as variables in loop.
4

Collect Results

Results from all iterations collected (optional).

Configuration

Collection Expression

Expression that resolves to an array:
{{START.items}}
{{action.response.data.users}}
{{transform.output.list}}
The collection expression must resolve to an array. Non-array values cause the node to fail.

Item Variables

Access current item and index in loop:
  • Item Variable: Default item (configurable)
  • Index Variable: Default index (configurable)
Access in loop:
{{item.fieldName}}
{{item}}
{{index}}

Concurrency

Control parallel iterations:
  • Max Concurrency: Maximum iterations running simultaneously
  • Sequential: Set to 1 for sequential execution
  • Parallel: Higher values for parallel execution
High concurrency may hit rate limits or overwhelm external services. Use appropriate limits.

Loop Subgraph

Nodes inside the FOREACH loop:
  • Access Item: Use {{item}} and {{index}} variables
  • Independent Execution: Each iteration runs independently
  • Error Handling: Errors in one iteration don’t stop others (unless configured)

Output

FOREACH node provides output:
{
  "itemCount": 10,
  "completedCount": 10,
  "failedCount": 0,
  "results": [...]
}

Best Practices

Validate Collection

Ensure collection is an array before FOREACH

Set Concurrency

Configure appropriate concurrency limits

Handle Errors

Use TRY nodes inside loops for error handling

Limit Size

Consider array size - very large arrays may timeout

Use Cases

  • Batch Processing: Process multiple records
  • API Pagination: Iterate over paginated results
  • Data Transformation: Transform each item in a list
  • Parallel Operations: Execute operations for multiple items

Next Steps

PARALLEL Node

Execute multiple branches in parallel

Transform Node

Transform data in loops