Skip to main content

Overview

Control flow blocks manage the execution logic of your pipeline:
  • IfElse: Conditional branching
  • Loop: Iteration over lists or repetition
  • Delay: Add pauses between operations
  • CaseSwitch: Multi-branch selection
  • SetVariable: Store values in variables
  • Script: Execute custom JavaScript
  • Log: Output debugging messages

IfElse

Execute different block sequences based on a condition.

Settings

condition
KeyCondition
required
Condition to evaluate (same format as KeyCheck conditions)
{
  "source": "data.RESPONSECODE",
  "comparison": "EqualTo",
  "value": "200"
}
true_blocks
Block[]
Blocks to execute when condition is true
false_blocks
Block[]
Blocks to execute when condition is false

Example

{
  "block_type": "IfElse",
  "label": "Check Login Status",
  "settings": {
    "type": "IfElse",
    "condition": {
      "source": "data.RESPONSECODE",
      "comparison": "EqualTo",
      "value": "200"
    },
    "true_blocks": [
      {
        "block_type": "ParseJSON",
        "label": "Extract Token",
        "settings": {
          "type": "ParseJSON",
          "json_path": "json.token",
          "output_var": "TOKEN"
        }
      }
    ],
    "false_blocks": [
      {
        "block_type": "Log",
        "label": "Log Error",
        "settings": {
          "type": "Log",
          "message": "Login failed: <data.RESPONSECODE>"
        }
      }
    ]
  }
}

Loop

Iterate over lists or repeat blocks multiple times.

Settings

loop_type
LoopType
required
Type of loop:
  • ForEach - Iterate over list items
  • Repeat - Repeat N times
list_var
string
Variable containing list to iterate (for ForEach)
item_var
string
default:"ITEM"
Variable name for current item (accessible as data.{item_var})
count
number
default:"1"
Number of iterations (for Repeat)
blocks
Block[]
Blocks to execute in each iteration

ForEach Example

{
  "block_type": "Loop",
  "label": "Process Each User",
  "settings": {
    "type": "Loop",
    "loop_type": "ForEach",
    "list_var": "data.USER_IDS",
    "item_var": "USER_ID",
    "blocks": [
      {
        "block_type": "HttpRequest",
        "label": "Fetch User",
        "settings": {
          "type": "HttpRequest",
          "method": "GET",
          "url": "https://api.example.com/users/<data.USER_ID>"
        }
      }
    ]
  }
}

Repeat Example

{
  "block_type": "Loop",
  "label": "Retry 3 Times",
  "settings": {
    "type": "Loop",
    "loop_type": "Repeat",
    "count": 3,
    "blocks": [
      {
        "block_type": "HttpRequest",
        "label": "Try Request",
        "settings": {
          "type": "HttpRequest",
          "method": "GET",
          "url": "https://api.example.com/data"
        }
      },
      {
        "block_type": "Delay",
        "label": "Wait",
        "settings": {
          "type": "Delay",
          "min_ms": 1000,
          "max_ms": 2000
        }
      }
    ]
  }
}

Delay

Pause execution for a random or fixed duration.

Settings

min_ms
number
default:"1000"
Minimum delay in milliseconds
max_ms
number
default:"1000"
Maximum delay in millisecondsThe actual delay is randomly selected between min_ms and max_ms

Examples

{
  "block_type": "Delay",
  "label": "Fixed Delay",
  "settings": {
    "type": "Delay",
    "min_ms": 1000,
    "max_ms": 1000
  }
}
{
  "block_type": "Delay",
  "label": "Random Delay",
  "settings": {
    "type": "Delay",
    "min_ms": 500,
    "max_ms": 2000
  }
}

CaseSwitch

Multi-branch selection based on input value (like switch/case).

Settings

input_var
string
default:"data.RESPONSECODE"
Variable to match against
cases
CaseBranch[]
Array of case branchesEach branch has:
  • match_value: Value to match
  • result_value: Output value if matched
default_value
string
Default value if no cases match
output_var
string
default:"RESULT"
Variable name to store result
capture
boolean
default:"false"
Capture as user-visible variable

Example

{
  "block_type": "CaseSwitch",
  "label": "Map Status Code",
  "settings": {
    "type": "CaseSwitch",
    "input_var": "data.RESPONSECODE",
    "cases": [
      {"match_value": "200", "result_value": "SUCCESS"},
      {"match_value": "401", "result_value": "UNAUTHORIZED"},
      {"match_value": "403", "result_value": "BAN"},
      {"match_value": "429", "result_value": "RATE_LIMIT"}
    ],
    "default_value": "ERROR",
    "output_var": "STATUS",
    "capture": true
  }
}

SetVariable

Store a value in a variable.

Settings

name
string
required
Variable name (without data. prefix)
value
string
required
Value to store (supports variable interpolation)
capture
boolean
default:"false"
Capture as user-visible variable

Examples

{
  "block_type": "SetVariable",
  "label": "Set API Endpoint",
  "settings": {
    "type": "SetVariable",
    "name": "API_URL",
    "value": "https://api.example.com/v2"
  }
}
{
  "block_type": "SetVariable",
  "label": "Build Auth Header",
  "settings": {
    "type": "SetVariable",
    "name": "AUTH_HEADER",
    "value": "Bearer <data.TOKEN>",
    "capture": true
  }
}

Script

Execute custom JavaScript code for complex logic.

Settings

code
string
required
JavaScript code to executeAvailable variables:
  • data - Access to all pipeline variables
  • input - Access to input variables
  • Return value is stored in output_var
output_var
string
default:"RESULT"
Variable name to store return value
capture
boolean
default:"false"
Capture as user-visible variable

Example

{
  "block_type": "Script",
  "label": "Custom Logic",
  "settings": {
    "type": "Script",
    "code": "const total = data.PRICE * data.QUANTITY; return total > 100 ? 'PREMIUM' : 'STANDARD';",
    "output_var": "TIER",
    "capture": true
  }
}

Log

Output messages to the console for debugging.

Settings

message
string
required
Message to log (supports variable interpolation)

Example

{
  "block_type": "Log",
  "label": "Debug Output",
  "settings": {
    "type": "Log",
    "message": "Processing user: <input.USER>, status: <data.STATUS>"
  }
}

Best Practices

  1. Use IfElse sparingly - KeyCheck often handles branching better
  2. Limit loop iterations - Large loops can slow down pipelines
  3. Add delays between requests - Prevent rate limiting
  4. Use descriptive variable names in SetVariable
  5. Test scripts thoroughly - JavaScript errors halt execution
  6. Use Log blocks for debugging complex pipelines