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.request
  • Examples
  • pm.request properties
Tests and scriptsWrite scriptsPostman sandbox reference

Reference Postman requests in scripts

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

Access cookies in Postman scripts

Next

Reference Postman responses in scripts

Built with

The pm.request object provides access to the data for the request from a script running within it. pm.request is available in both Before invoke and After response scripts. For a Pre-request script, this is the request that’s about to run. For a Post-response script, this is the request that has already run.

You can use the pm.request object pre-request scripts to alter various parts of the request configuration before it runs.

pm.request

Use the pm.request methods in your scripts to access and manipulate collection requests.

See the Postman Collection SDK Request reference for more information.

pm.request.headers.add(header:Header):function

Adds a header with the given name and value for the current request.

pm.request.headers.remove(headerName:String):function

Deletes the request header with the given name.

pm.request.headers.upsert({key: headerName:String, value: headerValue:String}):function

Inserts the given header name and value if the header doesn’t exist. If it exists, the existing header updates with the given value.

Examples

Add a header with the given name and value for the current request:

1pm.request.headers.add({
2 key: "client-id",
3 value: "abcdef"
4});

pm.request properties

The pm.request object contains the following properties:

  • pm.request.url:Url - The request’s URL.

  • pm.request.headers:HeaderList - The list of headers for the current request.

  • pm.request.method:String - The HTTP request’s method.

  • pm.request.methodPath - The package, service, and method name in packageName.serviceName.methodName format.

  • pm.request.body:RequestBody - The request body’s data. This object is immutable and can’t be modified from scripts.

  • pm.request.auth - The request’s authentication details.

  • pm.request.metadata - The list of metadata sent with the request. An individual metadata item is an object containing the key and value properties. For example, PropertyList<{ key: string, value: string }>.

  • pm.request.messages - The list of outgoing messages. An individual message is a PropertyList object with the following properties:

    • data - The contents of the sent message.
    • timestamp - The time the message was sent, represented as a Date object.

    For requests with unary and server streaming methods, pm.request.messages contains only one message at index 0, which can be accessed as pm.request.messages.idx(0).

Request mutation isn’t supported in the pm object.