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
          • Blocks reference
            • Logic blocks overview
            • Condition
            • If
            • Validate
            • Evaluate
            • Delay
            • OR
        • Deployed flows overview
        • Connector blocks overview
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
  • Inputs
  • Outputs
  • Setup
  • Example
  • Related blocks
  • Related pages
Postman FlowsFlows referenceBlocksLogic

The If block

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

The Condition block

Next

The Validate block

Built with

The If block is a logical gate that routes data through one of two output ports based on the result of an evaluation. The If block can process and evaluate data using TypeScript or Flows Query Language (FQL) expressions.

Tip

The If block is one of two blocks you can use to do branching logic in a flow. The other one - the Condition block - supports a wider variety of use cases than the If block. Use the If block only if the your flow’s logic must branch into exactly two logical paths, based on a single condition.

One common use for the If block is to find and filter data.

Inputs

variable - Connect a block to this input port to evaluate its data with TypeScript or FQL. Click Add data blocks Add data blocks to insert a data block into your If block. You can change an inserted block to a different data block by selecting the inserted block’s icon and choosing a block from the dropdown list.

Text box - Enter TypeScript (the default) or FQL code to create true/false expressions here. To switch between TypeScript and FQL, select from the dropdown list at the top of the block.

Data - Data received by this input port will be routed through either the Then or Else output port depending on whether the expression in the text box is true or false. If you don’t need to pass any data through to those outputs, connect a Bool block to the Data input. (This avoids having the If block fail because the Data input has received no data.)

Outputs

When the expression in the text box is true, the block routes data received by the Data input through the Then output port. Otherwise, the data is routed through the Else output.

The data sent through either port is only what the Data input receives, not the variables (if any) that you added as inputs to the evaluation expression.

Setup

  1. To receive and evaluate data from another block in your flow, connect the variable input port to the other block’s output port.

  2. To insert a block and evaluate its data, click Add data blocks Add data blocks, then select a block from the dropdown list. You can reference the inserted block’s value as a variable in your true/false expression. To rename the variable, select the inserted block’s name and enter a new name.

  3. Enter TypeScript (the default) or FQL code to create true/false expressions here. To switch between TypeScript and FQL, select from the dropdown list at the top of the block.

  4. Enter your TypeScript or FQL expression in the text box.

Example

The following example flow uses an If block to compare a random integer to a cutoff set at 350. The flow follows one branch if the input value exceeds the cutoff, and follows the other branch if the input is less than or equal to the cutoff.

Note that for the integer to appear in the Display blocks connected to the THEN and ELSE branches, it was necessary to send that data to the Data input. Sending it to an input for the text box didn’t suffice, because data in the text box isn’t available to the THEN and ELSE branches.

An If block example flow

To run this flow, clone it from Flow Snippets: If.

Related blocks

The blocks you can insert into the If block to provide data for the evaluation that it runs include the String, Bool, Number, Null, Select, Now, Date, Date & Time, List, Record, and Get Variable blocks.

Related pages

For tutorials that use the If block, see the following:

  • Automate repetitive tasks using Postman Flows
  • Send information from one system to another using Postman Flows