Send your first SMS message

In a few simple steps, we will explain how to send an SMS using Routee Messaging API.

1. Routee account

To get started you'll need a Routee account

[2]:https://dev.routee.net "Routee platform"

2. Authentication

Following, your Application ID and Application Secret have to be encoded in base64 like this:

Combine the application id and secret into a string applicationid:applicationsecret
Encode the resulting string using base64

You can get your default application id and secret from the applications' menu of Routee platform

Now you can get a valid access token by sending the encoded string to the Authentication Resource.

👍

Authentication Guide

For more details and examples check this guide

3. 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.

4. Request

Now, you are ready to create an HTTP POST request to messaging API.

Resource reference here

Your Header should contain authorization and content type:

KEY

VALUE

Authorization:

Bearer {access_token}

Content-Type:

application/json

Request body contains the message text (body), the sender (from) and the recipient (to).

An example request 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' \
  --header 'Expect:' \
  --data '{ "body": "A new game has been posted to the MindPuzzle. Check it out","to" : "+30697ΧΧΧΧΧΧΧ","from": "amdTelecom"}'
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\" : \"+30697ΧΧΧΧΧΧΧ\",\"from\": \"amdTelecom\"}");
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\" : \"+30697ΧΧΧΧΧΧΧ\",\"from\": \"amdTelecom\"}", 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\" : \"+30697ΧΧΧΧΧΧΧ\",\"from\": \"amdTelecom\"}",
  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\" : \"+30697ΧΧΧΧΧΧΧ\",\"from\": \"amdTelecom\"}"

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\" : \"+30697ΧΧΧΧΧΧΧ\",\"from\": \"amdTelecom\"}"

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\" : \"+30697ΧΧΧΧΧΧΧ\",\"from\": \"amdTelecom\"}"
}

$.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": @"+30697ΧΧΧΧΧΧΧ",
                              @"from": @"amdTelecom",
                               };

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.

Resource Reference here

👍

Character Transcoding

If you need to automatically transcode unicode characters (Greek, French, Spanish etc) just enable the enforce transcoding option found on here under the application you used to authenticate.

📘

Important

All tokens that are issued from Routee's authorization server are valid for 1 hour. This allows better security for your HTTP calls. That means that once you get an HTTP response with a status code of 401, from any Routee API resource, you should issue a new token and repeat your previous request with the new token.

To issue a new token, you follow the same procedure of exchanging your application credentials through the authorization server.

👍

Non-Expiring Tokens

If by any reason you want a non-expirable token then you should create a new application on https://go.routee.net/#/management/applications or https://dev.routee.net/#/management/applications and at the dropdown Token Expiration Settings select the option Unlimited. When you exchange the new application ID & Secret with the oAuth resource the receiving token will never expire.

Updated about a year ago


Send your first SMS message


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.