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

# Authentication

> The headers every request needs, how API keys are scoped, and how to choose between staging and production.

Both the File API and the Adclear API authenticate with the same bearer key. Every request needs two headers.

## Required headers

| Header                  | Required | Description                                                                    |
| ----------------------- | -------- | ------------------------------------------------------------------------------ |
| `Authorization`         | Yes      | `Bearer <your-api-key>`, provided during onboarding                            |
| `X-External-User-ID`    | Yes      | A stable identifier for the acting user in your system, such as an employee ID |
| `X-External-User-Email` | No       | The acting user's email, when you have it                                      |

The API key is scoped to a single Adclear organisation and workspace. Rate limits apply per key (see [Errors & rate limits](/developer/errors)).

## Environments

| Environment | File API                           | Adclear API                             | Purpose                               |
| ----------- | ---------------------------------- | --------------------------------------- | ------------------------------------- |
| Staging     | `https://files-staging.adclear.ai` | `https://public-api-staging.adclear.ai` | Integration testing with sandbox data |
| Production  | `https://files.adclear.ai`         | `https://public-api.adclear.ai`         | Live                                  |

API keys are environment-specific. A staging key won't authenticate against production, and vice versa.

<Tip>
  Build and test your integration against staging before switching to production.
</Tip>

## Interactive API reference

Explore and try endpoints in Swagger UI:

* Adclear API: [https://public-api.adclear.ai/v1/docs](https://public-api.adclear.ai/v1/docs)
* File API: [https://files.adclear.ai/v1/docs](https://files.adclear.ai/v1/docs)

Machine-readable OpenAPI 3.1 specs:

* `GET https://public-api.adclear.ai/v1/openapi.json`
* `GET https://files.adclear.ai/v1/openapi.json`

## Generate types from the spec

Generate TypeScript types directly from the specs with [openapi-typescript](https://openapi-ts.dev/):

```bash theme={null}
npx openapi-typescript https://public-api.adclear.ai/v1/openapi.json -o adclear-api.d.ts
npx openapi-typescript https://files.adclear.ai/v1/openapi.json -o adclear-files.d.ts
```
