***

title: Run API tests using Postman Monitors
approved: 2026-03-12T00:00:00.000Z
search\_keyword: 'setEnvironmentVariable, postman.setEnvironmentVariable, pm.environment.set'
slug: docs/tests-and-scripts/run-tests/test-with-monitors
max-toc-depth: 2
topictype: tutorial
-------------------

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](/docs/monitoring-your-api/setting-up-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](/docs/monitoring-your-api/viewing-monitor-results/).

The following are some ways you can use monitors to test your APIs and ensure they're functioning correctly.

<Info>
  For examples of monitors in action, visit the [Postman API Monitoring Examples public workspace](https://www.postman.com/postman/postman-api-monitoring-examples/overview) to find example collections for some common monitoring use cases. You can [fork the collection](/docs/collaborating-in-postman/using-version-control/forking-elements/#create-a-fork) to collaborate on it in your own workspace.
</Info>

## 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](/docs/tests-and-scripts/write-scripts/test-scripts/).

## 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.

```js
// Set the value
pm.environment.set("data", JSON.stringify({ id: 123 }));

// Get the value
const data = JSON.parse(pm.environment.get("data"));
```

## Monitor HTTP response codes

You can validate HTTP response status codes in your post-response scripts.

```js
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
```

## 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:

```js
pm.test("Response time is acceptable", function () {
    // responseTime is in milliseconds
    pm.expect(pm.response.responseTime).to.be.below(1000);
});
```
