loop

Schema Definition

type: object
required:
  - type
  - name
  - inputs
  - connections
properties:
  type:
    type: string
    enum: [loop]
    description: Block type identifier
  name:
    type: string
    description: Display name for this loop block
  inputs:
    type: object
    required:
      - loopType
    properties:
      loopType:
        type: string
        enum: [for, forEach]
        description: Type of loop to execute
      iterations:
        type: number
        description: Number of iterations (for 'for' loops)
        minimum: 1
        maximum: 1000
      collection:
        type: string
        description: Collection to iterate over (for 'forEach' loops)
      maxConcurrency:
        type: number
        description: Maximum concurrent executions
        default: 1
        minimum: 1
        maximum: 10
  connections:
    type: object
    required:
      - loop
    properties:
      loop:
        type: object
        required:
          - start
        properties:
          start:
            type: string
            description: Target block ID to execute inside the loop
          end:
            type: string
            description: Target block ID for loop completion (optional)
      success:
        type: string
        description: Target block ID after loop completion (alternative format)
      error:
        type: string
        description: Target block ID for error handling

Connection Configuration

Loop blocks use a special connection format with a loop section:

Alternative format (legacy):

Child Block Configuration

Blocks inside a loop must have their parentId set to the loop block ID:

Examples

For Loop (Fixed Iterations)

ForEach Loop (Collection Processing)

Complex Loop with Multiple Child Blocks

Concurrent Processing Loop

Loop Variables

Inside loop child blocks, these special variables are available:

Output References

After a loop completes, you can reference its aggregated results:

Best Practices

  • Set reasonable iteration limits to avoid long execution times

  • Use forEach for collection processing, for loops for fixed iterations

  • Consider using maxConcurrency for I/O bound operations

  • Include error handling for robust loop execution

  • Use descriptive names for loop child blocks

  • Test with small collections first

  • Monitor execution time for large collections

Was this helpful?