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
      • Welcome
        • Overview
        • Download
        • Send a request
        • Write a test
        • Sign up and sign in
        • Create a collection
        • Explore the Postman API Network
        • Next steps
      • Troubleshooting
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.

Get startedPostman first steps

Write your first test

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

Send your first API request

Next

Sign up for Postman

Built with

API tests are a way to ensure that your API is behaving as you expect it to. For example, you might write a test to validate your API’s error handling by sending a request with incomplete data or wrong parameters. You can write tests for your Postman API requests in JavaScript and add them to individual requests, collections, and folders in a collection. Postman includes code snippets you can add and then change to suit your test logic.

To write a test, do the following:

  1. Go to the request you made in Send your first API request.

  2. In the request, click the Scripts tab, then click Post-response.

  3. Click Code icon Snippets at the lower right of the code editor, then select Status code: Code is 200. This will enter the following test code:

    1pm.test("Status code is 200", function () {
    2 pm.response.to.have.status(200);
    3});
  4. Click Send.

After the request runs, the test will run. In the response section, click Test Results to review the results of your test.

To learn more about writing tests, go to Write scripts to test API response data in Postman.