# Getting started with Errors API

![errors.png](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/ab092981-3070-4a3b-8a61-a4a72b1f2e00/md1x =2600x878)

## How Errors API works

Our API follows the [JSON:API](https://jsonapi.org/) specification.

API requests made to Better Stack API are authorized using a [Bearer Authentication standard](https://swagger.io/docs/specification/authentication/bearer-authentication/). That means you'll only need to add a header with `Authorization: Bearer $TOKEN` to your requests.
To access the Errors API, you need an API token. This token **authenticates your requests** and grants you access to manage your resources programmatically. The Errors API uses the same tokens as the Telemetry API.

You can use either a Global API token (for organization-wide management) or a Telemetry API token (scoped to a specific team).

### Get a global API token

A global API token is a token **valid across all your teams**, for managing anything within Better Stack.

- Go to [Better Stack → API tokens](https://betterstack.com/settings/global-api-tokens ";_blank").
- Copy an existing token or create a new one in the **Global API tokens** section.

![Global API Token](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/4105983b-56a9-48d6-5f91-4548d3851800/md1x =3180x1004)

### Get a Telemetry API token

A Telemetry API token is a **team-scoped token** for managing your Telemetry resources, including Errors. You can get a separate API token for each of your teams.

- Go to [Better Stack → API tokens -> Team-based tokens](https://betterstack.com/settings/api-tokens/0 ";_blank").
- Select your team.
- Copy an existing token or create a new one in the **Telemetry API tokens** section.

![Telemetry API Token](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/1db96051-6344-48d3-e378-44d3b5130d00/md2x =3182x810)

## Pagination

Lists come in pages, with a `pagination` object in the response body. To go through every page, request the URL in `pagination.next` until it's `null`. To get a specific page, pass the `page` query parameter.

| Parameter  | Type    | Value                                                                                            |
|------------|---------|--------------------------------------------------------------------------------------------------|
| `page`     | Integer | The page number to return, starting with `1`.                                                    |
| `per_page` | Integer | Number of results per page. Defaults to `50`, maximum `250`, unless the endpoint says otherwise. |

| Attribute          | Type             | Value                                                      |
|--------------------|------------------|------------------------------------------------------------|
| `pagination.first` | String           | The URL of the first page.                                 |
| `pagination.last`  | String           | The URL of the last page.                                  |
| `pagination.prev`  | String or `null` | The URL of the previous page, or `null` on the first page. |
| `pagination.next`  | String or `null` | The URL of the next page, or `null` on the last page.      |

```shell
[label Example cURL to list applications]
curl --request GET \
  --url "https://errors.betterstack.com/api/v2/applications?page=3&per_page=20" \
  --header "Authorization: Bearer $TOKEN"
```

```json
[label Example response body listing applications]
{
  "data": [
    {
      "id": "41",
      "type": "application",
      "attributes": {
        application's attributes omitted...
      }
    },
    {
      "id": "42",
      "type": "application",
      "attributes": {
        application's attributes omitted...
      }
    }
  ],
  "pagination": {
    "first": "https://errors.betterstack.com/api/v2/applications?page=1&per_page=20",
    "last": "https://errors.betterstack.com/api/v2/applications?page=3&per_page=20",
    "prev": "https://errors.betterstack.com/api/v2/applications?page=2&per_page=20",
    "next": null
  }
}
```
