Send an SMS message and receive status updates

Check the delivery status of your message#

When you send a text message, you get back a response from the API regarding the message status

There are two ways to get the delivery status of the message.

  • A. By using the Tracking resource
  • B. By providing a callbackURL to your original message submission so that the Routee API will respond back with the delivery update.

The final delivery status might take from some seconds to some days, depending on the network or recipient status.

For example, if a mobile device is turned off, the message will be delivered when the GSM subscriber (client) gets back online or switches on the mobile device. Depending on your system configuration, you have the option to provide a Callback URL - also called Webhook - to receive status updates for your messages.

In order to minimize load, you might prefer to receive only the final status update for your messages.

Messaging statuses: Routee is using only application significant statuses read more...

Guide#

In this guide, we assume you have already registered, got your application credentials from Routee Platform and authenticated.

We will demonstrate how to send an SMS and get the final delivery status update to your application.

Phone number format#

The message will be sent only to a valid phone number, written in international format e.g. +3069xxxxxxxx. You have to use the E.164 number formatting. E.164 numbers are internationally standardized to a 15-digit maximum length.

Request#

Now, you are ready to create an HTTP POST request to the API. Before that, you should enable an endpoint in your application server accessible by routee.net (eg. http://www.yourserver.com/message) to receive message update(s).

Your Header should contain authorization and content type:

KEYVALUE
Authorization:Bearer {access_token}
Content-Type:application/json

Request example is shown below:

curl - -request POST \
  - -url https://connect.routee.net/sms \
  - -header 'authorization: Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4'\
  - -header 'content-type: application/json' \
  - -data '{ "body": "A new game has been posted to the MindPuzzle. Check it out","to" : "+30697ΧΧΧΧΧΧΧ","from": "amdTelecom","callback": { "strategy": "OnCompletion", "url": "http://www.yourserver.com/message"}}'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \"body\": \"A new game has been posted to the MindPuzzle. Check it out\",\"to\" : \"+30697XXXXXXX\",\"from\": \"amdTelecom\",\"callback\": { \"strategy\": \"OnCompletion\", \"url\": \"http://www.yourserver.com/message\"}}");
Request request = new Request.Builder()
  .url("https://connect.routee.net/sms")
  .post(body)
  .addHeader("authorization", "Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4")
  .addHeader("content-type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/sms");
var request = new RestRequest(Method.POST);

request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4");
request.AddParameter("application/json", "{ \"body\": \"A new game has been posted to the MindPuzzle. Check it out\",\"to\" : \"+30697XXXXXXX\",\"from\": \"amdTelecom\",\"callback\": { \"strategy\": \"OnCompletion\", \"url\": \"http://www.yourserver.com/message\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://connect.routee.net/sms",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{ \"body\": \"A new game has been posted to the MindPuzzle. Check it out\",\"to\" : \"+30697XXXXXXX\",\"from\": \"amdTelecom\",\"callback\": { \"strategy\": \"OnCompletion\", \"url\": \"http://www.yourserver.com/message\"}}",
  CURLOPT_HTTPHEADER => array(
    "authorization: Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("connect.routee.net")

payload = "{ \"body\": \"A new game has been posted to the MindPuzzle. Check it out\",\"to\" : \"+30697XXXXXXX\",\"from\": \"amdTelecom\",\"callback\": { \"strategy\": \"OnCompletion\", \"url\": \"http://www.yourserver.com/message\"}}"

headers = {
    'authorization': "Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4",
    'content-type': "application/json"
    }

conn.request("POST", "/sms", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://connect.routee.net/sms")

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"] = 'Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4'
request["content-type"] = 'application/json'
request.body = "{ \"body\": \"A new game has been posted to the MindPuzzle. Check it out\",\"to\" : \"+30697XXXXXXX\",\"from\": \"amdTelecom\",\"callback\": { \"strategy\": \"OnCompletion\", \"url\": \"http://www.yourserver.com/message\"}}"

response = http.request(request)
puts response.read_body
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://connect.routee.net/sms",
  "method": "POST",
  "headers": {
    "authorization": "Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4",
    "content-type": "application/json"
  },
  "processData": false,
  "data": "{ \"body\": \"A new game has been posted to the MindPuzzle. Check it out\",\"to\" : \"+30697XXXXXXX\",\"from\": \"amdTelecom\",\"callback\": { \"strategy\": \"OnCompletion\", \"url\": \"http://www.yourserver.com/message\"}}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"authorization": @"Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4",
                           @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"body": @"A new game has been posted to the MindPuzzle. Check it out",
                              @"to": @"+30697XXXXXXX",
                              @"from": @"amdTelecom",
                              @"callback": @{ @"strategy": @"OnCompletion", @"url": @"http://www.yourserver.com/message" } };

NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/sms"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];

That's it! You should receive an SMS in a few moments.
Your application on http://www.yourserver.com/message should receive a status update for the message when the final message delivery status is received from Routee server(s).

Resource Reference here

Additional information#

  • Check here for resource reference
  • The payload that Routee will POST to your CallbackURL is described here
  • You can also set the default CallbackURL for a Routee application.

For more information check here

👍

Character Transcoding

If you need to automatically transcode unicode characters (Greek, French, Spanish etc) just set the "transcode" parameter to true in the body of the request, or enable the enforce transcoding option found on here under the application you used to authenticate.