Run API tests using Postman Monitors
With Postman Monitors, you can continuously check the health and performance of your APIs, automatically running Postman tests when the monitor is triggered to run. When you set up a monitor, choose a collection with the requests and tests you want to run. You can choose if you’d like the monitor to run on a schedule or only run when triggered by the Postman CLI. You’re notified if a test fails, experiences an error, or times out, and all results are recorded on the monitor’s results.
The following are some ways you can use monitors to test your APIs and ensure they’re functioning correctly.
For examples of monitors in action, visit the Postman API Monitoring Examples public workspace to find example collections for some common monitoring use cases. You can fork the collection to collaborate on it in your own workspace.
Monitor an API endpoint
To monitor an API endpoint, create a collection with one or more requests for that endpoint, along with tests to validate the responses. You can include different variations of the request, such as query parameters, headers, or request bodies. This enables you to verify how the endpoint behaves under different conditions.
Monitors run the collection and your tests to help ensure the endpoint is working as expected over time. To learn more about writing tests, see Write scripts to test API response data in Postman.
Monitor an entire API
To monitor an entire API, create a collection with multiple requests that represent important endpoints and workflows. Use environment variables to manage shared values like the base URL.
You can also pass data between requests to simulate real-world usage. This enables you to validate how different parts of your API interact and ensure everything works together as expected.
Run API tests
When testing APIs with dependent requests, you can save part or all of a response as a variable and reuse it in later requests. This is useful for passing data such as IDs, tokens, or other values between requests.
Postman stores variables as strings. To work with complex data like objects or arrays, convert them to a string using JSON.stringify() before saving them, and use JSON.parse() to read them later. Once stored, you can reuse this value in subsequent requests, for example as part of a request body.
Monitor HTTP response codes
You can validate HTTP response status codes in your post-response scripts.
Monitor latency
You can validate how long requests take to complete in post-response scripts. Add tests to ensure response times stay within an acceptable threshold: