> For the complete documentation index, see [llms.txt](https://docs.contextual.io/documentation-and-resources/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.contextual.io/documentation-and-resources/tenants/tenant-apis/alerts-api.md).

# Alerts API

{% hint style="info" %}
Alerts are in early access and may not be available in your account. [Contact Contextual support](mailto:help@contextual.io) to request that Alerts be enabled for your tenant.
{% endhint %}

Use the Alerts API to manage configuration, validate drafts, inspect alert instances, and manage the tenant's background metrics connection.

## Base URL and Authentication

Use the Alerts API base URL supplied by your administrator. The base URL includes `/api/v1`, as in `https://alerts.example.com/api/v1`. Replace the example hostname with your assigned host.

Direct requests require a bearer token accepted by that service's configured audience and an organization ID in `x-org-id`. The service verifies organization membership and operation permissions.

In shell examples, set `ALERTS_BASE_URL`, `ALERTS_TOKEN`, and `ALERTS_ORG_ID` securely for direct API requests. Use no trailing slash in the base URL. This read-only request lists templates:

```sh
curl --fail-with-body --silent --show-error \
  "$ALERTS_BASE_URL/templates" \
  -H "Authorization: Bearer $ALERTS_TOKEN" \
  -H "x-org-id: $ALERTS_ORG_ID"
```

Do not put tokens or destination URLs in committed files or shared logs. URL-encode IDs used in route segments and preserve their case.

## Swagger UI and OpenAPI

The Alerts service hosts Swagger UI at `/api-docs/` and its OpenAPI 3.1 document at `/api-docs/openapi.json`. For a service hosted at `https://alerts.example.com`, the URLs are `https://alerts.example.com/api-docs/` and `https://alerts.example.com/api-docs/openapi.json`. Replace the example hostname with your assigned host. These paths are outside `/api/v1`; do not append them to the API base. Ask your administrator for the documentation URL if these paths are unavailable.

The documentation endpoints are public. API operations still require authentication, organization membership, permissions, and enabled capabilities. To use **Try it out**, select **Authorize**, enter an accepted access token without the `Bearer` prefix, and supply `x-org-id` for the operation. Write operations change tenant configuration, and destination reveal operations return real credentials.

Use the served contract for the deployed version's operation schemas, parameters, permissions, and responses. This guide explains workflows and interpretation; it complements the machine-readable contract. The contract covers metrics enrollment as well as the other Alerts operations.

## References

* [Configuration](https://docs.contextual.io/documentation-and-resources/tenants/tenant-apis/alerts-api/configuration.md): templates, rules, destinations, subscriptions, silences, and declarative apply.
* [Rule Validation and Preview Endpoints](https://docs.contextual.io/documentation-and-resources/tenants/tenant-apis/alerts-api/validation-and-preview.md): authoring checks and bounded historical observations.
* [Alert Operations](https://docs.contextual.io/documentation-and-resources/tenants/tenant-apis/alerts-api/alert-operations.md): active alerts, history, delivery details, and dismissal.
* [Metrics Enrollment](https://docs.contextual.io/documentation-and-resources/tenants/tenant-apis/alerts-api/metrics-enrollment.md): status, setup, reconnect, notifications, and cleanup.

## Errors and Availability

Errors use `application/json` with `code` (a string or number), `message`, and optional `errors`. For example, validation failures use `code: validation_error`. Preserve the HTTP status, response body, and relevant headers such as `Retry-After` when diagnosing a request; do not expect RFC 7807 `type` or `detail` fields.

| Status        | Typical cause                                                                         |
| ------------- | ------------------------------------------------------------------------------------- |
| `400`         | Invalid input or unsupported authoring shape                                          |
| `401`         | Missing or invalid authentication                                                     |
| `403`         | Missing membership, permissions, or access                                            |
| `404`         | Resource not found in the accessible scope                                            |
| `409`         | Operation conflicts with state, including enrollment required or ineligible dismissal |
| `412`         | Stale hash on a guarded write                                                         |
| `429`         | Request admission limit; inspect `Retry-After`                                        |
| `501`         | Preview capability unavailable for the requested source/history                       |
| `502` / `503` | Upstream evidence, dependency, or temporary availability failure                      |

Where available, `GET /capabilities` reports access, capability state (`enabled`, `paused`, or `unavailable`), and permitted actions such as inspect, author, and cleanup. Do not infer that every operation is available from a visible navigation item. At the API, a known pause can still permit inspection and narrowly defined disable/delete cleanup. The Admin Console hides Alerts navigation and blocks the Alerts page when the platform capability is not enabled; it is not a paused-tenant cleanup interface.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.contextual.io/documentation-and-resources/tenants/tenant-apis/alerts-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
