# Создание имен отправителей

## Создание имени отправителя (SMS)

<mark style="color:green;">`POST`</mark> `https://direct.i-dgtl.ru/api/v1/sender-names`

При помощи данного метода можно отправить на регистрацию имя отправителя для SMS-трафика.\
Для имен типа PROMO необходимо прикрепление файлов.

#### Headers

| Name                                            | Type   | Description           |
| ----------------------------------------------- | ------ | --------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | `Basic {TOKEN_2}`     |
| Content-Type<mark style="color:red;">\*</mark>  | string | `multipart/form-data` |

#### Request Body

| Name                                               | Type   | Description                                                                                                                                                                |
| -------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark>             | string | <p>Название части содержимого<br><code>file1, file2, file3</code>... -- для прикладываемых файлов<br><code>body</code> -- для основного json'а</p>                         |
| filename                                           | string | <p>Название прикладываемого файла<br>Указывается для<code>name=file</code></p>                                                                                             |
| channelType<mark style="color:red;">\*</mark>      | string | Канал трафика, для которого регистрируется имя отправителя.                                                                                                                |
| commonType<mark style="color:red;">\*</mark>       | string | Тип имени отправителя                                                                                                                                                      |
| brand<mark style="color:red;">\*</mark>            | string | Оператор                                                                                                                                                                   |
| dateFrom<mark style="color:red;">\*</mark>         | string | <p>Желаемая дата начала действия<br>Время с датой вида "yyyy-MM-ddThh:mm:ssZ"; не ранее чем следующий день</p>                                                             |
| senderName<mark style="color:red;">\*</mark>       | string | <p>Имя отправителя<br>Для Мегафона должно соответствовать выражению <code>\[A-z0-9.*!-]{3,11}</code><br>Для остальных операторов<br><code>\[A-z0-9.*+-\s]{3,11}</code></p> |
| counteragentName<mark style="color:red;">\*</mark> | string | Имя юрлица                                                                                                                                                                 |
| counteragentInn<mark style="color:red;">\*</mark>  | string | ИНН юрлица                                                                                                                                                                 |

{% tabs %}
{% tab title="200" %}
Возвращается объект имени отправителя, соответствующий полученному json.

```
{
  "id": 1,
  "channelType": "SMS",
  "commonType": "PROMO",
  "brand": "MTS",
  "dateFrom": "2020-07-07T21:00:00Z",
  "senderName": "test",
  "counteragentName": "Контрагент, ООО",
  "counteragentInn": "123451729124",
  "status": "PRE_REVIEW",
  "fee": 2000
}
```

{% endtab %}

{% tab title="401" %}
Использование невалидного токена / отсутствие заголовка авторизации.

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

```
{
    "error": {
        "code": 4012,
        "msg": "Bad credentials"
    }
}
```

{% endtab %}

{% tab title="4010" %}

```
{
    "error": {
        "code": 4010,
        "msg": "Not Authenticated"
    }
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="403" %}
Использование неподходящего токена.

```
{
    "error": {
        "code": 4030,
        "msg": "Access Denied"
    }
}
```

{% endtab %}

{% tab title="422" %}
Невалидные параметры в теле запроса; ниже приведены несколько примеров ответа.

```
{
    "error": {
        "code": 4220,
        "msg": "Date from isn't greater than now"
    }
}
-----------------------------------------------------------------------------
{
    "error": {
        "code": 4220,
        "msg": "Unknown brand NEW_BRAND"
    }
}
-----------------------------------------------------------------------------
{
    "error": {
        "code": 4220,
        "msg": "Invalid channel type"
    }
}
-----------------------------------------------------------------------------
{
    "error": {
        "code": 4220,
        "msg": "Duplicates with existing name (id = 1161)"
    }
}
```

{% endtab %}
{% endtabs %}

Возможные варианты перечислений:

| Параметр    | Варианты                                                               |
| ----------- | ---------------------------------------------------------------------- |
| channelType | <ul><li>SMS</li></ul>                                                  |
| commonType  | [Типы имен отправителей](/extra/references.md#sender-name-types)       |
| brand       | [Операторы имен отправителей](/extra/references.md#sender-name-brands) |

## Пример запроса <a href="#example" id="example"></a>

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

```
POST https://direct.i-dgtl/ru/api/v1/sender-names
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: multipart/form-data; boundary=--part
--part
Content-Disposition: form-data; name="file1"; filename="document1.pdf"
< ./path/document1.pdf
--part
Content-Disposition: form-data; name="file2"; filename="document2.png"
< ./path/document2.png
Content-Disposition: form-data; name="body"
Content-Type: application/json
{
  "channelType": "SMS",
  "commonType": "PROMO",
  "brand": "MTS",
  "dateFrom": "2020-07-07T21:00:00Z",
  "senderName": "test",
  "counteragentName": "Контрагент, ООО",
  "counteragentInn": "123451729124"
}
```

{% endtab %}

{% tab title="cURL" %}

```
curl -X POST 'https://direct.i-dgtl.ru/api/v1/sender-names' \
-H 'Content-Type: multipart/form-data;boundary=--part' \
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' \
-F 'body={"channelType":"SMS","commonType":"PROMO","brand":"MTS","dateFrom":"2020-07-07T21:00:00Z","senderName":"test","counteragentName":"Контрагент, ООО","counteragentInn":"123451729124"}' \
-F 'file1=@path/document1.pdf'
-F 'file2=@path/document2.png'
```

{% 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://api.docs.direct.i-dgtl.ru/sender-names/post.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.
