SMS Send RESTful API
Author Image

By: Aivis Olsteins

In News

2018-11-01

Using RESTful API to send text messages

Discussing practical implementation of letting your clients send text messages via your own RESTful API

Sending text messages is one of the most recent features added to SAARA system. It supports several ways to deliver Mobile Terminated (MT) messages to the end client:

  1. Most simplest way is to open a web interface on SAARA server, login as end user and send SMS from there. It is simple and handy for one off sending of one or few messages. It is not suitable for server-to-server connection or automated message delivery.
  2. SMPP protocol is industry standard for text message sending between Message Entities (ESMEs) and Mesage Centers. However, it requries implementation of SMPP which is not always straigh forward and easy.
  3. RESTful APIs are a popular method for machine-to-machine communication, and can be implemented much easier, since there are plenty of free and commercial suftware packages, libraries and tools which implement or support this functionality.

Here we will discuss the latter method. The step by stepo guide of how to set up SAARA system for MT message sending can be found at this link, and more specifically, the guide how to set up API support for SMS sending is located here.

The API is implemented with following API call:

POST /sms/send 

{
  "to": "1234567890",
  "from": "9876543210",
  "content": "Hello, world!"
}

The above request sends text mesage "Hello, world" to phone number 1234567890 and the sender ID displayed on the recipients screen will be 987654321

The API will respond with confirmation where the body will contain message like:

{
  "code": 0,
  "status": 200,
  "data": "accepted",
  "request_id": "29737936-96c9-496f-aa13-1cd3a4544417"
}

Note, there is request_id attribute in response. It can be used in further requests to obtain status of the message delivery and billing data if necessary.

API client can be implemented in many languages. The quickest way, without actually writing any line of code is either via browser addons, like RESTClient add-on for Mozilla Firefox or Advanced REST Client for Google Chrome. Other way is to use curl, Linux CLI tool:

curl -X POST -H 'Authorization: token U51U9KhRl0t53n9W' -i 'http://server.address/api/sms/send' --data '{
    "to": "1234567890",
    "from":"9876543210",
    "content":"Hello world!"
}'

 

About Author
Author Image

With more than 25 years in the industry, Aivis Olsteins is founder of DataTechLabs, and has been involved in every aspect of the company through its development. He has large expertise in telecom networks, databases, large data processing and other advanced technical topics.

Get in Touch

If you have something to say, please use the contact form below to get in touch with us. We will get back to you as soon as possible.

Mail Us

DataTechLabs SIA, Muzikas str 12A
Jurmala, LV-2008, Latvia.

Call Us

+371 67 65 25 28
+ 1 202 499 1550

E-mail Us

info@datatechlabs.com
support@datatechlabs.com