Создание имен отправителей#
Создание имени отправителя (SMS)#
POST https://direct.i-dgtl.ru/api/v1/sender-names
При помощи данного метода можно отправить на регистрацию имя отправителя для SMS-трафика.
Для имен типа PROMO необходимо прикрепление файлов.
Headers#
Name |
Type |
Description |
|---|---|---|
Authorization* |
string |
|
Content-Type* |
string |
|
Request Body#
Name |
Type |
Description |
|---|---|---|
name* |
string |
Название части содержимого |
filename |
string |
Название прикладываемого файла |
channelType* |
string |
Канал трафика, для которого регистрируется имя отправителя. |
commonType* |
string |
Тип имени отправителя |
brand* |
string |
Оператор |
dateFrom* |
string |
Желаемая дата начала действия |
senderName* |
string |
Имя отправителя |
counteragentName* |
string |
Имя юрлица |
counteragentInn* |
string |
ИНН юрлица |
Возвращается объект имени отправителя, соответствующий полученному 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
}
Использование невалидного токена / отсутствие заголовка авторизации.
{
"error": {
"code": 4012,
"msg": "Bad credentials"
}
}
{
"error": {
"code": 4010,
"msg": "Not Authenticated"
}
}
Использование неподходящего токена.
{
"error": {
"code": 4030,
"msg": "Access Denied"
}
}
Невалидные параметры в теле запроса; ниже приведены несколько примеров ответа.
{
"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)"
}
}
Возможные варианты перечислений:
Параметр |
Варианты |
|---|---|
channelType |
|
commonType |
|
brand |
Пример запроса #
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"
}
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'
import requests
import json
url = "https://direct.i-dgtl.ru/api/v1/sender-names"
payload = {'body': '{"channelType": "SMS", "commonType": "PROMO", "brand": "MTS", "dateFrom": "2026-06-01T21:00:00Z", "senderName": "test", "counteragentName": "Контрагент, ООО", "counteragentInn": "123451729124"}'}
files=[
('file1',('file',open('/path/to/file','rb'),'application/octet-stream')),
('file2',('file',open('/path/to/file','rb'),'application/octet-stream'))
]
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
const formdata = new FormData();
formdata.append("body", "{\"channelType\": \"SMS\", \"commonType\": \"PROMO\", \"brand\": \"MTS\", \"dateFrom\": \"2026-06-01T21:00:00Z\", \"senderName\": \"test\", \"counteragentName\": \"Контрагент, ООО\", \"counteragentInn\": \"123451729124\"}");
formdata.append("file1", fileInput.files[0], "file");
formdata.append("file2", fileInput.files[0], "file");
const requestOptions = {
method: "POST",
headers: myHeaders,
body: formdata,
redirect: "follow"
};
fetch("https://direct.i-dgtl.ru/api/v1/sender-names", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("body", null,
RequestBody.create(MediaType.parse("application/json"), "{\"channelType\": \"SMS\", \"commonType\": \"PROMO\", \"brand\": \"MTS\", \"dateFrom\": \"2026-06-01T21:00:00Z\", \"senderName\": \"test\", \"counteragentName\": \"Контрагент, ООО\", \"counteragentInn\": \"123451729124\"}".getBytes()))
.addFormDataPart("file1","file",
RequestBody.create(MediaType.parse("application/octet-stream"),
new File("/path/to/file")))
.addFormDataPart("file2","file",
RequestBody.create(MediaType.parse("application/octet-stream"),
new File("/path/to/file")))
.build();
Request request = new Request.Builder()
.url("https://direct.i-dgtl.ru/api/v1/sender-names")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/json'
];
$options = [
'multipart' => [
[
'name' => 'body',
'contents' => '{"channelType": "SMS", "commonType": "PROMO", "brand": "MTS", "dateFrom": "2026-06-01T21:00:00Z", "senderName": "test", "counteragentName": "Контрагент, ООО", "counteragentInn": "123451729124"}'
],
[
'name' => 'file1',
'contents' => Utils::tryFopen('/path/to/file', 'r'),
'filename' => '/path/to/file',
'headers' => [
'Content-Type' => '<Content-type header>'
]
],
[
'name' => 'file2',
'contents' => Utils::tryFopen('/path/to/file', 'r'),
'filename' => '/path/to/file',
'headers' => [
'Content-Type' => '<Content-type header>'
]
]
]];
$request = new Request('POST', 'https://direct.i-dgtl.ru/api/v1/sender-names', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
package main
import (
"fmt"
"bytes"
"mime/multipart"
"os"
"path/filepath"
"net/http"
"io"
)
func main() {
url := "https://direct.i-dgtl.ru/api/v1/sender-names"
method := "POST"
payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
mimeHeader1 := make(map[string][]string)
mimeHeader1["Content-Disposition"] = append(mimeHeader1["Content-Disposition"], "form-data; name=\"body\"")
mimeHeader1["Content-Type"] = append(mimeHeader1["Content-Type"], "application/json")
fieldWriter1, _ := writer.CreatePart(mimeHeader1)
fieldWriter1.Write([]byte("{\"channelType\": \"SMS\", \"commonType\": \"PROMO\", \"brand\": \"MTS\", \"dateFrom\": \"2026-06-01T21:00:00Z\", \"senderName\": \"test\", \"counteragentName\": \"Контрагент, ООО\", \"counteragentInn\": \"123451729124\"}"))
file, errFile2 := os.Open("/path/to/file")
defer file.Close()
part2,
errFile2 := writer.CreateFormFile("file1",filepath.Base("/path/to/file"))
_, errFile2 = io.Copy(part2, file)
if errFile2 != nil {
fmt.Println(errFile2)
return
}
file, errFile3 := os.Open("/path/to/file")
defer file.Close()
part3,
errFile3 := writer.CreateFormFile("file2",filepath.Base("/path/to/file"))
_, errFile3 = io.Copy(part3, file)
if errFile3 != nil {
fmt.Println(errFile3)
return
}
err := writer.Close()
if err != nil {
fmt.Println(err)
return
}
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Set("Content-Type", writer.FormDataContentType())
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}