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
        • Use TypeScript in an Evaluate block
        • Iterate through a list using a For loop
        • Select data from complex JSON
        • Persist data outside a flow
        • Use the AI Agent block as logic for a flow
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
  • Recipe
  • Try it out
Postman FlowsFlows cookbook

Use TypeScript in an Evaluate block

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

Postman Flows Cookbook overview

Next

Iterate through a list using a For loop

Built with

You can use TypeScript to process and manipulate data in Evaluate, Condition, and If blocks in your flows. For example, you might use TypeScript to format a timestamp, check a response for errors, or select an item from a list.

Recipe

The following recipe describes how to use TypeScript with an Evaluate block to select a random item from a list:

  1. Create a flow and add an HTTP Request block. For this example, send a GET request to https://openlibrary.org/subjects/love.json?limit=5.

    This gets a list of five book titles.

  2. Connect an Evaluate block to the HTTP Request block’s Success port.

  3. In the Evaluate block, name the variable items and set it to body.works.

  4. Enter the following TypeScript in the Evaluate block to select a random title from the response:

    1items[Math.floor(Math.random() * items.length)].title
  5. Run the flow and click the Evaluate block’s Result output port to see the selected title.

Try it out

To see this recipe’s completed flow, check out Cookbook: Use TypeScript to select a random item from a list. You can also clone this flow to your workspace to experiment with it.