Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.spojit.com/llms.txt

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

The Loop node repeats a set of steps. It supports three iteration modes: forEach, while, and times.

Loop modes

ForEach

Iterates over each item in an array. The current item and index are available to nodes inside the loop body.
FieldDescription
ArrayThe array to iterate over (reference a previous node’s output)

While

Repeats as long as a condition is true. Evaluates the condition before each iteration.
FieldDescription
ConditionThe expression to evaluate before each iteration
Max iterationsSafety limit to prevent infinite loops

Times

Repeats a fixed number of times.
FieldDescription
CountNumber of iterations

Output handles

HandleDescription
BodyConnect the nodes that should execute on each iteration
CompleteContinues here after all iterations are finished

Accessing loop variables

Inside the loop body, two special variables are injected on each iteration:
VariableDefault nameDescription
Item variableitemThe current array element (forEach mode)
Index variableindexThe current iteration index (0-based)
You can customize these names in the loop node properties panel. Use them in any template expression inside the loop body:
ExpressionResolves to
{{ item }}The entire current element (preserves type — object, string, number, etc.)
{{ item.email }}A specific field on the current element
{{ item.address.city }}Nested field access
{{ index }}Current iteration index: 0, 1, 2, …
When {{ item }} is the entire value (not mixed with other text), the original type is preserved. For example, if item is an object, {{ item }} resolves to that object — not a JSON string. When mixed with text like https://api.com/{{ item.id }}, it resolves to a string.

Example: Fetch users and post each to a webhook

This example fetches a list of users from an API, then loops over each user and sends their data to a webhook.

Canvas layout

[Trigger] → [Fetch Users] → [Loop] ─── body ───→ [Post to Webhook]
                                    └── complete ─→ [Send Summary]

Step 1: Fetch Users (Connector node — direct mode)

FieldValue
ConnectorHTTP Requests
Runner modeDirect
Toolhttp-get
Tool args{"url": "https://jsonplaceholder.typicode.com/users"}
Output variableusers

Step 2: Loop (forEach)

FieldValue
Loop typeForEach
Array{{ users.data }}
Item variableitem
Index variableindex
The array path users.data navigates into the HTTP response: users (output variable) is the parsed HTTP response object { data, status, headers, statusText }, and .data is the response body — here a JSON array of user objects.

Step 3: Post to Webhook (Connector node inside loop body — direct mode)

FieldValue
ConnectorHTTP Requests
Runner modeDirect
Toolhttp-post
Tool args{"url": "https://example.com/webhook", "body": "{{ item }}"}
On each iteration, {{ item }} resolves to the current user object (e.g., {"id": 1, "name": "Leanne Graham", "email": "Sincere@april.biz", ...}). You can also map individual fields:
{
  "url": "https://example.com/webhook",
  "body": {
    "name": "{{ item.name }}",
    "email": "{{ item.email }}",
    "city": "{{ item.address.city }}"
  }
}

Step 4: Send Summary (Connector node after loop completes)

Connect from the loop’s Complete handle. This node runs once after all iterations are finished. The loop’s collected results are available via its output variable.

Tips

  • Always set a max iterations limit on while loops to prevent runaway execution.
  • The loop collects results from each iteration — the complete output is an array of all iteration results.
  • For parallel processing of array items, consider using a Parallel node instead.