# Вспомогательные функции

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

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

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

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

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

***

## get\_status - получение информации об авторизации

<mark style="color:blue;">`GET`</mark> `https://api.telefon-ip.ru/api/v1/authcalls/<token>/get_status/<id>/`

#### Path Parameters

| Name                                    | Type    | Description                                |
| --------------------------------------- | ------- | ------------------------------------------ |
| token<mark style="color:red;">\*</mark> | String  | Ключ доступа                               |
| id<mark style="color:red;">\*</mark>    | Integer | Индификатор запроса (берется из get\_code) |

{% tabs %}
{% tab title="200: OK Информация об авторизации" %}

```json
{
    "success": true,
    "error": "",
    "data": {
        "id": 454733,
        "created_at": "2023-04-02T12:54:31",
        "phone": "89243555100",
        "status": 1,
        "status_info": "Ok: SIP 200 OK",
        "price": 0.2
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Ошибка в запросе" %}

```json
{
    "success": false,
    "error": "id record not found",
    "data": {}
}
```

{% endtab %}

{% tab title="401: Unauthorized Ошибка авторизации" %}

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

{% endtab %}
{% endtabs %}

## get\_balance - получение остатка средств на счете

<mark style="color:blue;">`GET`</mark> `https://api.telefon-ip.ru/api/v1/authcalls/<token>/get_balance/`

**Example**

<https://api.telefon-ip.ru/api/v1/authcalls/4ea13fbf-f5a3-4084-8b01-9733cd6fd0b1/get\\_balance/>

#### Path Parameters

| Name  | Type   | Description  |
| ----- | ------ | ------------ |
| token | String | Ключ доступа |

{% tabs %}
{% tab title="200: OK Текущий баланс" %}

```javascript
{
    "success": true,
    "error": "",
    "data": {
        "balance": 5.0,
        "price": 0.2,
        "balance_limit": 0.0
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized Ошибка авторизации" %}

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

{% endtab %}
{% endtabs %}

## get\_billing\_record - получение N последних записей транзакций

<mark style="color:blue;">`GET`</mark> `https://api.telefon-ip.ru/api/v1/authcalls/<token>/get_billing_record/<coun-record>/`

**Example**

<https://api.telefon-ip.ru/api/v1/authcalls/4ea13fbf-f5a3-4084-8b01-9733cd6fd0b1/get\\_billing\\_record/50/>

#### Path Parameters

| Name                                    | Type   | Description                                  |
| --------------------------------------- | ------ | -------------------------------------------- |
| token<mark style="color:red;">\*</mark> | String | Ключ авторизации                             |
| count-record                            | Integr | Количество последних записей (не больше 100) |

{% tabs %}
{% tab title="200: OK Список записей" %}

```javascript
{
    "success": true,
    "error": "",
    "data": [
        {
            "created_at": "2021-12-29T14:06:51",
            "code_auth": "2371",
            "status": 1,
            "status_info": "ok",
            "phone": "89243555100",
            "price": 0.2
        }
}
```

{% endtab %}

{% tab title="400: Bad Request Ошибка в запросе" %}

```javascript
{
    "success": false,
    "error": "count_record field greater than 100",
    "data": {}
}
```

{% endtab %}

{% tab title="401: Unauthorized Ошибка авторизации" %}

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

{% endtab %}
{% endtabs %}

## get\_billing\_csv - получение экспорта данных записей транзакций в csv формате

<mark style="color:blue;">`GET`</mark> `https://api.telefon-ip.ru/api/v1/authcalls/<token>/get_billing_csv/<start_date>/`

**Example**

<https://api.telefon-ip.ru/api/v1/authcalls/4ea13fbf-f5a3-4084-8b01-9733cd6fd0b1/get\\_billing\\_csv/2021-12-31/>

#### Path Parameters

| Name        | Type   | Description                             |
| ----------- | ------ | --------------------------------------- |
| token       | String | Ключ авторизации                        |
| start\_date | String | Дата начала выгрузки формата YYYY-MM-DD |

{% tabs %}
{% tab title="200: OK csv файл" %}

{% endtab %}

{% tab title="400: Bad Request Ошибка в запросе" %}

```javascript
{
    "success": false,
    "error": "Incorrect data format field date_start, should be YYYY-MM-DD",
    "data": {}
}
```

{% endtab %}

{% tab title="401: Unauthorized Ошибка авторизации" %}

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

{% endtab %}
{% endtabs %}

## post\_billing\_data - получение записей транзакций

<mark style="color:green;">`POST`</mark> `https://api.telefon-ip.ru/api/v1/authcalls/<token>/post_billing_data/`

#### Path Parameters

| Name  | Type   | Description      |
| ----- | ------ | ---------------- |
| token | String | Ключ авторизации |

#### Request Body

| Name        | Type   | Description                                     |
| ----------- | ------ | ----------------------------------------------- |
| start\_date | String | Дата начала получения данных формата YYYY-MM-DD |
| end\_date   | String | Дата конца получения данных формата YYYY-MM-DD  |

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

```javascript
{
    "success": true,
    "error": "",
    "data": [
        {
            "created_at": "2021-12-29T14:06:51",
            "code_auth": "2371",
            "status": 1,
            "status_info": "ok",
            "phone": "89243555100",
            "price": 0.2
        }
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "success": false,
    "error": "Incorrect data format field date_start, should be YYYY-MM-DD",
    "data": {}
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript

    "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/vspomogatelnye-funkcii.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.
