# Better Stack API

Manage every Better Stack product with one API. Incidents, Telemetry, Errors and AI SRE take the same global API token, and share one request format and one way to page through lists.

## Every API in Better Stack

What do you want to manage via API:

- [Incidents API](https://betterstack.com/docs/uptime/api/getting-started-with-uptime-api/): Monitors, heartbeats, incidents, on-call schedules, escalation policies, severities, status pages, the catalog, metadata, maintenance windows and integrations.
- [Telemetry API](https://betterstack.com/docs/logs/api/getting-started/): Sources, collectors, dashboards, explorations, alerts, extracted metrics, ClickHouse connections, services, traces and SQL queries.
- [Errors API](https://betterstack.com/docs/errors/api/getting-api-token/): Error tracking applications, application groups, errors, error comments and issues, ignored errors, releases, integrations, and the users, sessions and groups real user monitoring sees.
- [AI SRE API](https://betterstack.com/docs/ai-sre/api/getting-api-token/): Chats with AI SRE.
- [Teams and account API](https://betterstack.com/docs/uptime/api/teams/list/): Teams, team members, roles, usage and pricing.

## Get an API token

Send a token in the `Authorization: Bearer $TOKEN` header of every request.

- **Global API token**: valid across all your teams and every product. Copy an existing one or create a new one in [Better Stack → API tokens → Global tokens](https://betterstack.com/settings/global-api-tokens ";_blank"). When it can reach more than one team, pick the team with the `team_id` query parameter, like `t123`.
- **Team-based token**: scoped to one team and one application.
  - Go to [Better Stack → API tokens → Team-based tokens](https://betterstack.com/settings/api-tokens/0 ";_blank") and select your team.
  - Create a token with **Incidents** selected as its application for the Incidents API, or **Telemetry** for the Telemetry, Errors and AI SRE APIs.

Teams, usage and pricing need a global API token.

## Requests and responses

Responses follow the [JSON:API](https://jsonapi.org/) specification: each record sits under `data`, with its `id` as a string and its fields under `attributes`. To create or update a record, send its attributes at the top level of a JSON request body.

```shell
[label Example cURL to create a monitor]
curl --request POST \
  --url "https://incidents.betterstack.com/api/v3/monitors" \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{"monitor_type": "status", "url": "https://example.com"}'
```

## Pagination

Lists come in pages of 50 records unless the endpoint says otherwise. Pass `per_page` for up to 250, and `page` for a specific page, starting with `1`. The response's `pagination` object holds the URLs of the `first`, `last`, `prev` and `next` pages, and `total_count`, the total number of results across all pages. To go through every page, request the URL in `pagination.next` until it's `null`.

```shell
[label Example cURL to list the second page of monitors]
curl --request GET \
  --url "https://incidents.betterstack.com/api/v3/monitors?page=2&per_page=100" \
  --header "Authorization: Bearer $TOKEN"
```

## OpenAPI

Each API comes with an OpenAPI 3.1 document, to generate a client or to import into tools such as Postman:

- [Incidents API](https://betterstack.com/openapi/latest/incidents.json ";_blank")
- [Telemetry API](https://betterstack.com/openapi/latest/telemetry.json ";_blank")
- [Errors API](https://betterstack.com/openapi/latest/errors.json ";_blank")
- [AI SRE API](https://betterstack.com/openapi/latest/chat.json ";_blank")
- [Teams and account API](https://betterstack.com/openapi/latest/betterstack.json ";_blank")

### Manage Better Stack as code, from terminal, or via an agent

Define your resources in code with [Terraform](https://betterstack.com/docs/getting-started/integrations/terraform/) or [Pulumi](https://betterstack.com/docs/getting-started/integrations/pulumi/), run commands from your terminal with the [CLI](https://betterstack.com/docs/getting-started/integrations/cli/), or let your AI assistant work through the [MCP server](https://betterstack.com/docs/getting-started/integrations/mcp/).
