Эта документация описывает актуальную версию SMS API для личного кабинета
lk.plusofon.ru
.Если адрес Вашего кабинета
portal.plusofon.ru
илиnew-portal.plusofon.ru
то, пожалуйста, используйтедокументацию по архивной версии SMS API
.
Группа методов позволяет обмениваться SMS-сообщениями, получать информацию и управлять пакетами SMS.
Метод позволяет отправить SMS-сообщение.
POST
api/v1/sms
https://restapi.plusofon.ru
number_id
integer
ИД номера-отправителя
dlr_level
integer
уровень обработки отчёта о доставке (DLR)
reject_long
boolean
признак запрета отправки SMS, превышающего максимальную длину (по умолчанию — отправлять, false
)
count_pdu
boolean
признак необходимости в ответе количества сегментов сообщения
возможные варианты параметра
dlr_level
:
1
статус доставки сообщения от вышестоящего SMSC (SMS-центра)
2
статус доставки сообщения конечному получателю (абонентскому устройству)
3
…
curl -X POST \
"https://restapi.plusofon.ru/api/v1/sms" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"text":"mollitia","number_id":2,"to":241.77791,"dlr_level":18,"reject_long":true,"count_pdu":true}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/sms"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"text": "mollitia",
"number_id": 2,
"to": 241.77791,
"dlr_level": 18,
"reject_long": true,
"count_pdu": true
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->post(
'https://restapi.plusofon.ru/api/v1/sms',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'text' => 'mollitia',
'number_id' => 2,
'to' => 241.77791,
'dlr_level' => 18,
'reject_long' => true,
'count_pdu' => true,
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/sms'
payload = {
"text": "mollitia",
"number_id": 2,
"to": 241.77791,
"dlr_level": 18,
"reject_long": true,
"count_pdu": true
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('POST', url, headers=headers, json=payload)
response.json()
В ответе могут возвращаться следующие поля:
success
признак успешно выполненного запроса
message
сообщение об ошибке
{
"success": true
}
Метод позволяет просмотреть список SMS-сообщений.
GET
api/v1/sms
https://restapi.plusofon.ru
date_from
date
фильтр по дате начала
date_to
date
фильтр по дате окончания
incoming
integer
фильтр по признаку входящего сообщения
receiver
string
фильтр по номеру-получателю
sender
string
фильтр по номеру-отправителю
limit
integer
лимит записей в ответе
возможные варианты параметра
incoming
:
1
входящее сообщение
0
исходящее сообщение
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/sms" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"date_from":"alias","date_to":"natus","incoming":3,"receiver":"facere","sender":"rem","limit":18}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/sms"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"date_from": "alias",
"date_to": "natus",
"incoming": 3,
"receiver": "facere",
"sender": "rem",
"limit": 18
}
fetch(url, {
method: "GET",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->get(
'https://restapi.plusofon.ru/api/v1/sms',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'date_from' => 'alias',
'date_to' => 'natus',
'incoming' => 3,
'receiver' => 'facere',
'sender' => 'rem',
'limit' => 18,
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/sms'
payload = {
"date_from": "alias",
"date_to": "natus",
"incoming": 3,
"receiver": "facere",
"sender": "rem",
"limit": 18
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers, json=payload)
response.json()
В ответе возвращается массив data
:
created_datetime
дата создания сообщения
sent_datetime
дата отправки сообщения
sender
номер-отправитель
receiver
номер-получатель
msg
текст сообщения
incoming
признак входящего сообщения
pdu
количество сегментов сообщения
возможные варианты поля
incoming
:
1
входящее сообщение
0
исходящее сообщение
{
"current_page": 1,
"data": [
{
"created_datetime": "2022-07-25 12:59:19",
"sent_datetime": "2022-07-25 12:59:21",
"sender": "79309993750",
"receiver": "79157255057",
"msg": "test1",
"incoming": 0,
"pdu": 1
},
{
"created_datetime": "2022-07-25 13:01:34",
"sent_datetime": "2022-07-25 13:01:36",
"sender": "79309993750",
"receiver": "79157255057",
"msg": "test2",
"incoming": 0,
"pdu": 1
}
],
"first_page_url": "http:\/\/localhost\/api\/v1\/sms?page=1",
"from": 1,
"next_page_url": null,
"path": "http:\/\/localhost\/api\/v1\/sms",
"per_page": 15,
"prev_page_url": null,
"to": 2
}
Метод позволяет получить список диалогов.
GET
api/v1/sms/dialog
https://restapi.plusofon.ru
date_from
date
фильтр по дате начала
date_to
date
фильтр по дате окончания
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/sms/dialog" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"date_from":"doloremque","date_to":"aperiam"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/sms/dialog"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"date_from": "doloremque",
"date_to": "aperiam"
}
fetch(url, {
method: "GET",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->get(
'https://restapi.plusofon.ru/api/v1/sms/dialog',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'date_from' => 'doloremque',
'date_to' => 'aperiam',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/sms/dialog'
payload = {
"date_from": "doloremque",
"date_to": "aperiam"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers, json=payload)
response.json()
В ответе возвращается массив data
:
id
ИД сообщения
sender
номер-отправитель
receiver
номер-получатель
sent_datetime
дата отправки сообщения
created_datetime
дата создания сообщения
msg
текст сообщения
incoming
признак входящего сообщения
readed
признак прочитанности сообщения
interlocutor_number
номер собеседника, по которому определяется диалог
возможные варианты поля
incoming
:
1
входящее сообщение
0
исходящее сообщение
возможные варианты поля
readed
:
1
сообщение прочитано
0
сообщение не прочитано
{
"data": [
{
"id": 15,
"sender": "79993332210",
"receiver": "79993332211",
"sent_datetime": "2022-08-26 10:27:10",
"created_datetime": "2022-08-26 10:27:10",
"msg": "Тест 2",
"incoming": 0,
"readed": 0,
"interlocutor_number": "79993332211"
},
{
"id": 114258467,
"sender": "79993332210",
"receiver": "79993332212",
"sent_datetime": "2022-08-17 15:23:29",
"created_datetime": "2022-08-17 15:23:27",
"msg": "Тест 1",
"incoming": 0,
"readed": 0,
"interlocutor_number": "79993332212"
}
],
"success": true
}
Метод позволяет активировать пакет SMS-сообщений.
PATCH
api/v1/sms/packets
https://restapi.plusofon.ru
curl -X PATCH \
"https://restapi.plusofon.ru/api/v1/sms/packets" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"number_id":16,"packet":"ut"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/sms/packets"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"number_id": 16,
"packet": "ut"
}
fetch(url, {
method: "PATCH",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->patch(
'https://restapi.plusofon.ru/api/v1/sms/packets',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'number_id' => 16,
'packet' => 'ut',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/sms/packets'
payload = {
"number_id": 16,
"packet": "ut"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('PATCH', url, headers=headers, json=payload)
response.json()
В ответе могут возвращаться следующие поля:
success
признак успешно выполненного запроса
message
сообщение об ошибке
{
"success": true
}
Метод позволяет получить список всех доступных пакетов SMS-сообщений.
GET
api/v1/sms/packets
https://restapi.plusofon.ru
Метод не имеет параметров.
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/sms/packets" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}"
const url = new URL(
"https://restapi.plusofon.ru/api/v1/sms/packets"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->get(
'https://restapi.plusofon.ru/api/v1/sms/packets',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/sms/packets'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers)
response.json()
В ответе возвращается массив packets
, содержащий следующие данные:
id
ИД пакета
name
название пакета
description
описание
price
абонентская плата
sms_count
количество SMS в пакете
{
"packets": [
{
"id": "401f6fbc-87db-0df2-6ccf-624161f2c7e3",
"name": "Пакет SMS 0",
"description": "Пакет активирует отправку и прием SMS. ",
"price": 0,
"sms_count": 0
},
{
"id": "8ccddfe2-2a7b-bb2a-40f8-624161d3f93a",
"name": "Пакет SMS 50",
"description": "Пакет на 50 SMS в месяц",
"price": 30,
"sms_count": 50
},
{
"id": "16fade6a-1232-d42f-6012-624162c4c018",
"name": "Пакет SMS 1000",
"description": "Пакет на 1000 SMS в месяц",
"price": 600,
"sms_count": 1000
}
],
"success": true
}
Метод позволяет указать для конкретного номера URL-адрес обработчика входящих SMS, на который будут приходить вебхуки (POST-запросы) с SMS-сообщениями.
POST
api/v1/sms/url
https://restapi.plusofon.ru
curl -X POST \
"https://restapi.plusofon.ru/api/v1/sms/url" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"number":"velit","url":"et"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/sms/url"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"number": "velit",
"url": "et"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->post(
'https://restapi.plusofon.ru/api/v1/sms/url',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'number' => 'velit',
'url' => 'et',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/sms/url'
payload = {
"number": "velit",
"url": "et"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('POST', url, headers=headers, json=payload)
response.json()
В ответе могут возвращаться следующие поля:
success
признак успешно выполненного запроса
message
сообщение об ошибке
{
"success": true
}
Метод позволяет удалить для всех номеров (или для конкретного номера) URL-адрес обработчика входящих SMS.
DELETE
api/v1/sms/url
https://restapi.plusofon.ru
curl -X DELETE \
"https://restapi.plusofon.ru/api/v1/sms/url" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"number":"aperiam","url":"ipsam"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/sms/url"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"number": "aperiam",
"url": "ipsam"
}
fetch(url, {
method: "DELETE",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->delete(
'https://restapi.plusofon.ru/api/v1/sms/url',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'number' => 'aperiam',
'url' => 'ipsam',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/sms/url'
payload = {
"number": "aperiam",
"url": "ipsam"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('DELETE', url, headers=headers, json=payload)
response.json()
В ответе могут возвращаться следующие поля:
success
признак успешно выполненного запроса
message
сообщение об ошибке
{
"success": true
}
Метод позволяет указать URL-адрес обработчика отчётов о доставке (DLR), на который будут приходить вебхуки (POST-запросы) с телом в формате JSON и типом контента «application/json».
PUT
api/v1/sms/dlr-url
https://restapi.plusofon.ru
curl -X PUT \
"https://restapi.plusofon.ru/api/v1/sms/dlr-url" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"url":"iusto"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/sms/dlr-url"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"url": "iusto"
}
fetch(url, {
method: "PUT",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->put(
'https://restapi.plusofon.ru/api/v1/sms/dlr-url',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'url' => 'iusto',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/sms/dlr-url'
payload = {
"url": "iusto"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('PUT', url, headers=headers, json=payload)
response.json()
В ответе могут возвращаться следующие поля:
success
признак успешно выполненного запроса
message
сообщение об ошибке
{
"success": true
}