Single textual message

This method allows you to send a single textual message to one destination address.

Resource

https://api.infobip.com/sms/1/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/1/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": 7,
           "name": "PENDING_ENROUTE",
           "description": "Message sent to next instance"
         },
         "smsCount":1,
         "messageId": "2033247207850523790"
      }
   ]
}
					
				

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 message without authorization, you will receive an error 401 Unauthorized.

SMSResponse

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.

SMSResponseDetails

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.
smsCount int The number of sent message segments.
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.

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.

Additional examples

Single textual message to one destination

Request:

POST /sms/1/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/1/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/1/text/single
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://api.infobip.com/sms/1/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/1/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_body
conn = 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/1/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/1/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/1/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/1/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":0,
            "groupName":"Queue/Accepted",
            "id":0,
            "name":"MESSAGE_ACCEPTED",
            "description":"Message accepted"
         },
         "smsCount":1,
         "messageId":"2250be2d4219-3af1-78856-aabe-1362af1edfd2"
      }
   ]
}
HTTP/1.1 200 OK
Content-Type: application/xml

<smsResponse>
   <messages>
      <message>
         <to>41793026727</to>
         <status>
            <id>0</id>
            <groupId>0</groupId>
            <groupName>ACCEPTED</groupName>
            <name>MESSAGE_ACCEPTED</name>
            <description>Message accepted</description>
         </status>
         <smsCount>1</smsCount>
         <messageId>2250be2d4219-3af1-78856-aabe-1362af1edfd2</messageId>
      </message>
   </messages>
</smsResponse>

Single textual message to multiple destinations

Request:

POST /sms/1/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/1/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/1/text/single
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://api.infobip.com/sms/1/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/1/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_body
import 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/1/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/1/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/1/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/1/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":0,
            "groupName":"ACCEPTED",
            "id":0,
            "name":"MESSAGE_ACCEPTED",
            "description":"Message accepted"
         },
         "smsCount":1,
         "messageId":"4a54f0242f19-b832-1c39-a7e7a2095f351ed2"
      },
      {  
         "to":"41793026834",
         "status":{  
            "groupId":0,
            "groupName":"ACCEPTED",
            "id":0,
            "name":"MESSAGE_ACCEPTED",
            "description":"Message accepted"
         },
         "smsCount":1,
         "messageId":"9404a69cef19-7a31-ba39-92ace76a5f351ed2"
      }
   ]
}
HTTP/1.1 200 OK
Content-Type: application/xml

<smsResponse>
   <bulkId>f5c4322c-10e7-a41e-5528-34fa0b032134</bulkId>
   <messages>
      <message>
         <to>41793026727</to>
         <status>
            <id>0</id>
            <groupId>0</groupId>
            <groupName>ACCEPTED</groupName>
            <name>MESSAGE_ACCEPTED</name>
            <description>Message accepted</description>
         </status>
         <smsCount>1</smsCount>
         <messageId>2250be2d4219-3af1-78856-aabe-1362af1edfd2</messageId>
      </message>
      <message>
         <to>41793026834</to>
         <status>
            <id>0</id>
            <groupId>0</groupId>
            <groupName>ACCEPTED</groupName>
            <name>MESSAGE_ACCEPTED</name>
            <description>Message accepted</description>
         </status>
         <smsCount>1</smsCount>
         <messageId>9404a69cef19-7a31-ba39-92ace76a5f351ed2</messageId>
      </message>
   </messages>
</smsResponse>