Skip to main content

Iterate through data with the Loop block

Learn how to run queries for each item in a data set during a workflow.

A Loop block contains an embedded block which runs for each evaluated item in an array. You use value and index to reference evaluated items and their indexes.

For example, you can automate a welcome email to new customers and customize the message for each recipient, using values like {{ value.email }} and {{ value.name }}.

Loop models

The default mode for Loop blocks is GUI. This mode automatically configures the loop to iterate through the query data you select from the Loop input dropdown. If you require more complex loop logic, use Code. This allows you to configure the JavaScript code used by the Loop block.

The lambda operation is run on each item in the loop input. You must specify the query data through which to loop within the custom code using value or index.

Loop through data and trigger a query with custom code

Configure block settings

Retry settings per iteration or loop

Toggle Retry per iteration or Retry entire loop to configure retry settings for the query that runs for each item or the loop itself.

You can configure the following settings for Response blocks.

Details
Timeout after (ms)

The duration to wait before the block times out. Default is 10000.

Details
Retry count

The maximum number of attempts to retry the query if an error is returned.

Details
Interval

The minimum length of time to wait between query retries. This is useful if a query is triggering a rate limit.

Details
Exponential

Whether to increase the interval between retries, also known as exponential backoff. This is useful for handling rate limits.

Details
Finally

Whether to stop the workflow and return an error if the block fails, or continue to allow an error handler to run.