How to send SMS using Pools
By creating a Pool you are able to send an SMS by following the next steps:
- Simply retrieve all the Routee available numbers, according to the country you desire.
- Search among the available numbers for one that meets your needs.
- Rent the number you wish with a small activation fee, by making a simple API call.
- Create a new pool with an API call (you can also edit your existing pool and your SMS settings)
- Add virtual numbers to your Pool.
- Send an SMS using your Pool.
Example of how to send an SMS using a Pool:
- In this example, you will see the steps of how to rent a new number.
To view all the available numbers according to the country you desire, you should send a request as below:
Your Header for all following requests should contain authorization and content type:
KEY | VALUE |
---|---|
Authorization | Bearer {access_token} |
Content-Type | application/json |
The country parameter of the request is required and should be in ISO alpha-2 format (e.g. US).
As response, you will receive all the available numbers for a US country and also for a specific area code.
The example request to search a number is shown below:
curl -X POST \
https://connect.routee.net/numbers/available/search \
-H 'Authorization: Bearer d0e71005-1089-44c1-9fce-80feec7b2af3' \
-H 'Content-Type: application/json'
-d '[
{"fieldName": "country", "searchTerm": "US"},
{"searchTerm": "201", "searchOperator": "is", "fieldName": "areaCode"}
]'
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[{\n\t\"searchTerm\":\"US\",\n\t\"fieldName\":\"country\",\n\t\"searchOperator\": \"is\"\n},\n\n\n{\"searchTerm\": \"201\", \"searchOperator\": \"is\", \"fieldName\": \"areaCode\"}\n\n\n]");
Request request = new Request.Builder()
.url("https://connect.routee.net/numbers/available/search")
.post(body)
.addHeader("Authorization", "Bearer d0e71005-1089-44c1-9fce-80feec7b2af3")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/numbers/available/search");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer d0e71005-1089-44c1-9fce-80feec7b2af3");
request.AddParameter("undefined", "[{\n\t\"searchTerm\":\"US\",\n\t\"fieldName\":\"country\",\n\t\"searchOperator\": \"is\"\n},\n\n\n{\"searchTerm\": \"201\", \"searchOperator\": \"is\", \"fieldName\": \"areaCode\"}\n\n\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://connect.routee.net/numbers/available/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "[{\n\t\"searchTerm\":\"US\",\n\t\"fieldName\":\"country\",\n\t\"searchOperator\": \"is\"\n},\n\n\n{\"searchTerm\": \"201\", \"searchOperator\": \"is\", \"fieldName\": \"areaCode\"}\n\n\n]",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer d0e71005-1089-44c1-9fce-80feec7b2af3",
"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.HTTPConnection("connect,routee,net")
payload = "[{\n\t\"searchTerm\":\"US\",\n\t\"fieldName\":\"country\",\n\t\"searchOperator\": \"is\"\n},\n\n\n{\"searchTerm\": \"201\", \"searchOperator\": \"is\", \"fieldName\": \"areaCode\"}\n\n\n]"
headers = {
'Authorization': "Bearer d0e71005-1089-44c1-9fce-80feec7b2af3",
'Content-Type': "application/json"
}
conn.request("POST", "numbers,available,search", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://connect.routee.net/numbers/available/search")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer d0e71005-1089-44c1-9fce-80feec7b2af3'
request["Content-Type"] = 'application/json'
request.body = "[{\n\t\"searchTerm\":\"US\",\n\t\"fieldName\":\"country\",\n\t\"searchOperator\": \"is\"\n},\n\n\n{\"searchTerm\": \"201\", \"searchOperator\": \"is\", \"fieldName\": \"areaCode\"}\n\n\n]"
response = http.request(request)
puts response.read_body
var settings = {
"async": true,
"crossDomain": true,
"url": "https://connect.routee.net/numbers/available/search",
"method": "POST",
"headers": {
"Authorization": "Bearer d0e71005-1089-44c1-9fce-80feec7b2af3",
"Content-Type": "application/json"
},
"processData": false,
"data": "[{\n\t\"searchTerm\":\"US\",\n\t\"fieldName\":\"country\",\n\t\"searchOperator\": \"is\"\n},\n\n\n{\"searchTerm\": \"201\", \"searchOperator\": \"is\", \"fieldName\": \"areaCode\"}\n\n\n]"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Authorization": @"Bearer d0e71005-1089-44c1-9fce-80feec7b2af3",
@"Content-Type": @"application/json"};
NSDictionary *parameters = @[ @{ @"searchTerm": @"US", @"fieldName": @"country", @"searchOperator": @"is" },
@{ @"searchTerm": @"201", @"searchOperator": @"is", @"fieldName": @"areaCode" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/numbers/available/search"]
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];
Now, you are able to select the number (MSISDN) and send a request to rent it as below:
The body parameters should be the below:
KEY | VALUE |
---|---|
msisdn | The phone number. |
inboundSmsCallbackUrl | The defined callback URL that will receive the inbound messages. |
The example request to rent a number is shown below:
curl -X POST \
https://connect.routee.net/numbers/my/ \
-H 'Authorization: Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023' \
-H 'Content-Type: application/json' \
-d '{ "msisdn": "+12012860774", "inboundSmsCallbackUrl": "http://my-inbound-sms-url.com" }'
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"msisdn\": \"+447123123456\",\n\t\"inboundSmsCallbackUrl\": \"http://my-inbound-sms-url.com\"\n}");
Request request = new Request.Builder()
.url("https://connect.routee.net/numbers/my/")
.post(body)
.addHeader("Authorization", "Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/numbers/my/");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023");
request.AddParameter("undefined", "{\n\t\"msisdn\": \"+447123123456\",\n\t\"inboundSmsCallbackUrl\": \"http://my-inbound-sms-url.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://connect.routee.net/numbers/my/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n\t\"msisdn\": \"+447123123456\",\n\t\"inboundSmsCallbackUrl\": \"http://my-inbound-sms-url.com\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023",
"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.HTTPConnection("connect.routee.net")
payload = "{\n\t\"msisdn\": \"+447123123456\",\n\t\"inboundSmsCallbackUrl\": \"http://my-inbound-sms-url.com\"\n}"
headers = {
'Authorization': "Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023",
'Content-Type': "application/json"
}
conn.request("POST", "numbers,my,", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://connect.routee.net/numbers/my/")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023'
request["Content-Type"] = 'application/json'
request.body = "{\n\t\"msisdn\": \"+447123123456\",\n\t\"inboundSmsCallbackUrl\": \"http://my-inbound-sms-url.com\"\n}"
response = http.request(request)
puts response.read_body
var settings = {
"async": true,
"crossDomain": true,
"url": "https://connect.routee.net/numbers/my/",
"method": "POST",
"headers": {
"Authorization": "Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023",
"Content-Type": "application/json"
},
"processData": false,
"data": "{\n\t\"msisdn\": \"+447123123456\",\n\t\"inboundSmsCallbackUrl\": \"http://my-inbound-sms-url.com\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Authorization": @"Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023",
@"Content-Type": @"application/json"};
NSDictionary *parameters = @{ @"msisdn": @"+306911111111",
@"inboundSmsCallbackUrl": @"http://example.org" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/numbers/my/"]
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];
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Authorization": @"Bearer b336c672-ce4b-4aa5-8386-7c2a60de3023",
@"Content-Type": @"application/json"};
NSDictionary *parameters = @{ @"msisdn": @"+447123123456",
@"inboundSmsCallbackUrl": @"http://my-inbound-sms-url.com" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/numbers/my/"]
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];
- After renting a number, you can create a new Pool and set your SMS settings as follow:
KEY | VALUE |
---|---|
sticky | When enabled, the service should try to always use the same number, as sender, for each recipient. |
geomatch | When enabled, the service should try to use, as sender, a number that matches the destination country. |
transcode | When enabled, the SMS message will get transcoded (when possible). |
defaultCountry | A country code in ISO 3166-1 alpha-2 format. Routee will use a number from this defaultCountry as sender, if there is not a more suitable option (eg a number from the same country or a sticky sender for the recipient). |
alphanumericSenderId | The alphanumeric Sender Id that will be used, when the pool strategy is "Alphanumeric". |
multipleSender | An array representing the settings required to support for multiple senderID's per country and multiple Keywords per ShortCode per country. |
multipleSender.country | A country code in ISO 3166-1 alpha-2 format. |
multipleSender.senderId | The senderID to use when the destination number matches the above country code. |
multipleSender.keyword | A string representing the keyword to use for the OPT-OUT for the destination country. |
multipleSender.shortCode | The shortCode to use for the OPT-OUT procedure for the destination country. |
inboundSMSCallbackUrl | Defines the callback URL that will receive the inbound messages to the numbers of the pool. |
callback | Defines the callback URL that will receive the status update notifications for your outbound SMS messages. |
callback.url | A URL that Routee will POST to, each time your message status changes. |
callback.strategy | Defines when the URL will be called. Two possible values: on every status change (OnChange) or when a final status arrives (OnCompletion). |
Example:
Your Header should contain authorization and content type:
KEY | VALUE |
---|---|
Authorization | Bearer {access_token} |
Content-Type | application/json |
The example request is shown below:
curl -X POST \
https://connect.routee.net/pools/my \
-H 'Authorization: Bearer 4c610523-6269-491a-bf42-9538eaed728f' \
-H 'Content-Type: application/json' \
-d '{
"poolName": "my pool",
"smsSettings": {
"sticky": "true",
"geomatch": "true",
"defaultCountry": "US",
"alphanumericSenderId": "pool sender",
"multipleSender": [
{
"country": "DE",
"senderId": "german",
"keyword": "yes"
},
{
"country": "CL",
"senderId": "chile",
"keyword": "yes",
"shortCode": "FI"
}
],
"callback": {
"url": "http://xxxx.xx",
"strategy": "OnChange"
},
"inboundSMSCallbackUrl": "http://xxxx.xx"
}
}'
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\"poolName\":\"my pool\",\n\"smsSettings\":{ \n \"sticky\":\"true\",\n \"geomatch\":\"true\", \n \"defaultCountry\":\"US\",\n \"alphanumericSenderId\":\"pool sender\" ,\n \"callback\":{\n \"url\":\"http://xxxx.xx\",\n \"strategy\":\"OnChange\"\n },\n \"inboundSMSCallbackUrl\":\"http://xxxx.xx\" \n}\n}");
Request request = new Request.Builder()
.url("https://connect.routee.net/pools/my")
.post(body)
.addHeader("Authorization", "Bearer 4c610523-6269-491a-bf42-9538eaed728f")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/pools/my");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer 4c610523-6269-491a-bf42-9538eaed728f");
request.AddParameter("undefined", "{\n\"poolName\":\"my pool\",\n\"smsSettings\":{ \n \"sticky\":\"true\",\n \"geomatch\":\"true\", \n \"defaultCountry\":\"US\",\n \"alphanumericSenderId\":\"pool sender\" ,\n \"callback\":{\n \"url\":\"http://xxxx.xx\",\n \"strategy\":\"OnChange\"\n },\n \"inboundSMSCallbackUrl\":\"http://xxxx.xx\" \n}\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://connect.routee.net/pools/my",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n\"poolName\":\"my pool\",\n\"smsSettings\":{ \n \"sticky\":\"true\",\n \"geomatch\":\"true\", \n \"defaultCountry\":\"US\",\n \"alphanumericSenderId\":\"pool sender\" ,\n \"callback\":{\n \"url\":\"http://xxxx.xx\",\n \"strategy\":\"OnChange\"\n },\n \"inboundSMSCallbackUrl\":\"http://xxxx.xx\" \n}\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer 4c610523-6269-491a-bf42-9538eaed728f",
"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.HTTPConnection("connect,routee,net")
payload = "{\n\"poolName\":\"my pool\",\n\"smsSettings\":{ \n \"sticky\":\"true\",\n \"geomatch\":\"true\", \n \"defaultCountry\":\"US\",\n \"alphanumericSenderId\":\"pool sender\" ,\n \"callback\":{\n \"url\":\"http://xxxx.xx\",\n \"strategy\":\"OnChange\"\n },\n \"inboundSMSCallbackUrl\":\"http://xxxx.xx\" \n}\n}"
headers = {
'Authorization': "Bearer 4c610523-6269-491a-bf42-9538eaed728f",
'Content-Type': "application/json"
}
conn.request("POST", "pools,my", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var settings = {
"async": true,
"crossDomain": true,
"url": "https://connect.routee.net/pools/my",
"method": "POST",
"headers": {
"Authorization": "Bearer 4c610523-6269-491a-bf42-9538eaed728f",
"Content-Type": "application/json"
},
"processData": false,
"data": "{\n\"poolName\":\"my pool\",\n\"smsSettings\":{ \n \"sticky\":\"true\",\n \"geomatch\":\"true\", \n \"defaultCountry\":\"US\",\n \"alphanumericSenderId\":\"pool sender\" ,\n \"callback\":{\n \"url\":\"http://xxxx.xx\",\n \"strategy\":\"OnChange\"\n },\n \"inboundSMSCallbackUrl\":\"http://xxxx.xx\" \n}\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Authorization": @"Bearer 4c610523-6269-491a-bf42-9538eaed728f",
@"Content-Type": @"application/json" };
NSDictionary *parameters = @{ @"poolName": @"my pool",
@"smsSettings": @{ @"sticky": @"true", @"geomatch": @"true", @"defaultCountry": @"US", @"alphanumericSenderId": @"pool sender", @"callback": @{ @"url": @"http://xxxx.xx", @"strategy": @"OnChange" }, @"inboundSMSCallbackUrl": @"http://xxxx.xx" } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/pools/my"]
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];
Now you will receive the poolId that you can use in the next step.
{
"poolId": "e744dde5-fd28-499e-9689-518ecc5709e8",
"poolName": "my pool",
"smsSettings": {
"sticky": true,
"geomatch": true,
"transcode": false,
"defaultCountry": "US",
"alphanumericSenderId": "pool sender",
"multipleSender": [
{
"country": "DE",
"senderId": "german",
"keyword": "yes"
},
{
"country": "CL",
"senderId": "chile",
"keyword": "yes",
"shortCode": "FI"
}
],
"callback": {
"url": "http://xxxx.xx",
"strategy": "OnChange"
},
"inboundSMSCallbackUrl": "http://xxxx.xx"
},
"updatedAt": "2018-11-20T13:48:45.228Z"
}
- Next step is to add the virtual numbers that you rented previously.
Example:
Your Header should contain authorization and content type:
KEY | VALUE |
---|---|
Authorization | Bearer {access_token} |
Content-Type | application/json |
The example request is shown below:
curl -X PUT \
'https://connect.routee.net/pools/my/2f80a522-f0cf-4779-b97c-4e352e94a0d1/numbers/+306996471446' \
-H 'Authorization: Bearer a271050c-5c15-46c7-862a-39d7e7a367a3' \
-H 'Content-Type: application/json'
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://connect.routee.net/pools/my/2f80a522-f0cf-4779-b97c-4e352e94a0d1/numbers/+306996471446")
.put(null)
.addHeader("Authorization", "Bearer a271050c-5c15-46c7-862a-39d7e7a367a3")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/pools/my/2f80a522-f0cf-4779-b97c-4e352e94a0d1/numbers/+306996471446");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer a271050c-5c15-46c7-862a-39d7e7a367a3");
IRestResponse response = client.Execute(request);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://connect.routee.net/pools/my/2f80a522-f0cf-4779-b97c-4e352e94a0d1/numbers/+306996471446",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer a271050c-5c15-46c7-862a-39d7e7a367a3",
"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.HTTPConnection("connect,routee,net")
headers = {
'Authorization': "Bearer a271050c-5c15-46c7-862a-39d7e7a367a3",
'Content-Type': "application/json"
}
conn.request("PUT", "pools,my,2f80a522-f0cf-4779-b97c-4e352e94a0d1,numbers,+306996471446", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://connect.routee.net/pools/my/2f80a522-f0cf-4779-b97c-4e352e94a0d1/numbers/+306996471446")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer a271050c-5c15-46c7-862a-39d7e7a367a3'
request["Content-Type"] = 'application/json'
response = http.request(request)
puts response.read_body
var settings = {
"async": true,
"crossDomain": true,
"url": "https://connect.routee.net/pools/my/2f80a522-f0cf-4779-b97c-4e352e94a0d1/numbers/+306996471446",
"method": "PUT",
"headers": {
"Authorization": "Bearer a271050c-5c15-46c7-862a-39d7e7a367a3",
"Content-Type": "application/json"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Authorization": @"Bearer a271050c-5c15-46c7-862a-39d7e7a367a3",
@"Content-Type": @"application/json" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/pools/my/2f80a522-f0cf-4779-b97c-4e352e94a0d1/numbers/+306996471446"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
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];
- After successfully added your virtual numbers to your Pool you are able to send your first SMS using your Pool.
Example:
Your Header should contain authorization and content type:
KEY | VALUE |
---|---|
Authorization | Bearer {access_token} |
Content-Type | application/json |
The example request is shown below:
curl -X POST \
https://connect.routee.net/pools/my/4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa/sms \
-H 'Authorization: Bearer ec6d9ab7-e52f-4586-b8f6-da945583e949' \
-H 'Content-Type: application/json' \
-d '{
"poolStrategy":"Numeric",
"to" : "+306948xxxxxx",
"body": "Send SMS using a pool"
}'
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \n \"poolStrategy\":\"Numeric\", \n \"to\" : \"+306948xxxxxx\",\n \"body\": \"Send SMS using a pool\"\n}");
Request request = new Request.Builder()
.url("https://connect.routee.net/pools/my/4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa/sms")
.post(body)
.addHeader("Authorization", "Bearer ec6d9ab7-e52f-4586-b8f6-da945583e949")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/pools/my/4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa/sms");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer ec6d9ab7-e52f-4586-b8f6-da945583e949");
request.AddParameter("undefined", "{ \n \"poolStrategy\":\"Numeric\", \n \"to\" : \"+306948xxxxxx\",\n \"body\": \"Send SMS using a pool\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://connect.routee.net/pools/my/4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa/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 => "{ \n \"poolStrategy\":\"Numeric\", \n \"to\" : \"+306948xxxxxx\",\n \"body\": \"Send SMS using a pool\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer ec6d9ab7-e52f-4586-b8f6-da945583e949",
"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.HTTPConnection("connect,routee,net")
payload = "{ \n \"poolStrategy\":\"Numeric\", \n \"to\" : \"+306948xxxxxx\",\n \"body\": \"Send SMS using a pool\"\n}"
headers = {
'Authorization': "Bearer ec6d9ab7-e52f-4586-b8f6-da945583e949",
'Content-Type': "application/json"
}
conn.request("POST", "pools,my,4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa,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/pools/my/4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa/sms")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer ec6d9ab7-e52f-4586-b8f6-da945583e949'
request["Content-Type"] = 'application/json'
request.body = "{ \n \"poolStrategy\":\"Numeric\", \n \"to\" : \"+306948xxxxxx\",\n \"body\": \"Send SMS using a pool\"\n}"
response = http.request(request)
puts response.read_body
var settings = {
"async": true,
"crossDomain": true,
"url": "https://connect.routee.net/pools/my/4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa/sms",
"method": "POST",
"headers": {
"Authorization": "Bearer ec6d9ab7-e52f-4586-b8f6-da945583e949",
"Content-Type": "application/json"
},
"processData": false,
"data": "{ \n \"poolStrategy\":\"Numeric\", \n \"to\" : \"+306948xxxxxx\",\n \"body\": \"Send SMS using a pool\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Authorization": @"Bearer ec6d9ab7-e52f-4586-b8f6-da945583e949",
@"Content-Type": @"application/json" };
NSDictionary *parameters = @{ @"poolStrategy": @"Numeric",
@"to": @"+306948xxxxxx",
@"body": @"Send SMS using a pool" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/pools/my/4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa/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];
You will get the following response:
{
"trackingId": "9004c273-6397-4c56-a615-7f5490c4305c",
"status": "Queued",
"createdAt": "2018-11-20T15:01:41.272Z",
"poolId": "4af48a7d-8c65-4e8b-91ab-34d2cb0c2efa",
"poolName": "demo pool",
"poolStrategy": "Numeric",
"smsSettings": {
"sticky": true,
"geomatch": true,
"transcode": false,
"alphanumericSenderId": "sender",
"multipleSender": [
{
"country": "DE",
"senderId": "german",
"keyword": "yes"
},
{
"country": "CL",
"senderId": "chile",
"keyword": "yes",
"shortCode": "FI"
}
]
},
"to": "+306948xxxxxx",
"from": "306988xxxxxx",
"body": "Send SMS using a pool",
"bodyAnalysis": {
"parts": 1,
"unicode": false,
"characters": 21
}
}
Updated over 3 years ago