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.response
  • pm.response properties
  • Validate response data with a JSON Schema
Tests and scriptsWrite scriptsPostman sandbox reference

Reference Postman responses in scripts

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

Reference Postman requests in scripts

Next

Use scripts to send requests in Postman

Built with

The pm.response object provides access to the data returned in the response for the current request. This object is only available in Post-response scripts.

For more information, see the Postman Collection SDK Response reference.

pm.response

Use the pm.response methods in your scripts to access and manipulate responses.

pm.response.text():Function

Gets the response text string.

pm.response.json():Function

Gets the response JSON object, which you can use to get the properties received.

pm.response properties

The pm.response object contains the following properties:

  • pm.response.code:Number - The response status code.

  • pm.response.status:String - The status text string.

  • pm.response.headers:HeaderList - The list of response headers.

  • pm.response.responseTime:Number - The time the response took to receive in milliseconds. For requests with streaming methods, responseTime denotes the total duration for that request execution.

  • pm.response.responseSize:Number- The size of the response received.

  • pm.response.metadata - The list of metadata received with the response. An individual metadata item is a PropertyList object with the key and value properties.

  • pm.response.trailers - The list of trailers received with the response. An individual trailer item is a PropertyList object with the key and value properties.

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

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

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

Validate response data with a JSON Schema

The jsonSchema method enables you to write a test assertion that validates the response data with a JSON Schema. Postman uses version 6.12.5 of the Ajv JSON Schema validator to validate response data with a JSON Schema.

To write your test assertion, use the pm.response object and Chai Assertion Library BDD syntax to access the data returned in the response.

The jsonSchema method accepts a JSON Schema as an object in the first argument. It also accepts an object of optional Ajv options in the second argument:

1pm.response.<bdd-syntax>.jsonSchema(schema, options);

You can define a JSON Schema in Postman, such as in the Scripts tab of a request. Then you can write a test that validates the properties in your response data against the defined JSON Schema.

Examples

In this example, the JSON Schema requires the response data to contain an alpha property that’s a Boolean data type. If the response data is missing this property or it’s a different data type, the test fails. This example uses BDD syntax to.have to express the assertion:

1const schema = {
2 "type": "object",
3 "properties": {
4 "alpha": {
5 "type": "boolean"
6 }
7 },
8 "required": ["alpha"]
9};
10
11pm.test('Response is valid', function() {
12 pm.response.to.have.jsonSchema(schema);
13});