Single textual message
This method allows you to send a single textual message to one destination address.
Resource
https://api.infobip.com/sms/2/text/single
Parameters
| Property name | Type | Description |
|---|---|---|
| from | string | Represents sender ID and it can be alphanumeric or numeric. Alphanumeric sender ID length should be between 3 and 11 characters (example: CompanyName). Numeric sender ID length should be between 3 and 14 characters. |
| to | array_string | Array of message destination addresses. If you want to send a message to one destination, a single String is supported instead of an Array. Destination addresses must be in international format (example: 41793026727). |
| text | string | Text of the message that will be sent. |
Request Example
POST /sms/2/text/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
"from":"InfoSMS",
"to":"41793026727",
"text":"Test SMS."
}
Response
{
"messages":[
{
"to":"41793026727",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 26,
"name": "PENDING_ACCEPTED",
"description": "Message sent to next instance"
},
"messageId": "2033247207850523790"
}
]
}
Long SMS:
The maximum length of one message is 160 characters for the GSM7 standard or 70 characters for Unicode encoded messages. If you send a text which exceeds the maximum number of supported characters, the sent message will be segmented and charged accordingly. One Long SMS that consists of two SMS counts as two SMS.
Response Format
If successful, the response header HTTP status code will be 200 OK and the message will be sent.
If you try to send a message without authorization, you will receive an error 401 Unauthorized.
Additionally you should also handle the 400 Bad request status. For more info on HTTP status handling see dedicated section in Integration best practices page.
SMS Response
| Parameter | Type | Description |
|---|---|---|
| bulkId | String | The ID that uniquely identifies the request. Bulk ID will be received only when you send a message to more than one destination address. |
| messages | SMSResponseDetails | Array of sent message objects, one object per every message. |
SMS Response Details
| Parameter | Type | Description |
|---|---|---|
| to | String | The message destination address. |
| status | Status | Indicates whether the message is successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status. |
| messageId | String | The ID that uniquely identifies the message sent. |
Status
| Parameter | Type | Description |
|---|---|---|
| groupId | int | Status group ID. |
| groupName | String | Status group name. |
| id | int | Status ID. |
| name | String | Status name. |
| description | String | Human-readable description of the status. |
| action | String | Action that should be taken to eliminate the error. |
SMS status
When sending SMS messages, Infobip API will first perform basic validation of the request. If validation passes API will return a response with a status from the PENDING group (group id 1) and continue processing of the SMS asynchronously. You can check the delivery status of your message using the Get delivery reports API endpoint. You can find a complete list of SMS statuses at Response status and error codes documentation page.
Additional examples
Single textual message to one destination
Request:
POST /sms/2/text/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
"from":"InfoSMS",
"to":"41793026727",
"text":"Test SMS."
}
POST /sms/2/text/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xml
Accept: application/xml
<request>
<from>InfoSMS</from>
<to>
<to>41793026727</to>
</to>
<text>Test SMS.</text>
</request>curl -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' \
-d '{
"from":"InfoSMS",
"to":"41793026727",
"text":"Test SMS."
}' https://api.infobip.com/sms/2/text/single<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.infobip.com/sms/2/text/single",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{ \"from\":\"InfoSMS\", \"to\":\"41793026727\", \"text\":\"Test SMS.\" }",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.infobip.com/sms/2/text/single")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["content-type"] = 'application/json'
request["accept"] = 'application/json'
request.body = "{\"from\":\"InfoSMS\",\"to\":\"41793026727\", \"text\":\"Test SMS.\"}"
response = http.request(request)
puts response.read_bodyconn = http.client.HTTPSConnection("api.infobip.com")
payload = "{\"from\":\"InfoSMS\",\"to\":\"41793026727\",\"text\":\"Test SMS.\"}"
headers = {
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'content-type': "application/json",
'accept': "application/json"
}
conn.request("POST", "/sms/2/text/single", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))HttpResponse<String> response = Unirest.post("https://api.infobip.com/sms/2/text/single")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("content-type", "application/json")
.header("accept", "application/json")
.body("{\"from\":\"InfoSMS\",\"to\":\"41793026727\",\"text\":\"Test SMS.\"}")
.asString();var client = new RestClient("https://api.infobip.com/sms/2/text/single");
var request = new RestRequest(Method.POST);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddParameter("application/json", "{\"from\":\"InfoSMS\", \"to\":\"41793026727\",\"text\":\"Test SMS.\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);var data = JSON.stringify({
"from": "InfoSMS",
"to": "41793026727",
"text": "Test SMS."
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.infobip.com/sms/2/text/single");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"messages":[
{
"to":"41793026727",
"status":{
"groupId":1,
"groupName":"PENDING",
"id":26,
"name":"MESSAGE_ACCEPTED",
"description":"Message sent to next instance"
},
"messageId":"2250be2d4219-3af1-78856-aabe-1362af1edfd2"
}
]
}
HTTP/1.1 200 OK
Content-Type: application/xml
<smsResponse>
<messages>
<message>
<to>41793026727</to>
<status>
<id>26</id>
<groupId>1</groupId>
<groupName>PENDING</groupName>
<name>PENDING_ACCEPTED</name>
<description>Message sent to next instance</description>
</status>
<messageId>2250be2d4219-3af1-78856-aabe-1362af1edfd2</messageId>
</message>
</messages>
</smsResponse>Single textual message to multiple destination
Request:
POST /sms/2/text/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
"from":"InfoSMS",
"to":[
"41793026727",
"41793026834"
],
"text":"Test SMS."
}
POST /sms/2/text/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xml
Accept: application/xml
<request>
<from>InfoSMS</from>
<to>
<to>41793026727</to>
<to>41793026834</to>
</to>
<text>Test SMS.</text>
</request>curl -X POST
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
-d '{
"from":"InfoSMS",
"to":[
"41793026727",
"41793026834"
],
"text":"Test SMS."
}' https://api.infobip.com/sms/2/text/single<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.infobip.com/sms/2/text/single",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{ \"from\":\"InfoSMS\", \"to\":[ \"41793026727\", \"41793026834\" ], \"text\":\"Test SMS.\" }",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.infobip.com/sms/2/text/single")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["content-type"] = 'application/json'
request["accept"] = 'application/json'
request.body = "{\"from\":\"InfoSMS\",\"to\":[\"41793026727\", \"41793026834\"],\"text\":\"Test SMS.\"}"
response = http.request(request)
puts response.read_bodyimport http.client
conn = http.client.HTTPSConnection("api.infobip.com")
payload = "{\"from\":\"InfoSMS\",\"to\":[\"41793026727\", \"41793026834\"],\"text\":\"Test SMS.\"}"
headers = {
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'content-type': "application/json",
'accept': "application/json"
}
conn.request("POST", "/sms/2/text/single", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))HttpResponse<String> response = Unirest.post("https://api.infobip.com/sms/2/text/single")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("content-type", "application/json")
.header("accept", "application/json")
.body("{\"from\":\"InfoSMS\",\"to\":[\"41793026727\", \"41793026834\"],\"text\":\"Test SMS.\"}")
.asString();var client = new RestClient("https://api.infobip.com/sms/2/text/single");
var request = new RestRequest(Method.POST);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddParameter("application/json", "{\"from\":\"InfoSMS\", \"to\":[ \"41793026727\",\"41793026834\"],\"text\":\"Test SMS.\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);var data = JSON.stringify({
"from": "InfoSMS",
"to": [
"41793026727",
"41793026834"
],
"text": "Test SMS."
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.infobip.com/sms/2/text/single");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"bulkId":"f5c4322c-10e7-a41e-5528-34fa0b032134",
"messages":[
{
"to":"41793026727",
"status":{
"groupId":1,
"groupName":"PENDING",
"id":26,
"name":"PENDING_ACCEPTED",
"description":"Message sent to next instance"
},
"messageId":"2033247207850523791"
},
{
"to":"41793026834",
"status":{
"groupId":1,
"groupName":"PENDING",
"id":26,
"name":"PENDING_ACCEPTED",
"description":"Message sent to next instance"
},
"messageId":"2033247207850523792"
}
]
}
HTTP/1.1 200 OK
Content-Type: application/xml
<smsResponse>
<bulkId>f5c4322c-10e7-a41e-5528-34fa0b032134</bulkId>
<messages>
<message>
<to>41793026727</to>
<status>
<id>26</id>
<groupId>1</groupId>
<groupName>PENDING</groupName>
<name>PENDING_ACCEPTED</name>
<description>Message sent to next instance</description>
</status>
<messageId>2033247207850523791</messageId>
</message>
<message>
<to>41793026834</to>
<status>
<id>26</id>
<groupId>1</groupId>
<groupName>PENDING</groupName>
<name>PENDING_ACCEPTED</name>
<description>Message sent to next instance</description>
</status>
<messageId>2033247207850523792</messageId>
</message>
</messages>
</smsResponse>
V1 documentation
Documentation for the previous version of API endpoint, still available at /sms/1/text/single, can be found here.