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

# ENS Ads API Authentication: API Keys & Bearer Tokens

> Every ENS Ads API request requires a Bearer token in the Authorization header. Learn how to pass your API key securely in cURL, JavaScript, and Python.

Every request to the ENS Ads API must include your API key as a Bearer token in the `Authorization` header. There are no cookies, query-string parameters, or session-based alternatives — the header is the only accepted mechanism. You can obtain your API key from the [ENS Ads dashboard](https://ads.enslive.live).

## Header format

Include the following header with every request, replacing `YOUR_API_KEY` with your actual key:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

<Warning>
  Never include your API key in client-side or user-facing code. Requests should always originate from your server so the key is never exposed in a browser, mobile app, or public repository.
</Warning>

## Code examples

The examples below show how to attach the `Authorization` header in three common environments.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://ads.enslive.live/api/v1/campaigns/fetch?placement=header_banner" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript (fetch) theme={null}
  const response = await fetch(
    'https://ads.enslive.live/api/v1/campaigns/fetch?placement=header_banner',
    {
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      }
    }
  );

  const data = await response.json();
  ```

  ```python Python (requests) theme={null}
  import requests

  response = requests.get(
      'https://ads.enslive.live/api/v1/campaigns/fetch',
      params={'placement': 'header_banner'},
      headers={'Authorization': 'Bearer YOUR_API_KEY'}
  )

  data = response.json()
  ```
</CodeGroup>

<Note>
  Store your API key in an environment variable (for example, `ENS_ADS_API_KEY`) and read it at runtime. Avoid hardcoding keys in source files or committing them to version control.
</Note>

## Authentication errors

If your key is missing or invalid, the API returns a `401 Unauthorized` response:

```json theme={null}
{
  "status": "error",
  "message": "unauthorized"
}
```

Check that the `Authorization` header is present, the token is prefixed with `Bearer `, and the key itself is correct. If the problem persists, generate a new key from the dashboard.
