How to send a personalized SMS campaign

With the SMS campaign API, you are able to send a personalized SMS campaign having uploading contacts with labels into a group.

Example of how to send a personalized SMS campaign:

In this example, you will see step by step how to create a new group, upload contacts with labels into this group and how to send a personalized SMS campaign.

You can create a new contact with custom labels and upload it to a specific group.

Your Header for all following requests should contain authorization and content type:

KEYVALUE
AuthorizationBearer {access_token}
Content-Typeapplication/json

The body parameters should be the below:

KEYVALUE
nameThe name of label
typeThe type of label (Text, Number)

The example request to create a label is shown below:

curl -X POST \
  https://connect.routee.net/contacts/labels/my \
  -H 'Authorization: Bearer 9fef567a-6a2a-4caa-ad68-d00eaeb42e12' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '[ { "name": "Document Id", "type": "Text" } ]'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[ { \"name\": \"Document Id\", \"type\": \"Text\" } ]");
Request request = new Request.Builder()
  .url("https://connect.routee.net/contacts/labels/my")
  .post(body)
  .addHeader("Authorization", "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cache-Control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/contacts/labels/my");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f");
request.AddParameter("undefined", "[ { \"name\": \"Document Id\", \"type\": \"Text\" } ]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://connect.routee.net/contacts/labels/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 => "[ { \"name\": \"Document Id\", \"type\": \"Text\" } ]",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    "Cache-Control: no-cache",
    "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 = "[ { \"name\": \"Document Id\", \"type\": \"Text\" } ]"

headers = {
    'Authorization': "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    'Content-Type': "application/json",
    'Cache-Control': "no-cache"
    }

conn.request("POST", "contacts,labels,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/contacts/labels/my")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f'
request["Content-Type"] = 'application/json'
request["Cache-Control"] = 'no-cache'
request.body = "[ { \"name\": \"Document Id\", \"type\": \"Text\" } ]"

response = http.request(request)
puts response.read_body
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://connect.routee.net/contacts/labels/my",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    "Content-Type": "application/json",
    "Cache-Control": "no-cache"
  },
  "processData": false,
  "data": "[ { \"name\": \"Document Id\", \"type\": \"Text\" } ]"
}

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

NSDictionary *headers = @{ @"Authorization": @"Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
                           @"Content-Type": @"application/json",
                           @"Cache-Control": @"no-cache"};
NSDictionary *parameters = @[ @{ @"name": @"Document Id", @"type": @"Text" } ];

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

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/contacts/labels/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];

You can create a new contact with the above custom label.
Example:

The body parameters should be the below:

KEYVALUE
firstNameThe first name of the contact.
lastNameThe last name of the contact.
mobileThe mobile number of the contact.
emailThe e-mail address of the contact.
vipIndicates whether the contact is treated as vip or not.
labelsContains the contact's labels with their respective values.
labels.nameThe name of the label.
labels.valueThe value of the label.

The example request to create a contact with labels is shown below:

curl -X POST \
  https://connect.routee.net/contacts/my \
  -H 'Authorization: Bearer 9fef567a-6a2a-4caa-ad68-d00eaeb42e12' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{ 
  "firstName": "James", 
  "lastName": "Davis", 
  "mobile": "+306911111111",
  "country": "GR", 
  "vip": false,
  "labels":[{"name":"Document Id","value":"56789D7689"}]
}
'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \n  \"firstName\": \"James\", \n  \"lastName\": \"Davis\", \n  \"mobile\": \"+306911111111\",\n  \"country\": \"GR\", \n  \"vip\": false,\n  \"labels\":[{\"name\":\"Document Id\",\"value\":\"56789D7689\"}]\n}\n");
Request request = new Request.Builder()
  .url("https://connect.routee.net/contacts/my")
  .post(body)
  .addHeader("Authorization", "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cache-Control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/contacts/my");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f");
request.AddParameter("undefined", "{ \n  \"firstName\": \"James\", \n  \"lastName\": \"Davis\", \n  \"mobile\": \"+306911111111\",\n  \"country\": \"GR\", \n  \"vip\": false,\n  \"labels\":[{\"name\":\"Document Id\",\"value\":\"56789D7689\"}]\n}\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://connect.routee.net/contacts/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  \"firstName\": \"James\", \n  \"lastName\": \"Davis\", \n  \"mobile\": \"+306911111111\",\n  \"country\": \"GR\", \n  \"vip\": false,\n  \"labels\":[{\"name\":\"Document Id\",\"value\":\"56789D7689\"}]\n}\n",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    "Cache-Control: no-cache",
    "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  \"firstName\": \"James\", \n  \"lastName\": \"Davis\", \n  \"mobile\": \"+306911111111\",\n  \"country\": \"GR\", \n  \"vip\": false,\n  \"labels\":[{\"name\":\"Document Id\",\"value\":\"56789D7689\"}]\n}\n"

headers = {
    'Authorization': "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    'Content-Type': "application/json",
    'Cache-Control': "no-cache"
    }

conn.request("POST", "contacts,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/contacts/my")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f'
request["Content-Type"] = 'application/json'
request["Cache-Control"] = 'no-cache'
request.body = "{ \n  \"firstName\": \"James\", \n  \"lastName\": \"Davis\", \n  \"mobile\": \"+306911111111\",\n  \"country\": \"GR\", \n  \"vip\": false,\n  \"labels\":[{\"name\":\"Document Id\",\"value\":\"56789D7689\"}]\n}\n"

response = http.request(request)
puts response.read_body
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://connect.routee.net/contacts/my",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    "Content-Type": "application/json",
    "Cache-Control": "no-cache"
  },
  "processData": false,
  "data": "{ \n  \"firstName\": \"James\", \n  \"lastName\": \"Davis\", \n  \"mobile\": \"+306911111111\",\n  \"country\": \"GR\", \n  \"vip\": false,\n  \"labels\":[{\"name\":\"Document Id\",\"value\":\"56789D7689\"}]\n}\n"
}

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

NSDictionary *headers = @{ @"Authorization": @"Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
                           @"Content-Type": @"application/json",
                           @"Cache-Control": @"no-cache"};
NSDictionary *parameters = @{ @"firstName": @"James",
                              @"lastName": @"Davis",
                              @"mobile": @"+306911111111",
                              @"country": @"GR",
                              @"vip": @"",
                              @"labels": @[ @{ @"name": @"Document Id", @"value": @"56789D7689" } ] };

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

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/contacts/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];

Using the following endpoint you can create a new group with name eg. Customers. For details, check here

Now you can add the contact to the group by sending the following request.

The body of the request should contain an array with the id of contacts as below:

curl -X POST \
  https://connect.routee.net/groups/my/Customers/contacts \
  -H 'Authorization: Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '[ "5a782d580cf25876fb7c1f17" ]'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[ \"5a782d580cf25876fb7c1f17\" ]");
Request request = new Request.Builder()
  .url("https://connect.routee.net/groups/my/Customers/contacts")
  .post(body)
  .addHeader("Authorization", "Bearer 60af8979-2b2f-4a43-9112-067c2c71bf86")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cache-Control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/groups/my/Customers/contacts");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer 60af8979-2b2f-4a43-9112-067c2c71bf86");
request.AddParameter("undefined", "[ \"5a782d580cf25876fb7c1f17\" ]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://connect.routee.net/groups/my/Customers/contacts",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "[ \"5a782d580cf25876fb7c1f17\" ]",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer 60af8979-2b2f-4a43-9112-067c2c71bf86",
    "Cache-Control: no-cache",
    "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 = "[ \"5a782d580cf25876fb7c1f17\" ]"

headers = {
    'Authorization': "Bearer 60af8979-2b2f-4a43-9112-067c2c71bf86",
    'Content-Type': "application/json",
    'Cache-Control': "no-cache"
    }

conn.request("POST", "groups,my,Customers,contacts", payload, headers)

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

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

url = URI("https://connect.routee.net/groups/my/Customers/contacts")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer 60af8979-2b2f-4a43-9112-067c2c71bf86'
request["Content-Type"] = 'application/json'
request["Cache-Control"] = 'no-cache'
request.body = "[ \"5a782d580cf25876fb7c1f17\" ]"

response = http.request(request)
puts response.read_body
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://connect.routee.net/groups/my/Customers/contacts",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer 60af8979-2b2f-4a43-9112-067c2c71bf86",
    "Content-Type": "application/json",
    "Cache-Control": "no-cache"
  },
  "processData": false,
  "data": "[ \"5a782d580cf25876fb7c1f17\" ]"
}

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

NSDictionary *headers = @{ @"Authorization": @"Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
                           @"Content-Type": @"application/json",
                           @"Cache-Control": @"no-cache"};
NSDictionary *parameters = @[ @"5a782d580cf25876fb7c1f17" ];

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

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/groups/my/Customers/contacts"]
                                                       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 send a personalized SMS campaign to the group using the label 'firstName' and the custom label 'Document Id'.

Example:

The body of request should be as below:

curl -X POST \
  https://connect.routee.net/sms/campaign \
  -H 'Authorization: Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
  "body": "Dear [~firstName], your document id is: [~Document Id]", 
  "to":["+306939999999"],
  "groups":["Customers"],
  "from": "amdTelecom"
}'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\n  \"body\": \"Dear [~firstName], your document id is: [~Document Id]\", \n  \"to\":[\"+306939999999\"],\n  \"groups\":[\"Customers\"],\n  \"from\": \"amdTelecom\"\n  \n}");
Request request = new Request.Builder()
  .url("https://connect.routee.net/sms/campaign")
  .post(body)
  .addHeader("Authorization", "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cache-Control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/sms/campaign");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f");
request.AddParameter("undefined", "{\n\n  \"body\": \"Dear [~firstName], your document id is: [~Document Id]\", \n  \"to\":[\"+306939999999\"],\n  \"groups\":[\"Customers\"],\n  \"from\": \"amdTelecom\"\n  \n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://connect.routee.net/sms/campaign",
  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\n  \"body\": \"Dear [~firstName], your document id is: [~Document Id]\", \n  \"to\":[\"+306939999999\"],\n  \"groups\":[\"Customers\"],\n  \"from\": \"amdTelecom\"\n  \n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    "Cache-Control: no-cache",
    "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\n  \"body\": \"Dear [~firstName], your document id is: [~Document Id]\", \n  \"to\":[\"+306939999999\"],\n  \"groups\":[\"Customers\"],\n  \"from\": \"amdTelecom\"\n  \n}"

headers = {
    'Authorization': "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    'Content-Type': "application/json",
    'Cache-Control': "no-cache"
    }

conn.request("POST", "sms,campaign", 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/campaign")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f'
request["Content-Type"] = 'application/json'
request["Cache-Control"] = 'no-cache'
request.body = "{\n\n  \"body\": \"Dear [~firstName], your document id is: [~Document Id]\", \n  \"to\":[\"+306939999999\"],\n  \"groups\":[\"Customers\"],\n  \"from\": \"amdTelecom\"\n  \n}"

response = http.request(request)
puts response.read_body
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://connect.routee.net/sms/campaign",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
    "Content-Type": "application/json",
    "Cache-Control": "no-cache"
  },
  "processData": false,
  "data": "{\n\n  \"body\": \"Dear [~firstName], your document id is: [~Document Id]\", \n  \"to\":[\"+306939999999\"],\n  \"groups\":[\"Customers\"],\n  \"from\": \"amdTelecom\"\n  \n}"
}

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

NSDictionary *headers = @{ @"Authorization": @"Bearer 917ca607-7c0c-4957-8ce2-f2335aa9a62f",
                           @"Content-Type": @"application/json",
                           @"Cache-Control": @"no-cache"};
NSDictionary *parameters = @{ @"body": @"Dear [~firstName], your document id is: [~Document Id]",
                              @"to": @[ @"+306939999999" ],
                              @"groups": @[ @"Customers" ],
                              @"from": @"amdTelecom" };

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

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/sms/campaign"]
                                                       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];

🚧

Validation Error

If the HTTP response has 400 status code, with "code":"400005000", then your SMS campaign contains invalid data, specified in "errors" array.

008 errorCode indicates that some recipients are invalid (either a mobile number in "to" array, a contact, or inside a group).
In order to send your campaign, try to exclude these invalid recipients (remove them from the selected group, "to" or "contacts" array) and send again the HTTP request.
You can find the invalid numbers as "property" in "errors" array, with "errorCode":008.