Многоканальная доставка сообщений
Данный API позволяет совершать многоканальную доставку сообщений с возможностью выбора каналов и установки приоритетов. Пользователи указывают желаемые каналы связи и последовательность в параметре конвейера, включая такие опции, как голосовые звонки, Telegram, Viber и SMS. Telegram можно использовать только для доставки одноразового пароля (OTP), тогда как голосовые звонки рекомендуется использовать только для OTP. SMS и Viber подходят как для OTP, так и для транзакционных сообщений. Параметры каждого канала, такие как содержимое сообщения, настройки голоса или подпись, можно настроить, чтобы адаптировать сообщения до его цели и получателей.
URI: https://alphasms.ua/api/json.php
Все запросы к API отправляются в формате JSON с помощью метода POST.
Параметры заголовков
В запросах обязательно должен быть заголовок Content-Type: application/json, иначе запрос будет считаться некорректным даже при валидном JSON в нем
Параметры запроса
Пример запроса
- Sync
- Async
- JSON
- cURL
- PHP
- Python
- Node.js
{
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"voice",
"telegram",
"viber",
"rcs",
"sms"
],
"id": 100500,
"phone": 380971234567,
"voice": {
"message": "Your code is 100500",
"voice": {
"gender": "female",
"language": "ru-RU",
"name": "ru-RU-Standard-A"
},
"dtmf": false
},
"telegram": {
"message": "100500"
},
"viber": {
"type": "text",
"signature": "SenderID",
"message": "Your code is 100500"
},
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"rcs": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"sms": {
"signature": "SenderID",
"message": "Your code is 100500"
},
"hook": "https://example.org/webhook/url.php"
}
]
}
curl -X POST 'https://alphasms.ua/api/json.php' \
-H 'Content-Type: application/json' \
--data-raw '{
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"voice",
"telegram",
"viber",
"rcs",
"sms"
],
"id": 100500,
"phone": 380971234567,
"voice": {
"message": "Your code is 100500",
"voice": {
"gender": "female",
"language": "ru-RU",
"name": "ru-RU-Standard-A"
},
"dtmf": false
},
"telegram": {
"message": "100500"
},
"viber": {
"type": "text",
"signature": "SenderID",
"message": "Your code is 100500"
},
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"rcs": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"sms": {
"signature": "SenderID",
"message": "Your code is 100500"
},
"hook": "https://example.org/webhook/url.php"
}
]
}'
<?php
$payload = json_encode([
'auth' => 'bb56a4369eb19***cfec6d1776bd25',
'data' => [
[
'type' => 'pipeline',
'pipeline' => [
'voice',
'telegram',
'viber',
'rcs',
'sms',
],
'id' => 100500,
'phone' => 380971234567,
'voice' => [
'message' => 'Your code is 100500',
'voice' => [
'gender' => 'female',
'language' => 'ru-RU',
'name' => 'ru-RU-Standard-A',
],
'dtmf' => false,
],
'telegram' => [
'message' => '100500',
],
'viber' => [
'type' => 'text',
'signature' => 'SenderID',
'message' => 'Your code is 100500',
],
'whatsapp' => [
'signature' => 'SenderID',
'message' => 'Your code is 1234',
],
'rcs' => [
'signature' => 'SenderID',
'message' => 'Your code is 1234',
],
'sms' => [
'signature' => 'SenderID',
'message' => 'Your code is 100500',
],
'hook' => 'https://example.org/webhook/url.php',
],
],
], JSON_UNESCAPED_UNICODE);
$ch = curl_init('https://alphasms.ua/api/json.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import requests
payload = {
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"voice",
"telegram",
"viber",
"rcs",
"sms",
],
"id": 100500,
"phone": 380971234567,
"voice": {
"message": "Your code is 100500",
"voice": {
"gender": "female",
"language": "ru-RU",
"name": "ru-RU-Standard-A",
},
"dtmf": False,
},
"telegram": {
"message": "100500",
},
"viber": {
"type": "text",
"signature": "SenderID",
"message": "Your code is 100500",
},
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234",
},
"rcs": {
"signature": "SenderID",
"message": "Your code is 1234",
},
"sms": {
"signature": "SenderID",
"message": "Your code is 100500",
},
"hook": "https://example.org/webhook/url.php",
},
],
}
response = requests.post(
"https://alphasms.ua/api/json.php",
json=payload,
timeout=30,
)
print(response.json())
const payload = {
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"voice",
"telegram",
"viber",
"rcs",
"sms"
],
"id": 100500,
"phone": 380971234567,
"voice": {
"message": "Your code is 100500",
"voice": {
"gender": "female",
"language": "ru-RU",
"name": "ru-RU-Standard-A"
},
"dtmf": false
},
"telegram": {
"message": "100500"
},
"viber": {
"type": "text",
"signature": "SenderID",
"message": "Your code is 100500"
},
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"rcs": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"sms": {
"signature": "SenderID",
"message": "Your code is 100500"
},
"hook": "https://example.org/webhook/url.php"
}
]
};
const response = await fetch("https://alphasms.ua/api/json.php", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
console.log(await response.json());
- JSON
- cURL
- PHP
- Python
- Node.js
{
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"voice",
"telegram",
"viber",
"rcs",
"sms"
],
"id": 100500,
"phone": 380971234567,
"voice": {
"message": "Your code is 100500",
"voice": {
"gender": "female",
"language": "ru-RU",
"name": "ru-RU-Standard-A"
},
"dtmf": false
},
"telegram": {
"message": "100500"
},
"viber": {
"type": "text",
"signature": "SenderID",
"message": "Your code is 100500"
},
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"rcs": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"sms": {
"signature": "SenderID",
"message": "Your code is 100500"
},
"hook": "https://example.org/webhook/url.php"
}
]
}
curl -X POST 'https://api-async.alphasms.ua/v1/json' \
-H 'Content-Type: application/json' \
--data-raw '{
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"voice",
"telegram",
"viber",
"rcs",
"sms"
],
"id": 100500,
"phone": 380971234567,
"voice": {
"message": "Your code is 100500",
"voice": {
"gender": "female",
"language": "ru-RU",
"name": "ru-RU-Standard-A"
},
"dtmf": false
},
"telegram": {
"message": "100500"
},
"viber": {
"type": "text",
"signature": "SenderID",
"message": "Your code is 100500"
},
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"rcs": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"sms": {
"signature": "SenderID",
"message": "Your code is 100500"
},
"hook": "https://example.org/webhook/url.php"
}
]
}'
<?php
$payload = json_encode([
'auth' => 'bb56a4369eb19***cfec6d1776bd25',
'data' => [
[
'type' => 'pipeline',
'pipeline' => [
'voice',
'telegram',
'viber',
'rcs',
'sms',
],
'id' => 100500,
'phone' => 380971234567,
'voice' => [
'message' => 'Your code is 100500',
'voice' => [
'gender' => 'female',
'language' => 'ru-RU',
'name' => 'ru-RU-Standard-A',
],
'dtmf' => false,
],
'telegram' => [
'message' => '100500',
],
'viber' => [
'type' => 'text',
'signature' => 'SenderID',
'message' => 'Your code is 100500',
],
'whatsapp' => [
'signature' => 'SenderID',
'message' => 'Your code is 1234',
],
'rcs' => [
'signature' => 'SenderID',
'message' => 'Your code is 1234',
],
'sms' => [
'signature' => 'SenderID',
'message' => 'Your code is 100500',
],
'hook' => 'https://example.org/webhook/url.php',
],
],
], JSON_UNESCAPED_UNICODE);
$ch = curl_init('https://api-async.alphasms.ua/v1/json');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import requests
payload = {
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"voice",
"telegram",
"viber",
"rcs",
"sms",
],
"id": 100500,
"phone": 380971234567,
"voice": {
"message": "Your code is 100500",
"voice": {
"gender": "female",
"language": "ru-RU",
"name": "ru-RU-Standard-A",
},
"dtmf": False,
},
"telegram": {
"message": "100500",
},
"viber": {
"type": "text",
"signature": "SenderID",
"message": "Your code is 100500",
},
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234",
},
"rcs": {
"signature": "SenderID",
"message": "Your code is 1234",
},
"sms": {
"signature": "SenderID",
"message": "Your code is 100500",
},
"hook": "https://example.org/webhook/url.php",
},
],
}
response = requests.post(
"https://api-async.alphasms.ua/v1/json",
json=payload,
timeout=30,
)
print(response.json())
const payload = {
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"voice",
"telegram",
"viber",
"rcs",
"sms"
],
"id": 100500,
"phone": 380971234567,
"voice": {
"message": "Your code is 100500",
"voice": {
"gender": "female",
"language": "ru-RU",
"name": "ru-RU-Standard-A"
},
"dtmf": false
},
"telegram": {
"message": "100500"
},
"viber": {
"type": "text",
"signature": "SenderID",
"message": "Your code is 100500"
},
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"rcs": {
"signature": "SenderID",
"message": "Your code is 1234"
},
"sms": {
"signature": "SenderID",
"message": "Your code is 100500"
},
"hook": "https://example.org/webhook/url.php"
}
]
};
const response = await fetch("https://api-async.alphasms.ua/v1/json", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
console.log(await response.json());
Параметры ответа
| successinteger Результат выполнения запроса | |||||||
| errorstring Текст ошибки, который возвращается, если success=false | |||||||
| datalist[object] Список объектов с результатами выполнения запроса
|
Примеры ответа
- Успешный
- Доступ запрещен
- Ошибка в Альфа-имени
HTTP Status Code: 200
Content Type: JSON application/json
{
"success": true,
"data": [
{
"success": true,
"data": {
"id": 100500,
"msg_id": 123456789,
"data": 1,
"parts": 1
}
}
]
}
HTTP Status Code: 200
Content Type: JSON application/json
{
"success": false,
"error": "Access denied"
}
HTTP Status Code: 200
Content Type: JSON application/json
{
"success": true,
"data": [
{
"success": false,
"error": "Error in Alpha-name",
"data": {
"id": 100500
}
}
]
}