Comment on page
SMS API
SMS API DecisionTelecom дозволяє надсилати SMS-повідомлення до будь-якої країни світу через API. Кожне повідомлення ідентифікується унікальним випадковим ідентифікатором, тому користувачі можуть перевірити статус повідомлення, використовуючи задану кінцеву точку.
SMS API використовує HTTPS з ключем доступу, який використовується як авторизація API. Корисні дані запитів та відповідей форматуються як JSON за допомогою кодування UTF-8 та значень у кодуванні URL.
API Авторизація - Базовий ключ доступу Base64.
Щоб отримати ключ API, будь ласка, зв'яжіться з вашим менеджером по роботі з клієнтами.
POST
https://web.it-decision.com/v1/api/send-sms
{
"phone":380632132121,
"sender":"InfoItd",
"text":"This is messages DecisionTelecom",
"validity_period":120
}
{
"message_data": [
{
"message_id": 26348338,
"phone": 380632132122,
"part_count": 1,
"concat_part": 1,
"status": "ACCEPTD"
}
]
}
GET
https://web.it-decision.com/v1/api/status?message_id=234234234
{
"message_id": 26348265,
"status": "DELIVRD"
}
message_id: int - A unique random ID which is created on the DecisionTelecom platform.
Phone: int - The telephone number that you want to do a network query on. - Required.
Text: string – sms message text
validity_period: int - SMS lifetime in minutes (min 1 minute, max 4320)
sender: string - The sender of the message, the maximum length is 11 characters
part_count: int - amount of messages
concat_part: int - Number of pieces of the message
status: string - possible sms status
Possible values of status:
DELIVRD, UNDELIV, ACCEPTD, EXPIRED, REJECTD, ENROUTE, DELETED, UNKNOWN
PHP
GO
Java
С#
JavaScript
NODE
Python
RUBY
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'web.it-decision.com/v1/api/send-sms',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"phone":380632132121,"sender":"InfoItd","text":"This is messages DecisionTelecom","validity_period":300}',
CURLOPT_HTTPHEADER => array(
'Authorization: Basic api_key',
'Content-Type: application/json',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "web.it-decision.com/v1/api/send-sms"
method := "POST"
payload := strings.NewReader(`{"phone":380632132121,"sender":"InfoItd","text":"This is messages DecisionTelecom","validity_period":300}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "Basic api_key")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"phone\":380632132121,\"sender\":\"InfoItd\",\"text\":\"This is messages DecisionTelecom\",\"validity_period\":300}");
Request request = new Request.Builder()
.url("web.it-decision.com/v1/api/send-sms")
.method("POST", body)
.addHeader("Authorization", "Basic api_key")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("web.it-decision.com/v1/api/send-sms");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic api_key");
request.AddHeader("Content-Type", "application/json");
var body = @"{""phone"":380632132121,""sender"":""InfoItd"",""text"":""This is messages DecisionTelecom"",""validity_period"":300}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic api_key");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"phone": 380632132121,
"sender": "InfoItd",
"text": "This is messages DecisionTelecom",
"validity_period": 300
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("web.it-decision.com/v1/api/send-sms", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var axios = require('axios');
var data = JSON.stringify({
"phone": 380632132121,
"sender": "InfoItd",
"text": "This is messages DecisionTelecom",
"validity_period": 300
});
var config = {
method: 'post',
url: 'web.it-decision.com/v1/api/send-sms',
headers: {
'Authorization': 'Basic api_key',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
})
import http.client
import json
conn = http.client.HTTPSConnection("web.it-decision.com")
payload = json.dumps({
"phone": 380632132121,
"sender": "InfoItd",
"text": "This is messages DecisionTelecom",
"validity_period": 300
})
headers = {
'Authorization': 'Basic api_key',
'Content-Type': 'application/json'
}
conn.request("POST", "/v1/api/send-sms", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "json"
require "net/http"
url = URI("web.it-decision.com/v1/api/send-sms")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Basic api_key"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"phone": 380632132121,
"sender": "InfoItd",
"text": "This is messages DecisionTelecom",
"validity_period": 300
})
response = http.request(request)
puts response.read_body
SMS Callbacks
You can create analytics on your SMS traffic by using event-based webhooks — user-defined HTTP callbacks — to track the delivery status of outgoing messages.
For every SMS message you send, IT-Decision Telecom sends a status update to a URL you configure as a callback. You can store the information on your server for delivery status analysis. Upon one of these events, IT-Decision Telecom makes an HTTP request (POST) to an endpoint URL you’ve configured for the webhook. To handle a webhook, you must create a listener (web app) that can accept these HTTP requests from IT-Decision Telecom. IT-Decision Telecom automatically retries webhooks three times if an HTTP 200 status code is not returned:
Interval - 15 minutes, 12 hours , 1 day, If your URL is not available for the whole retry period, the data will be lost (Delivery Reports).
1. Send method Post client Url callback
http://client.com/callback
Json:
[
{
"message_id": "26381482",
"time_delivery": "2022-05-27 12:31:25",
"phone": "380632132122",
"status": "2",
"part_count": "1",
"concat_part": "1"
},
{
"message_id": "26381475",
"time_delivery": "2022-05-27 07:17:44",
"phone": "380631211121",
"status": "2",
"part_count": "1",
"concat_part": "1"
},
{
"message_id": "26381473",
"time_delivery": "2022-05-27 07:04:15",
"phone": "380631111111",
"status": "2",
"part_count": "1",
"concat_part": "1"
}
]
Params:
phone: - The telephone number that you want to do a network query on. - Required.
Time_delivery - SMS delivery time format DATETIME (utc + 0)
part_count: - amount of messages
concat_part: - Number of pieces of the message
status: - possible sms status
ENROUTE = 1;
DELIVERED = 2;
EXPIRED = 3;
DELETED = 4;
UNDELIVERABLE = 5;
ACCEPTED = 6;
UNKNOWN = 7;
REJECTED = 8;
HTTP Authorization - Basic access key Base64
1. POST REQUEST json string
https://web.it-decision.com/v1/api/multiple-message
{
"phones": [380631111112, 380636151111],
"sender": "info",
"text": "when the text is more than 160 characters, the SMS is divided into several parts",
"validity_period": 300
}
[
[
{
"message_id": 26381268,
"phone": 380631111112,
"part_count": 2,
"concat_part": 1,
"status": "ACCEPTD"
},
{
"message_id": 26381269,
"phone": 380631111112,
"part_count": 2,
"concat_part": 2,
"status": "ACCEPTD"
}
],
[
{
"message_id": 26381270,
"phone": 380636151111,
"part_count": 2,
"concat_part": 1,
"status": "ACCEPTD"
},
{
"message_id": 26381271,
"phone": 380636151111,
"part_count": 2,
"concat_part": 2,
"status": "ACCEPTD"
}
]
]
message_id int A unique random ID which is created on the DecisionTelecom platform.
Phones array The telephone number that you want to do a network query on.
sender string The sender of the message. This can be a mobile phone number (including a country code) or an alphanumeric string. The maximum length of alphanumeric strings is 11 characters.
text string Each multi-part text message is limited to 153 characters rather than 160 due to the need for user-data headers (UDHs) information.( 306 (2x153 characters) ,459 characters (3 x 153)…)
Mobile phones use UDH information to enable them to link long messages together so that they appear as single SMS messages in recipient’s phone inbox. Using Unicode, for languages such as Hindi, restricts your message to a maximum of 70 characters per SMS .
The maximum lengths of two-part and three-part multi-part Unicode text messages are 134 (2 x 67) and 201 (3 x 67) characters, respectively.
part_count int Count of parts
concat_part int Part number
validity_period int SMS lifetime min 2 minute max 4320
CURL
Golang
C#
JAVA
JavaScript
C lib CURL
NodJs
PHP
Python
curl --location --request POST 'https://web.it-decision.com/v1/api/multiple-message' \
--header 'Authorization: api key base64' \
--header 'Content-Type: application/json' \
--data-raw '{"phones":[380631111112,380636151111],"sender":"info","text":"when the text is more than 160 characters, the SMS is divided into several parts","validity_period":300}'
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://web.it-decision.com/v1/api/multiple-message"
method := "POST"
payload := strings.NewReader(`{"phones":[380631111112,380636151111],"sender":"info","text":"when the text is more than 160 characters, the SMS is divided into several parts","validity_period":300}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "Basic api key base64")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
var client = new RestClient("https://web.it-decision.com/v1/api/multiple-message");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic api key");
request.AddHeader("Content-Type", "application/json");
var body = @"{""phones"":[380631111112,380636151111],""sender"":""info"",""text"":""when the text is more than 160 characters, the SMS is divided into several parts"",""validity_period"":300}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"phones\":[380631111112,380636151111],\"sender\":\"info\",\"text\":\"when the text is more than 160 characters, the SMS is divided into several parts\",\"validity_period\":300}");
Request request = new Request.Builder()
.url("https://web.it-decision.com/v1/api/multiple-message")
.method("POST", body)
.addHeader("Authorization", "Basic api key")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic api key");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"phones": [
380631111112,
380636151111
],
"sender": "info",
"text": "when the text is more than 160 characters, the SMS is divided into several parts",
"validity_period": 300
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://web.it-decision.com/v1/api/multiple-message", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));