> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trunk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Flaky Tests: Monitors, labels and flaky marks in the v2 API

> Manage monitors, mute them per test, mark tests flaky, label tests and read detection events through the v2 API, with new API key permissions.

**You can now manage monitors and flag tests from the v2 API, not only from the web app.**

### New features

* **Monitors.** [List](https://docs.trunk.io/api/monitors/list-monitors.md), [get](https://docs.trunk.io/api/monitors/get-a-monitor.md), [create](https://docs.trunk.io/api/testcollections/create-a-monitor.md) and [edit](https://docs.trunk.io/api/monitors/edit-a-monitor.md) a test collection's monitors. Turning a monitor off through the API deactivates it on every test, as it does in the web app.
* **Mute a monitor for some tests.** [Mute](https://docs.trunk.io/api/monitortests/mute-a-monitor-for-one-test.md) or [unmute](https://docs.trunk.io/api/monitortests/unmute-a-monitor-for-one-test.md) a monitor for one test, or [mute](https://docs.trunk.io/api/monitortests/mute-a-monitor-for-many-tests.md) and [unmute](https://docs.trunk.io/api/monitortests/unmute-a-monitor-for-many-tests.md) it for many at once. A mute lasts up to 30 days or has no end. [List a monitor's tests](https://docs.trunk.io/api/monitortests/list-a-monitors-tests.md) to see where it is active.
* **Mark tests flaky.** [Mark a test flaky](https://docs.trunk.io/api/tests/mark-a-test-flaky.md) or [clear the mark](https://docs.trunk.io/api/tests/clear-a-tests-flaky-mark.md), as **Flag as Flaky** does in the web app.
* **Label tests.** [Add](https://docs.trunk.io/api/tests/add-labels-to-a-test.md) or [remove](https://docs.trunk.io/api/tests/remove-labels-from-a-test.md) a test's labels. A new label name creates the label.
* **Detection events.** [List detection events](https://docs.trunk.io/api/detectionevents/list-detection-events.md) to see each verdict your monitors recorded on a test, over a window of up to 30 days.

### Updates

* **New API key permissions.** Flaky Tests writes now need a matching permission on the API key: **Quarantine tests**, **Flag tests**, **Manage monitors**, **Mute monitors**, **Link tickets** and **Create tickets**. A key without permissions can still read collections, tests, monitors and detection events. If a key lacks a permission, the API returns `403 INSUFFICIENT_PERMISSIONS`. See [Permissions](https://docs.trunk.io/api/authentication#permissions).
* **Read a pull request's impacted targets.** A new v2 endpoint returns the impacted targets uploaded for a pull request.

See the [API reference](https://docs.trunk.io/api.md) for all v2 endpoints.
