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
        • Write pre-request scripts
        • Write tests
        • Script examples
        • Dynamic variables
          • Overview
          • pm variables methods
          • pm.vault
          • pm.cookies
          • pm.request
          • pm.response
          • pm.sendrequest
          • pm.visualizer
          • pm.test and pm.expect
          • pm.require
          • pm.execution
          • pm.message
          • pm.info
          • pm.mock
          • pm.datasets
          • pm.state
        • Troubleshoot test errors
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
  • pm.sendRequest
Tests and scriptsWrite scriptsPostman sandbox reference

Use scripts to send requests in Postman

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

Reference Postman responses in scripts

Next

Script Postman visualizations

Built with

Use the pm.sendRequest method to send a request asynchronously from a Pre-request or Post-response script in HTTP requests. For gRPC scripts, you can use the method in Before invoke, On message, and After response scripts.

This method enables you to run logic in the background if you are carrying out computation or sending multiple requests at the same time without waiting for each to complete. You can avoid blocking issues by adding a callback function so that your code can respond when Postman receives a response. You can then carry out any more processing you need on the response data.

To send a request in your collection using its request ID, use the pm.execution.runRequest method.

pm.sendRequest

You can pass the pm.sendRequest method a URL string, or you can provide a complete request configuration in JSON including headers, method, body, and more.

For more information, see the Request definition and Response structure reference documentation.

The following examples demonstrate use of the pm.sendRequest method:

Examples

Example with a plain string URL:

1try {
2 const response = await pm.sendRequest('https://postman-echo.com/get');
3
4 console.log(response.json());
5}
6catch (error) {
7 console.log(error)
8}

Example with a full-fledged request:

1const postRequest = {
2 url: 'https://postman-echo.com/post',
3 method: 'POST',
4 header: {
5 'Content-Type': 'application/json',
6 'X-Foo': 'bar'
7 },
8 body: {
9 mode: 'raw',
10 raw: JSON.stringify({ key: 'this is json' })
11 }
12};
13pm.sendRequest(postRequest, (error, response) => {
14 console.log(error ? error : response.json());
15});

Example containing a test:

1pm.sendRequest('https://postman-echo.com/get', (error, response) => {
2 if (error) {
3 console.log(error);
4 }
5
6 pm.test('response should be okay to process', () => {
7 pm.expect(error).to.equal(null);
8 pm.expect(response).to.have.property('code', 200);
9 pm.expect(response).to.have.property('status', 'OK');
10 });
11});