# TG Code - авторизация Telegram

Запросы выполняются методом **POST** или **GET** на URL:&#x20;

**<https://api.telefon-ip.ru/api/v1/authcalls/{token}/{action}/{params}>**  где:&#x20;

**token  -** ключ доступа к API, который можете получить в личном кабинете или по запросу на <support@telefon-ip.ru>.&#x20;

**action** - вызываемые функции API описанные ниже в документации

**params** - передаваемые параметры в зависимости от метода вызова, обычно для GET запроса

***

## get\_tg\_code - запрос с кодом авторизации

<mark style="color:green;">`GET`</mark> `https://api.telefon-ip.ru/api/v1/authcalls/{{token}}/get_tg_code/{{phone}}/`

Отправка кода авторизации через смс. Генерируется случайный четырех значный код. Если нужно отправить свой код, необходимо его передать в параметре code. Время отображения кода в Telegram чате 90 секунд.&#x20;

{% hint style="info" %}
Пример:

`https://api.telefon-ip.ru/api/v1/authcalls/4`ee85f4f-f5a4-4084-6a04-4634cd4fd4b4`/get_tg_code/79243555100?code=0000`

{% endhint %}

#### Path Parameters

| Name                                    | Value  | Description                                                                                                   |
| --------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | Ключ доступа                                                                                                  |
| phone<mark style="color:red;">\*</mark> | string | <p>Номер вызываемого абонента. </p><p><em>Ограничение на количество отправок в сутки (опционально).</em> </p> |

#### Query Parameters

| Name | Type   | Description                                                                                                         |
| ---- | ------ | ------------------------------------------------------------------------------------------------------------------- |
| code | string | Код авторизации: если он указан, то отправляется, а если нет — генерируется автоматически. Длина кода четыре знака. |

**Response**

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

```json
{
    "success": true,
    "error": "",
    "data": {
        "phone": "79243555100",
        "code": "6681",
        "id": 11084059,
        "operator_name": "ООО \"Мегафон\"",
        "channel": "telegram",
        "status": true,
        "status_info": "send ok"
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "success": false,
    "error": "does not match the format 89XXXXXXXXX or phone field is missing",
    "data": {}
}
```

{% endtab %}

{% tab title="401" %}

```json
{
    "success": false,
    "error": "Unauthorized token",
    "data": {}
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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.telefon-ip.ru/reference/api-reference/tg-code-avtorizaciya-telegram.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.
