For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Postman
PricingEnterprise
Contact SalesSign InSign Up for Free
HomeDocs
HomeDocs
      • Overview
        • Overview
            • Loops overview
            • Loops with external data
            • Loops for pagination
            • Loops for polling
          • Work with date and time
          • Find and filter data
          • Run flows in the cloud
          • Send URL-encoded or form data to flows
Postman API Platform

Product

  • Postman Overview
  • Enterprise
  • Spec Hub
  • Flows
  • Agent Mode
  • API Catalog
  • Fern
  • Postman CLI
  • Integrations
  • Workspaces
  • Plans and pricing

API Network

  • App Security
  • Artificial Intelligence
  • Communication
  • Data Analytics
  • Database
  • Developer Productivity
  • DevOps
  • Ecommerce
  • eSignature
  • Financial Services
  • Payments
  • Travel

Resources

  • Postman Docs
  • Academy
  • Community
  • Templates
  • Intergalactic
  • Videos
  • MCP Servers

Legal and Security

  • Legal Terms Hub
  • Terms of Service
  • Postman Product Terms
  • Security
  • Website Terms of Use

Company

  • About
  • Careers and culture
  • Contact us
  • Partner program
  • Customer stories
  • Student programs
  • Press and media
Twitter iconLinkedIn iconGithub iconYouTube iconInstagram iconDiscord icon
Download Postman
Privacy Policy

© 2026 Postman, Inc.

On this page
  • Loops with the Repeat block
  • Loops with the For block
  • Best practices for working with loops
  • Alternatives to loops
Postman FlowsBuild flowsStructureLoops

Loops overview

||View as Markdown|
Was this page helpful?
Previous

Create copies of flows with clones

Next

Loops with external data

Built with

Loops are a basic element of control flow in computer programming that Postman Flows supports. As a visual programming environment, Flows has its own design patterns that you need to know to make looping structures work for you.

Starting in Postman version 11.47.2, you can’t connect blocks to pass data into loops within flow. Instead, use a Create Variable block to store a value, and then insert an inline Get Variable block in the block that needs to use that value.

Loops with the Repeat block

In Flows, here’s the most basic design pattern for a loop:

  1. Begin with a Repeat block. Use a Number block to set the Count input to the number of times you want Flows to iterate through the loop.

  2. Connect a block that does work (for example, an Evaluate block) to the Repeat block.

  3. Optionally, add more blocks that do work, connecting them together in a series.

  4. Connect a Collect block to the last of the blocks from the previous step.

  5. Connect a Display block to the Collect block.

This loop repeats the specified number of times. There’s no way to break out of the loop.

Here’s how the loop will look:

Design pattern for basic loop with Repeat

Loops with the For block

Since the For block iterates over a list, you need to provide a list to its input.

  1. Begin with a List block. Alternatively, you can use an HTTP Request block to pass in a list from an API.

  2. Connect a For block to the List block.

  3. Connect a block that does work (for example, an Evaluate block) to the For block.

  4. Optionally, add more blocks that do work, connecting them together in a series.

  5. Connect a Collect block to the last of the blocks from the previous step.

  6. Connect a Display block to the Collect block.

This loop goes all the way through the list - there’s no way to break out. Nor can you start in the middle.

Here’s how the loop will look:

Design pattern for basic loop with For

Best practices for working with loops

When planning and creating loops in flows, consider the following facts and principles:

  • Collect blocks are great for synchronizing loops, because the flow will wait until all data has been collected before continuing.

  • Don’t try to create a variable within a loop. Flows treat variables as constants that can only be set once.

  • In Flows, you can construct a double For loop that’s equivalent to a nested loop in programming languages like Python or JavaScript. For example, if a value X in the outer loop is needed to process other values in the inner loop, use an Evaluate block in the outer loop to map X to each item you’re sending through to the inner loop. (See the TypeScript map() function.)

Alternatives to loops

Flows can filter and map data. For computational efficiency, consider doing this with TypeScript in Evaluate blocks rather than with loops.

Here’s an example flow whose source data is a list of JSON objects that describe water and oil wells. The goal is to reveal correlations between a well’s elevation and its status.

  • The first Evaluate block filters out all the wells whose elevation falls outside of a range of interest, thus selecting a manageable subset of wells to investigate. The range of interest is from 700 to 960 feet, inclusive, and the following expression performs the filtering:

    1tableOfWells.filter(
    2(row) => row.Elevation >= 700 && row.Elevation <= 960);
  • The second Evaluate block maps values from the data’s Elevation and Status of Well fields to new JSON objects and outputs these as a list ordered by elevation from low to high. Displaying the transformed data as a table makes correlations easier to spot. The following expression performs the mapping and ordering:

    1wellList = wells.map((row) => ({["Elevation"]: row["Elevation"],["Status": row["Status of Well"]}));
    2wellList.sort((a, b) => a.Elevation - b.Elevation);

You could produce the same result using loops. But especially when operating on large data sets, you’ll get better performance using Evaluate blocks with the TypeScript methods filter(), map(), and sort().

Design pattern for basic loop with For