Skip to navigation

Test APIs and write scripts in Postman

View as Markdown

In an API-first world, APIs are developed before the rest of an application. That means API testing happens earlier in the API lifecycle. With Postman, you can run API tests in the same place where you collaborate and build APIs with your team.

Postman provides a variety of tools you can use to ensure the quality and reliability of your APIs. Use scripts to add logic to your requests, replicate complex user workflows, and write test assertions, then use Postman Collections to group individual tests into comprehensive test suites. Once you’ve set up your tests, you can run them manually or automate them as part of your regular development process.

Mock an API and its dependencies

Stand in for an API without a real backend, whether it’s your own API before it’s built or an external service your app depends on. Write a mock in JavaScript for dynamic, stateful responses, or create a mock server from a collection of saved examples. Develop and test against the stand-in locally or at an always-available hosted URL.

Learn more at Mock APIs and their dependencies in Postman.

Simulate real-world conditions

Use Postman Simulator to group mocks of the services your app depends on, then test how your service responds when those dependencies fail with latency, errors, and rate limits.

Learn more at Simulate API conditions with Postman Simulator.

Add logic and process data with scripts

Add dynamic behavior to your API requests with Postman’s built-in JavaScript runtime by writing test scripts to check for a specific status code, set a variable, or validate a response. You can also use scripts to process data and build dynamic workflows.

Postman can run scripts before a request is sent (pre-request) or after (post-response). You can also create packages for your favorite scripts and reuse them across your Postman team.

Learn more at Use scripts to add logic and tests to Postman requests.

Manage and reuse test data with datasets

Use Postman Datasets to define your test data once and reuse it across your API workflows, instead of duplicating or hard-coding values. You can create a dataset from a data file or from scratch, then query it from your scripts and collection runs.

Learn more at Test APIs with datasets in Postman.

Test APIs at every stage of development

Testing plays an important role throughout the API development lifecycle. You can use Postman to perform essential types of testing, such as integration, end-to-end, and regression testing. You can also use Postman to test performance to make sure your API can handle the expected load.

Learn more at Test API functionality and performance in Postman.

Simulate user traffic to test performance

Run a performance test to simulate user traffic and observe how your API behaves under load. Virtual users send the requests in your collection in parallel from your local machine, your CI/CD environment, or Postman Cloud, so you can find bottlenecks before your users do.

Learn more at Simulate user traffic to test your API performance.

Test applications with UI test integration

Postman’s Application Inventory integrates with your existing UI test suite to validate API interactions and discover dependencies automatically. By connecting Playwright tests to Postman, you can capture network traffic during UI test execution, validate API calls against Postman Collections, and gain visibility into your application’s API dependencies.

This approach bridges the gap between UI testing and API validation, helping you catch contract drift, identify coverage gaps, and maintain comprehensive test evidence for both your user interface and underlying API interactions.

Learn more at Application Inventory overview.

Run and automate your API tests

Postman supports both manual testing and test automation. You can run a single test on demand by sending a request, or run an entire test suite using the Collection Runner.

To increase efficiency and test coverage, you can configure test collections to run automatically on a schedule. You can also use the Postman CLI to run test collections as part of your continuous integration and continuous delivery (CI/CD) pipeline.

Learn more at Run and automate API tests in Postman.

Run collections

Run a collection to send its requests in the order you choose, whether it’s a group of saved requests, a workflow, or a test suite. You can run collections manually with the Collection Runner, schedule them, trigger them with webhooks, or run them with the Postman CLI.

Learn more at Test your API functionality.