> For the complete documentation index, see [llms.txt](https://docs.sendcode.ru/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sendcode.ru/s-chego-nachat.md).

# С чего начать

## Для начала нужно получить API ключ

Чтобы работать с API и отправлять запросы, в первую очередь необходимо получить токен доступа. Вы можете сгенерировать его во вкладке API [здесь](https://sendcode.ru/api).

## Куда отправлять запросы

Запросы можно отправлять как с помощью методов GET, так и POST на `https://sendcode.ru/v1`. &#x20;

Убедитесь, что заголовок `Content-Type` установлен в `application/json`.&#x20;

Поле `Authorization` должно содержать ваш API ключ. Также токен можно передавать в URL через параметр `token`, однако мы не рекомендуем так делать из соображений безопасности.

Сервис всегда будет отвечать кодом **200**, за исключением ситуаций с некорректным форматом запроса.

Неудачные запросы не тарифицируются.

## Запрос баланса&#x20;

<mark style="color:blue;">`https://sendcode.ru/v1/balance`</mark>

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Response**

{% tabs %}
{% tab title="OK" %}

```json
{
  "ok": true,
  "balance": 90.55,
  "tier": 1
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
  "ok": false,
  "error": "Invalid token"
}
```

{% endtab %}
{% endtabs %}

## Отправка кода&#x20;

<mark style="color:orange;">`https://sendcode.ru/v1/send`</mark>

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body params**

| Name    | Value                                                      |
| ------- | ---------------------------------------------------------- |
| number  | Номер в формате E.164                                      |
| length? | Можно передать длину кода от 4 до 8 (по умолчанию 4 знака) |
| code?   | Если передан будет отправлен ваш код                       |

**Response**

{% tabs %}
{% tab title="OK" %}

```json
{
  "ok": true,
  "number": "+70001234567",
  "code": "9042",
  "cost": 0.45
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
  "ok": false,
  "code": "NUMBER_NOT_FOUND",
  "meessag": "Телефон не зарегистрирован в телеграм"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sendcode.ru/s-chego-nachat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
