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

# Аутентификация

> Как аутентифицироваться в OnlyTraffic Studio API.

## API-ключ

Все запросы требуют заголовок `X-API-Key`.

<Steps>
  <Step title="Получите ключ">
    Перейдите на [studio.onlytraffic.com/api](https://studio.onlytraffic.com/api) и создайте API-ключ.
  </Step>

  <Step title="Добавьте заголовок">
    Передавайте ключ в каждом запросе:

    ```text theme={null}
    X-API-Key: your-api-key-here
    ```
  </Step>
</Steps>

## Base URL

```text theme={null}
https://studio-api.onlytraffic.com/api/external/v1
```

## Пример запроса

<CodeGroup>
  ```bash cURL theme={null}
  curl https://studio-api.onlytraffic.com/api/external/v1/subscribers \
    -H "X-API-Key: your-api-key-here"
  ```

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

  response = requests.get(
      "https://studio-api.onlytraffic.com/api/external/v1/subscribers",
      headers={"X-API-Key": "your-api-key-here"}
  )
  data = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://studio-api.onlytraffic.com/api/external/v1/subscribers",
    { headers: { "X-API-Key": "your-api-key-here" } }
  );
  const data = await response.json();
  ```
</CodeGroup>

## Лимиты запросов

Лимиты разделены по уровням и применяются на аккаунт, они общие для всех API-ключей аккаунта. Уровни, заголовки ответа и формат ошибки `429` описаны в разделе [Лимиты запросов](/docs/ru/api/introduction#лимиты-запросов) на странице «Введение».

## Ошибки

<AccordionGroup>
  <Accordion title="401 Unauthorized">
    | Ошибка                | Сообщение                    |
    | --------------------- | ---------------------------- |
    | `missing_api_key`     | X-API-Key header is required |
    | `invalid_credentials` | Invalid or inactive API key  |
  </Accordion>

  <Accordion title="403 Forbidden">
    | Ошибка          | Сообщение                     |
    | --------------- | ----------------------------- |
    | `access_denied` | Access denied to this account |
  </Accordion>

  <Accordion title="429 Rate Limit">
    | Ошибка                | Сообщение         |
    | --------------------- | ----------------- |
    | `rate_limit_exceeded` | Too many requests |
  </Accordion>
</AccordionGroup>
