NAV Navigation
Shell PHP JavaScript Node.JS Ruby Python Java Go

Authentication

To make successful API Requests, you need to authorize the API calls using one of the following methods:

You can generate, retrieve and manage your API keys or Client IDs & Secrets in your SMS.to dashboard under the API Clients section.

API Key VS Client ID & Secret

The main differences in using API Key instead of Client ID & Secret are:

1. API Key does not require generating the access token and can be directly used for authorization of API requests:

On the other hand, if you are going to use Client ID & Secret instead of API Key, you will need to generate the access token to authorize your API requests. Also, please note that the generated Access Token can only be used as Authorization Header: Authorization: Bearer <ACCESS_TOKEN>.

2. API Key doesn't have expiration time. By default, Access Token has no expiration time but to provide extra security of token, user can pass expires_in (in minutes) parameter in request. The token generated will have expiration time set by user.

3. Most of the 3rd party services (such as Zapier) can be integrated using the API Key. However, there are some applications that require Client ID & Secret for integration, and that's the reason why we also provide this way of authorizing API calls.

Generate Access Token

curl -L -X POST "https://auth.sms.to/oauth/token" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d "{
	\"client_id\" : \"234\",
	\"secret\": \"Kn5TtQMMGx0BYU3ECctXG6m7l2BKmirq9FZ8YLbi\",
	\"expires_in\": 60
}"
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://auth.sms.to/oauth/token",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n\t\"client_id\" : \"234\",\n\t\"secret\": \"Kn5TtQMMGx0BYU3ECctXG6m7l2BKmirq9FZ8YLbi\",\n\t\"expires_in\": 60\n}",
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n	\"client_id\" : \"234\",\n	\"secret\": \"Kn5TtQMMGx0BYU3ECctXG6m7l2BKmirq9FZ8YLbi\",\n	\"expires_in\": 60\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://auth.sms.to/oauth/token");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://auth.sms.to',
  'path': '/oauth/token',
  'headers': {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n\t\"client_id\" : \"234\",\n\t\"secret\": \"Kn5TtQMMGx0BYU3ECctXG6m7l2BKmirq9FZ8YLbi\",\n\t\"expires_in\": 60\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://auth.sms.to/oauth/token")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request.body = "{\n\t\"client_id\" : \"234\",\n\t\"secret\": \"Kn5TtQMMGx0BYU3ECctXG6m7l2BKmirq9FZ8YLbi\",\n\t\"expires_in\": 60\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://auth.sms.to")
payload = "{\n\t\"client_id\" : \"234\",\n\t\"secret\": \"Kn5TtQMMGx0BYU3ECctXG6m7l2BKmirq9FZ8YLbi\",\n\t\"expires_in\": 60\n}"
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json'
}
conn.request("POST", "/oauth/token", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"client_id\" : \"234\",\n\t\"secret\": \"Kn5TtQMMGx0BYU3ECctXG6m7l2BKmirq9FZ8YLbi\",\n\t\"expires_in\": 60\n}");
Request request = new Request.Builder()
  .url("https://auth.sms.to/oauth/token")
  .method("POST", body)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://auth.sms.to/oauth/token"
  method := "POST"

  payload := strings.NewReader("{\n	\"client_id\" : \"234\",\n	\"secret\": \"Kn5TtQMMGx0BYU3ECctXG6m7l2BKmirq9FZ8YLbi\",\n	\"expires_in\": 60\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Accept", "application/json")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGgtYXBpLnRlc3Qvb2F1dGgvdG9rZW4iLCJpYXQiOjE1NjY4Mzc1OTYsImV4cCI6MTU2NzQ0MjM5NiwibmJmIjoxNTY2ODM3NTk2LCJqdGkiOiI5RlhnbkRCSkgxaFh6NzB1Iiwic3ViIjo4MTkzLCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.U6NqFpbo1QQ4NP9F-xWDZJT5FG8cSN-ySkZgQsiG2kI",
    "token_type": "bearer",
    "expires": 604800,
    "type": "admin"
}

POST https://auth.sms.to/oauth/token

Generate new Access Token

Parameters

Parameter In Type Required Description
client_id body string Yes Your Client ID
secret body string Yes Your Secret
expires_in body int Optional Pass this when you want TOKEN to expire

Responses Schema

Name Type Required Description
jwt String true Access Token used for authorizing API calls
token_type String true Token type
expires Int true Expiry time in seconds
type String true User role associated with the provided credentials (Client ID & Secret)

Refresh Access Token

For Expiring Tokens, the expiring time can be refreshed.

curl -L -X POST "https://auth.sms.to/refresh" \
-H "Accept: application/json" \
-H "Content-Type: application/json"
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://auth.sms.to/refresh",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://auth.sms.to/refresh");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://auth.sms.to',
  'path': '/refresh',
  'headers': {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://auth.sms.to/refresh")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request.body = ""

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://auth.sms.to")
payload = ""
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json'
}
conn.request("POST", "/refresh", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://auth.sms.to/refresh")
  .method("POST", body)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://auth.sms.to/refresh"
  method := "POST"

  payload := strings.NewReader("")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Accept", "application/json")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

POST https://auth.sms.to/refresh

Verify Number

curl -L -X POST "https://sms.to/v1/verify/number" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
	\"to\" : \"+3579400001\"
}"
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.to/v1/verify/number",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n\t\"to\":\"+35794000001\"}",
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Content-Type: application/json"
    "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n	\"to\" : \"+35794000001\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://sms.to/v1/verify/number");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");
xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://sms.to',
  'path': '/v1/verify/number',
  'headers': {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n\t\"to\":\"+35794000001\"}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/verify/number")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n\t\"to\":\"+35794000001\"}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
payload = "{\n\t\"to\":\"+35794000001\"}"
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/v1/verify/number", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"to\":\"+35794000001\"}");
Request request = new Request.Builder()
  .url("https://sms.to/v1/verify/number")
  .method("POST", body)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>") 
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/verify/number"
  method := "POST"

  payload := strings.NewReader("{\n	\"to\" : \"+35794000001\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Accept", "application/json")
  req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "phone": "+35794000001",
    "status": "ACTIVE",
    "details": {
        "mcc": "429",
        "country": {
            "code": "CY",
            "name": "Cyprus",
            "localeName": "Cyprus",
            "isoA3Code": "CY"
        },
        "network": {
            "name": "Cytamobile",
            "mnc": "01"
        },
        "imsi": "42901",
        "ported": false
    }
}

POST https://sms.to/v1/verify/number

Verify phone number

Parameters

Parameter In Type Required Description
to body string Yes Mobile number to verify

Responses Schema

Name Type Required Description
phone String true Phone number to verify
status String true Status of phone number
details Array false Provide Country and Network information if phone number is ACTIVE

Get Balance

curl -L -X GET "https://auth.sms.to/api/balance" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
 "https://auth.sms.to/api/balance",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://auth.sms.to/api/balance");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://auth.sms.to',
  'path': '/api/balance',
  'headers': {
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
require "uri"
require "net/http"

url = URI("https://auth.sms.to/api/balance")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://auth.sms.to")
payload = ''
headers = {
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("GET", "/api/balance", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://auth.sms.to/api/balance")
  .method("GET", null)
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://auth.sms.to/api/balance"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "balance": 1.184,
    "currency": "EUR"
}

GET https://auth.sms.to/api/balance

Get the current balance of your SMS.to account

Lists & Contacts

Everything about creating and manipulating contact lists and contacts. Creating a list allows you to manage your customers more efficiently. It enables features like Opt-Out management and Personalisation.

Create a new list

curl -L -X POST "https://sms.to/v1/lists/" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
	\"name\": \"List Name\",
	\"description\": \"List Description\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.test/v1/lists/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n\t\"name\": \"List Name\",\n\t\"description\": \"List Description\"\n}",
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Content-Type: application/json",
    "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n	\"name\": \"List Name\",\n	\"description\": \"List Description\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://sms.to/v1/lists/");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://sms.to',
  'path': '/v1/lists/',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n\t\"name\": \"List Name\",\n\t\"description\": \"List Description\"\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/lists/")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n\t\"name\": \"List Name\",\n\t\"description\": \"List Description\"\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
payload = "{\n\t\"name\": \"List Name\",\n\t\"description\": \"List Description\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/v1/lists/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"name\": \"List Name\",\n\t\"description\": \"List Description\"\n}");
Request request = new Request.Builder()
  .url("https://sms.to/v1/lists/")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/lists/"
  method := "POST"

  payload := strings.NewReader("{\n	\"name\": \"List Name\",\n	\"description\": \"List Description\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "data": {
        "id": 1265,
        "user_id": 146,
        "name": "My List",
        "description": "This my contacts list",
        "favorite": null,
        "from_deleted_user": null,
        "created_at": {
            "date": "2019-08-26 17:20:17.000000",
            "timezone_type": 3,
            "timezone": "UTC"
        }
    },
    "message": "List created."
}

POST https://sms.to/v1/lists

Create new contact list

Parameters

Parameter In Type Required Description
name body string Yes Your contact list name
description body string No A brief description of your list

Import contacts to list

curl -L -X POST "https://sms.to/v1/list/1531" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
	\"phones\": [\"+35794585001\",\"+35794585002\"]
}"

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.to/v1/list/1531",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"contacts\": [\n        {\n            \"phone\": \"35794585001\",\n            \"firstname\": \"first 1\",\n            \"lastname\": \"last 1\",\n            \"email\": \"email1@email.com\",\n            \"custom1\": \"custom1 1\",\n            \"custom2\": \"custom2 1\"\n        },\n        {\n            \"phone\": \"35794585002\",\n            \"firstname\": \"first 2\",\n            \"lastname\": \"last 2\",\n            \"email\": \"email2@email.com\",\n            \"custom1\": \"custom1 2\",\n            \"custom2\": \"custom2 2\"\n        }\n    ]\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n    \"contacts\": [\n        {\n            \"phone\": \"35794585001\",\n            \"firstname\": \"first 1\",\n            \"lastname\": \"last 1\",\n            \"email\": \"email1@email.com\",\n            \"custom1\": \"custom1 1\",\n            \"custom2\": \"custom2 1\"\n        },\n        {\n            \"phone\": \"35794585002\",\n            \"firstname\": \"first 2\",\n            \"lastname\": \"last 2\",\n            \"email\": \"email2@email.com\",\n            \"custom1\": \"custom1 2\",\n            \"custom2\": \"custom2 2\"\n        }\n    ]\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://sms.to/v1/list/1531");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://sms.to',
  'path': '/v1/list/1531',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n    \"contacts\": [\n        {\n            \"phone\": \"35794585001\",\n            \"firstname\": \"first 1\",\n            \"lastname\": \"last 1\",\n            \"email\": \"email1@email.com\",\n            \"custom1\": \"custom1 1\",\n            \"custom2\": \"custom2 1\"\n        },\n        {\n            \"phone\": \"35794585002\",\n            \"firstname\": \"first 2\",\n            \"lastname\": \"last 2\",\n            \"email\": \"email2@email.com\",\n            \"custom1\": \"custom1 2\",\n            \"custom2\": \"custom2 2\"\n        }\n    ]\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/list/1531")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n    \"contacts\": [\n        {\n            \"phone\": \"35794585001\",\n            \"firstname\": \"first 1\",\n            \"lastname\": \"last 1\",\n            \"email\": \"email1@email.com\",\n            \"custom1\": \"custom1 1\",\n            \"custom2\": \"custom2 1\"\n        },\n        {\n            \"phone\": \"35794585002\",\n            \"firstname\": \"first 2\",\n            \"lastname\": \"last 2\",\n            \"email\": \"email2@email.com\",\n            \"custom1\": \"custom1 2\",\n            \"custom2\": \"custom2 2\"\n        }\n    ]\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
payload = "{\n    \"contacts\": [\n        {\n            \"phone\": \"35794585001\",\n            \"firstname\": \"first 1\",\n            \"lastname\": \"last 1\",\n            \"email\": \"email1@email.com\",\n            \"custom1\": \"custom1 1\",\n            \"custom2\": \"custom2 1\"\n        },\n        {\n            \"phone\": \"35794585002\",\n            \"firstname\": \"first 2\",\n            \"lastname\": \"last 2\",\n            \"email\": \"email2@email.com\",\n            \"custom1\": \"custom1 2\",\n            \"custom2\": \"custom2 2\"\n        }\n    ]\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/v1/list/1531", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"contacts\": [\n        {\n            \"phone\": \"35794585001\",\n            \"firstname\": \"first 1\",\n            \"lastname\": \"last 1\",\n            \"email\": \"email1@email.com\",\n            \"custom1\": \"custom1 1\",\n            \"custom2\": \"custom2 1\"\n        },\n        {\n            \"phone\": \"35794585002\",\n            \"firstname\": \"first 2\",\n            \"lastname\": \"last 2\",\n            \"email\": \"email2@email.com\",\n            \"custom1\": \"custom1 2\",\n            \"custom2\": \"custom2 2\"\n        }\n    ]\n}");
Request request = new Request.Builder()
  .url("https://sms.to/v1/list/1531")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/list/1531"
  method := "POST"

  payload := strings.NewReader("{\n    \"contacts\": [\n        {\n            \"phone\": \"35794585001\",\n            \"firstname\": \"first 1\",\n            \"lastname\": \"last 1\",\n            \"email\": \"email1@email.com\",\n            \"custom1\": \"custom1 1\",\n            \"custom2\": \"custom2 1\"\n        },\n        {\n            \"phone\": \"35794585002\",\n            \"firstname\": \"first 2\",\n            \"lastname\": \"last 2\",\n            \"email\": \"email2@email.com\",\n            \"custom1\": \"custom1 2\",\n            \"custom2\": \"custom2 2\"\n        }\n    ]\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "data": {
        "list_id": 1265
    },
    "message": "Contacts are now importing into the list 'My List'"
}

POST https://sms.to/v1/list/{list_id}

Import contacts into the specified list

Parameters

Parameter In Type Required Description
list_id path integer Yes Your contact list id you want to access.
contacts body string Yes List of contacts that you import. See below for more details.

The contacts parameter that is specified in the body should include an array of contacts in JSON format, where each contact has a JSON representation of the following parameters:

Parameter Type Required Description
phone string Yes The phone number.
firstname string No The first name
lastname string No The last name
email string No The email address
custom1 string No The custom field
custom2 string No The custom field

Example of contacts array:

[{"phone":"35794585001", "email":"email1@email.com"}, {"phone":"35794585002", "firstname":"John"}]

Fetch contacts from list

curl -L -X GET "https://sms.to/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=first%201" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d ""
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.test/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=first%201",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Content-Type: application/json",
    "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://sms.to/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=first%201");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://sms.to',
  'path': '/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=first%201',
  'headers': {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=first 1")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
payload = ''
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("GET", "/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=first 1", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://sms.to/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=first 1")
  .method("GET", null)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=first%201"
  method := "GET"

  payload := strings.NewReader("")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Accept", "application/json")
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "data": {
        "data": [
            {
                "_id": {
                    "$oid": "5d412d0b7194be00ba775742"
                },
                "user_id": 2,
                "list_id": 11,
                "phone": "+35794585001",
                "firstname": "first 1",
                "lastname": "last 1",
                "email": "email1@email.com",
                "custom1": "custom1 1",
                "custom2": "custom2 1",
                "country_code": 357,
                "network_name": "Lemontel",
                "countryA2Code": null,
                "optedout": 0,
                "optout_date": null,
                "created_at": {
                    "date": "2019-07-31 05:54:19.744945",
                    "timezone_type": 3,
                    "timezone": "UTC"
                },
                "updated_at": {
                    "date": "2019-07-31 05:54:19.744945",
                    "timezone_type": 3,
                    "timezone": "UTC"
                },
                "optout_method": null,
                "id": "5d412d0b7194be00ba775742"
            },
            {
                "_id": {
                    "$oid": "5d412d0b7194be00ba775743"
                },
                "user_id": 2,
                "list_id": 11,
                "phone": "+35794585002",
                "firstname": "first 2",
                "lastname": "last 2",
                "email": "email2@email.com",
                "custom1": "custom1 2",
                "custom2": "custom2 2",
                "country_code": 357,
                "network_name": "Lemontel",
                "countryA2Code": null,
                "optedout": 0,
                "optout_date": null,
                "created_at": {
                    "date": "2019-07-31 05:54:19.744945",
                    "timezone_type": 3,
                    "timezone": "UTC"
                },
                "updated_at": {
                    "date": "2019-07-31 05:54:19.744945",
                    "timezone_type": 3,
                    "timezone": "UTC"
                },
                "optout_method": null,
                "id": "5d412d0b7194be00ba775743"
            }
        ],
        "meta": {
            "pagination": {
                "count": 2,
                "current_page": 1,
                "links": [],
                "per_page": 100000,
                "total": 2,
                "total_pages": 1
            }
        },
        "request": {
            "q": "/v1/list/11/contacts"
        }
    }
}

GET https://sms.to/v1/list/{list_id}/contacts

Fetch paginated contacts of a list

Parameters

Parameter In Type Required Description Default Value
list_id path integer Yes Contact list ID
limit query integer No The number of contacts to show per page. 100
page query integer No The page number. 1
sort query string No Sort by firstname or lastname (ASC) firstname
search query string No Keywords to search firstname, lastname, email, and phone

Example of URL with query params:

https://sms.to/v1/list/1531/contacts?limit=10&page=1&sort=firstname&search=john

Fetch lists

curl -L -X GET "https://sms.to/v1/lists/" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d ""
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.test/v1/lists/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Accept: application/json",
    "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://sms.to/v1/lists/");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data); 
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://sms.to',
  'path': '/v1/lists/',
  'headers': {
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; ------WebKitFormBoundary7MA4YWxkTrZu0gW--";

req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/lists/")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
boundary = ''
payload = ''
headers = {
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>',
  'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("GET", "/v1/lists/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://sms.to/v1/lists/")
  .method("GET", null)
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "bytes"
  "mime/multipart"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/lists/"
  method := "GET"

  payload := &bytes.Buffer{}
  writer := multipart.NewWriter(payload)
  err := writer.Close()
  if err != nil {  fmt.Println(err)}


  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "data": [
        {
            "id": 1,
            "user_id": 146,
            "name": "List One",
            "description": "This is the first list",
            "favorite": null,
            "from_deleted_user": 0,
            "created_at": {
                "date": "2018-06-29 19:36:01.000000",
                "timezone_type": 3,
                "timezone": "UTC"
            }
        },
        {
            "id": 2,
            "user_id": 146,
            "name": "List Two",
            "description": "This is the second list",
            "favorite": null,
            "from_deleted_user": 0,
            "created_at": {
                "date": "2018-06-30 19:36:01.000000",
                "timezone_type": 3,
                "timezone": "UTC"
            }
        }
    ],
    "links": {
        "first": "https://api.sms.to/v1/lists?page=1",
        "last": "https://api.sms.to/v1/lists?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "path": "https://api.sms.to/v1/lists",
        "per_page": 100,
        "to": 25,
        "total": 25
    },
    "success": true,
    "message": "Data fetched successfully."
}

GET https://sms.to/v1/lists

Fetch paginated lists

Parameters

Parameter In Type Required Description Default Value
limit query integer No The number of lists per page. 100
page query integer No The page number. 1
sort query string No The field which you want to sort, e.g. use created_at for ASC order or -created_at for DESC order. created_at
search query string No Keywords to search for a list name.

Example of URL with query params:

https://sms.to/v1/lists?limit=10&page=1&sort=created_at&search=test

Fetch single list

curl -L -X GET "https://sms.to/v1/lists/1531" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
<?php
    
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.test/v1/lists/1531",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Accept: application/json",
    "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = "";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://sms.to/v1/lists/1531");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://sms.to',
  'path': '/v1/lists/1531',
  'headers': {
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; ------WebKitFormBoundary7MA4YWxkTrZu0gW--";

req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/lists/1531")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
boundary = ''
payload = ''
headers = {
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>',
  'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("GET", "/v1/lists/1531", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://sms.to/v1/lists/1531")
  .method("GET", null)
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "bytes"
  "mime/multipart"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/lists/1531"
  method := "GET"

  payload := &bytes.Buffer{}
  writer := multipart.NewWriter(payload)
  err := writer.Close()
  if err != nil {  fmt.Println(err)}


  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "data": {
        "id": 11,
        "user_id": 2,
        "name": "My List",
        "description": "This my contacts list",
        "favorite": null,
        "from_deleted_user": 0,
        "created_at": {
            "date": "2019-07-31 05:48:31.000000",
            "timezone_type": 3,
            "timezone": "UTC"
        }
    },
    "message": "Data fetched successfully."
}

GET https://sms.to/v1/lists/{list_id}

Fetch the specified list

Parameters

Parameter In Type Required Description
list_id path integer Yes ID of the list you want to fetch

Opt-Out contacts

curl -L -X POST "https://sms.to/v1/list/1531/optout" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
	\"phones\": [\"+35794585001\",\"+35794585002\"]
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.to/v1/list/1531/optout",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n	\"phones\": [\"+35794585001\",\"+35794585002\"]\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://sms.to/v1/list/1531/optout");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://sms.to',
  'path': '/v1/list/1531/optout',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/list/1531/optout")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
payload = "{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/v1/list/1531/optout", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}");
Request request = new Request.Builder()
  .url("https://sms.to/v1/list/1531/optout")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/list/1531/optout"
  method := "POST"

  payload := strings.NewReader("{\n	\"phones\": [\"+35794585001\",\"+35794585002\"]\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "message": "Optout action request received."
}

POST https://sms.to/v1/list/{list_id}/optout

Unsubscribe the contacts (phone numbers) from specified list

Parameters

Parameter In Type Required Description
list_id path integer Yes ID of the list from which you want to opt-out phone numbers (contacts).
phones body string Yes Array of phone numbers that you opt-out. For example:["+35794585001", "+35794585002"]

Opt-In contacts

curl -L -X POST "https://sms.to/v1/list/1531/optin" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
	\"phones\": [\"+35794585001\",\"+35794585002\"]
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.to/v1/list/1531/optin",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n	\"phones\": [\"+35794585001\",\"+35794585002\"]\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://sms.to/v1/list/1531/optin");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://sms.to',
  'path': '/v1/list/1531/optin',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/list/1531/optin")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
payload = "{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/v1/list/1531/optin", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"phones\": [\"+35794585001\",\"+35794585002\"]\n}");
Request request = new Request.Builder()
  .url("https://sms.to/v1/list/1531/optin")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/list/1531/optin"
  method := "POST"

  payload := strings.NewReader("{\n	\"phones\": [\"+35794585001\",\"+35794585002\"]\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "message": "Optin action request received."
}

POST https://sms.to/v1/list/{list_id}/optin

Subscribe the contacts (phone numbers) to specified list

Parameters

Parameter In Type Required Description
list_id path integer Yes ID of the list to which you want to opt-in phone numbers (contacts).
phones body string Yes Array of phone numbers that you opt-in. For example:["+35794585001", "+35794585002"]

Delete list

curl -L -X DELETE "https://sms.to/v1/lists/1531" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d ""
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.to/v1/lists/1531",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("DELETE", "https://sms.to/v1/lists/1531");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var qs = require('querystring');

var options = {
  'method': 'DELETE',
  'hostname': 'https://sms.to',
  'path': '/v1/lists/1531',
  'headers': {
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = qs.stringify({

});

req.setHeader('Content-Length', postData.length);

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://sms.to/v1/lists/1531")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://sms.to")
payload = ''
headers = {
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("DELETE", "/v1/lists/1531", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://sms.to/v1/lists/1531")
  .method("DELETE", body)
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/lists/1531"
  method := "DELETE"

  payload := strings.NewReader("")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "data": {
        "id": 7,
        "user_id": 2,
        "name": "My List",
        "description": "This my contacts list",
        "favorite": null,
        "from_deleted_user": 0,
        "created_at": {
            "date": "2019-07-31 04:44:28.000000",
            "timezone_type": 3,
            "timezone": "UTC"
        }
    },
    "message": "List deleted."
}

DELETE https://sms.to/v1/lists/{list_id}

Delete the specified list

Parameters

Parameter In Type Required Description
list_id path integer Yes ID of the list you want to delete.

SMS Messaging

To be able to send messages, your SMS.to account must have sufficient balance. Click here to add funds to your account.

Also, here are a few tips:

  1. If your messages contain only unicode characters, enabling transcoding will reduce the costs of sending. You can enable transcoding on your SMS.to account settings.

  2. We recommend that you set the Default Prefix to ease and speed-up your sending process. The default prefix will be applied on all recipient phone numbers that don't contain the country dial code at the beginning. You can set the default prefix on your SMS.to account settings.

Send single message

curl -L -X POST "https://api.sms.to/sms/send" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
    \"message\": \"This is a test message\",
    \"to\": \"+9779856034616\",
    \"sender_id\": \"SMS.to\",
    \"callback_url\": \"https://sms.to/callback/handler\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/send",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"message\": \"This is a test message\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = "{\n    \"message\": \"This is a test message\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.sms.to/sms/send");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://api.sms.to',
  'path': '/sms/send',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n    \"message\": \"This is a test message\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/send")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n    \"message\": \"This is a test message\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = "{\n    \"message\": \"This is a test message\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/sms/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"message\": \"This is a test message\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/sms/send"
  method := "POST"

  payload := strings.NewReader("{\n    \"message\": \"This is a test message\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "message": "Message is queued for sending! Please check report for update",
    "success": true,
    "message_Id": "e7745289-7236-497f-acf2-f9cfd6a86f16"
}

POST https://api.sms.to/sms/send

Send single message to a number

Parameters

Parameter In Type Required Description
message body string Yes Your message
to body string Yes Phone number
sender_id body string No The displayed value of who sent the message
callback_url body string No A callback URL that will be used to send back information about updates of message status. See below for more details.

You can estimate the cost of sending a message by changing the path to https://api.sms.to/sms/estimate. Click here for more details.

Callback URL

The update sent to your callback URL will have the following structure:

{
    "trackingId": "185c9d63-dae2-4614-b0f4-48453e870dcf",
    "messageId": "e7745289-7236-497f-acf2-f9cfd6a86f16",
    "phone": "+9779856034616",
    "status": "SENT",
    "parts": 1,
    "price": 0.015
}

If specified, we will send responses to your callback URL via a POST method. SMS.to will be expecting response with the status code 200 (OK) in return, or it will keep retrying every 15 minutes until the callback expires (up to 48 hours).

Send campaign message

curl -L -X POST "https://api.sms.to/sms/send" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
    \"message\": \"This is a test message\",
    \"to\": [
        \"+9779856034616\",
        \"+9779856034617\"
    ],
    \"sender_id\": \"SMS.to\",
    \"callback_url\": \"https://sms.to/callback/handler\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/send",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"message\": \"This is a test message\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = "{\n    \"message\": \"This is a test message\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.sms.to/sms/send");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://api.sms.to',
  'path': '/sms/send',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n    \"message\": \"This is a test message\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/send")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n    \"message\": \"This is a test message\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = "{\n    \"message\": \"This is a test message\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/sms/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"message\": \"This is a test message\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/sms/send"
  method := "POST"

  payload := strings.NewReader("{\n    \"message\": \"This is a test message\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "message": "Message is queued for sending! Please check report for update",
    "success": true,
    "campaign_id": "abb44b64-700d-4ad6-a7e4-ba53d4db58b6"
}

POST https://api.sms.to/sms/send

Send message to multiple recipients (phone numbers)

Parameters

Parameter In Type Required Description
message body string Yes Your message
to body array Yes Array of phone number (e.g. ["+35794585001", "+35794585002"])
sender_id body string No The displayed value of who sent the message
callback_url body string No A callback URL that will be used to send back information about updates of message status. Click here for more details.

You can estimate the cost of sending campaign message by changing the path to https://api.sms.to/sms/estimate. Click here for more details.

Send personalized messages

curl -L -X POST "https://api.sms.to/sms/send" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
    \"messages\": [
        {
            \"message\": \"This is a test message\",
            \"to\": \"+9779856034616\"
        },
        {
            \"message\": \"Hello world!\",
            \"to\": \"+35799585001\"
        }
    ],
    \"sender_id\": \"SMS.to\",
    \"callback_url\": \"https://sms.to/callback/handler\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/send",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"messages\": [\n        {\n            \"message\": \"This is a test message\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = "{\n    \"messages\": [\n        {\n            \"message\": \"This is a test message\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.sms.to/sms/send");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://api.sms.to',
  'path': '/sms/send',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n    \"messages\": [\n        {\n            \"message\": \"This is a test message\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/send")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n    \"messages\": [\n        {\n            \"message\": \"This is a test message\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = "{\n    \"messages\": [\n        {\n            \"message\": \"This is a test message\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/sms/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"message\": \"This is a test message\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/sms/send"
  method := "POST"

  payload := strings.NewReader("{\n    \"messages\": [\n        {\n            \"message\": \"This is a test message\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:


{
    "message": "Message is queued for sending! Please check report for update",
    "success": true
}

POST https://api.sms.to/sms/send

Send unique (personalized) messages to different phone numbers

Parameters

Parameter In Type Required Description
messages body array Yes Array containing JSON representation of messages and related recipient phone numbers. See below for more details.
sender_id body string No The displayed value of who sent the message
callback_url body string No A callback URL that will be used to send back information about updates of message status. Click here for more details.

The messages parameter that is specified in the body should include an array of messages and related recipient phone numbers in JSON format with following parameters:

Parameter Type Required Description
message string Yes Your message for the specified phone number.
to string No The recipient phone number

Example of messages array:

[{"message":"Hi John!", "to":"35794585001"}, {"message":"Hello Mike!", "to":"35794585002"}]

You can estimate the costs by changing the path to https://api.sms.to/sms/estimate. Click here for more details.

Schedule sending messages

curl -L -X POST "https://api.sms.to/sms/send" \
-H "Content-Type: application/json" \
-d "{
    \"messages\": [
        {
            \"message\": \"This is test\",
            \"to\": \"+9779856034616\"
        },
        {
            \"message\": \"This is test\",
            \"to\": \"+9779856034617\"
        }
    ],
    \"sender_id\": \"SMS.to\",
    \"callback_url\": \"https://sms.to/callback/handler\",
    \"scheduled_for\": \"2019-12-12 12:00:00\",
    \"timezone\": \"Asia/Kathmandu\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/send",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034617\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\",\n    \"scheduled_for\": \"2019-12-12 12:00:00\",\n    \"timezone\": \"Asia/Kathmandu\"\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034617\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\",\n    \"scheduled_for\": \"2019-12-12 12:00:00\",\n    \"timezone\": \"Asia/Kathmandu\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.sms.to/sms/send");
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://api.sms.to',
  'path': '/sms/send',
  'headers': {
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034617\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\",\n    \"scheduled_for\": \"2019-12-12 12:00:00\",\n    \"timezone\": \"Asia/Kathmandu\"\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/send")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034617\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\",\n    \"scheduled_for\": \"2019-12-12 12:00:00\",\n    \"timezone\": \"Asia/Kathmandu\"\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034617\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\",\n    \"scheduled_for\": \"2019-12-12 12:00:00\",\n    \"timezone\": \"Asia/Kathmandu\"\n}"
headers = {
  'Content-Type': 'application/json'
}
conn.request("POST", "/sms/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034617\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\",\n    \"scheduled_for\": \"2019-12-12 12:00:00\",\n    \"timezone\": \"Asia/Kathmandu\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/sms/send"
  method := "POST"

  payload := strings.NewReader("{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034617\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\",\n    \"scheduled_for\": \"2019-12-12 12:00:00\",\n    \"timezone\": \"Asia/Kathmandu\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "message": "Message is queued for sending! Please check report for update",
    "success": true
}

POST https://api.sms.to/sms/send

Schedule messages to send later

Parameters

For other (required and optional) parameters please take a look at Send personalized messages.

Parameter Type Required Description
scheduled_for string No Date and time when the message(s) will be sent. The required format is YEAR-MONTH-DAY HOUR:MINUTE:SECOND (e.g. 2020-09-30 20:47:07). If not specified, it will be sent immediately as personalized messages.
timezone string No The timezone that will be used. You need to specify the TZ database name.

Please note that if you do not provide the timezone parameter, then timezone from your SMS.to account settings will be used.

If you did not set the timezone (on your account settings and as a parameter), then the UTC timezone will be used by default.

Get messages

curl -L -X GET "https://api.sms.to/messages" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/messages",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.sms.to/messages");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://api.sms.to',
  'path': '/messages',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/messages")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("GET", "/messages", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://api.sms.to/messages")
  .method("GET", null)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/messages"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "current_page": 1,
    "data": [
        {
            "id": 1245184,
            "_id": "969ad54e-9dc2-4dec-b493-9481c661ce01",
            "campaign_id": null,
            "user_id": 8193,
            "sender_id": "SMSto",
            "message": "This is test",
            "to": "+9779856034616",
            "status": "SCHEDULED",
            "our_cost": 0,
            "client_cost": 0.113,
            "callback_url": "https://sms.to/callback/handler",
            "scheduled_for": 1576131300,
            "timezone": "0",
            "created_at": "2019-08-26 18:52:24",
            "updated_at": "2019-08-26 18:52:24",
            "provider_id": 21,
            "fallback_provider_id": null,
            "message_id": null,
            "sms_count": 1,
            "final_callback_sent": 0,
            "is_api": 1,
            "a2_code": "NP"
        }
    ],
    "first_page_url": "https://api.sms.to/messages?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "https://api.sms.to/messages?page=1",
    "next_page_url": null,
    "path": "https://api.sms.to/messages",
    "per_page": 50,
    "prev_page_url": null,
    "to": 8,
    "total": 8
}

GET https://api.sms.to/messages

Fetch paginated messages

Parameters

Parameter In Type Required Description Default Value
limit query integer No The number of messages per page. 100
page query integer No The page number. 1
search query string No Keywords to search for. This parameter can be used to filter messages by phone number, specific date, source type (how messages were sent - using web application or api)

Example of URL with query params (filter by the date of sending):

https://api.sms.to/messages?limit=10&page=1&search=2019-11-18

or filter by the recipient phone number:

https://api.sms.to/messages?limit=10&page=1&search=9779856034616

or show messages that were sent only using API:

https://api.sms.to/messages?limit=10&page=1&search=api

Get last message

curl -L -X GET "https://api.sms.to/last/message" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/last/message",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.sms.to/last/message");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://api.sms.to',
  'path': '/last/message',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/last/message")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("GET", "/last/message", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://api.sms.to/last/message")
  .method("GET", null)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/last/message"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "id": 1245184,
    "_id": "969ad54e-9dc2-4dec-b493-9481c661ce01",
    "campaign_id": null,
    "user_id": 8193,
    "sender_id": "SMSto",
    "message": "This is test",
    "to": "+9779856034616",
    "status": "SCHEDULED",
    "our_cost": 0,
    "client_cost": 0.113,
    "callback_url": "https://sms.to/callback/handler",
    "scheduled_for": 1576131300,
    "timezone": "0",
    "created_at": "2019-08-26 18:52:24",
    "updated_at": "2019-08-26 18:52:24",
    "provider_id": 21,
    "fallback_provider_id": null,
    "message_id": null,
    "sms_count": 1,
    "final_callback_sent": 0,
    "is_api": 1,
    "a2_code": "NP"
}

GET https://api.sms.to/last/message

Get the last message that you have sent

Get campaigns

curl -L -X GET "https://api.sms.to.test/campaigns" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/campaigns",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.sms.to.test/campaigns");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://api.sms.to.test',
  'path': '/campaigns',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to.test/campaigns")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to.test")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("GET", "/campaigns", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://api.sms.to.test/campaigns")
  .method("GET", null)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to.test/campaigns"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "current_page": 1,
    "data": [
        {
            "id": 65536,
            "_id": "abb44b64-700d-4ad6-a7e4-ba53d4db58b6",
            "type": "message",
            "campaign_name": "0",
            "user_id": 8193,
            "sender_id": "SMSto",
            "template_id": 0,
            "message": "This is test",
            "contacts": "+9779856034616, +9779856034617",
            "list_id": 0,
            "status": "ONGOING",
            "our_total_cost": 0,
            "client_total_cost": 0.226,
            "estimated_cost": 0.226,
            "delivered_messages": 0,
            "failed_messages": 0,
            "pending_messages": 2,
            "sent_messages": 0,
            "callback_url": null,
            "scheduled_for": null,
            "timezone": "0",
            "created_at": "2019-08-26 18:37:25",
            "updated_at": "2019-08-26 18:37:25",
            "sms_count": 1,
            "is_api": 1,
            "canceled_at": null
        }
    ],
    "first_page_url": "https://api.sms.to.test/campaigns?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "https://api.sms.to.test/campaigns?page=1",
    "next_page_url": null,
    "path": "https://api.sms.to.test/campaigns",
    "per_page": 50,
    "prev_page_url": null,
    "to": 1,
    "total": 1
}

GET https://api.sms.to.test/campaigns

Fetch paginated campaigns list

Parameters

Parameter In Type Required Description Default Value
limit query integer No The number of campaigns per page. 100
page query integer No The page number. 1
search query string No Keywords to search for. This parameter can be used to filter campaigns by phone number, specific date, source type (how messages were sent - using web application or api)

Example of URL with query params:

https://api.sms.to.test/campaigns?limit=10&page=1&search=2019-11-18

Get last campaign

curl -L -X GET "https://api.sms.to/last/campaign" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/last/campaign",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.sms.to/last/campaign");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://api.sms.to',
  'path': '/last/campaign',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/last/campaign")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("GET", "/last/campaign", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://api.sms.to/last/campaign")
  .method("GET", null)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/last/campaign"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "id": 65536,
    "_id": "abb44b64-700d-4ad6-a7e4-ba53d4db58b6",
    "type": "message",
    "campaign_name": "0",
    "user_id": 8193,
    "sender_id": "SMSto",
    "template_id": 0,
    "message": "This is test",
    "contacts": "+9779856034616, +9779856034617",
    "list_id": 0,
    "status": "ONGOING",
    "our_total_cost": 0,
    "client_total_cost": 0.226,
    "estimated_cost": 0.226,
    "delivered_messages": 0,
    "failed_messages": 0,
    "pending_messages": 2,
    "sent_messages": 0,
    "callback_url": null,
    "scheduled_for": null,
    "timezone": "0",
    "created_at": "2019-08-26 18:37:25",
    "updated_at": "2019-08-26 18:37:25",
    "sms_count": 1,
    "is_api": 1,
    "canceled_at": null
}

GET https://api.sms.to/last/campaign

Get the last campaign that you have sent

Estimate single message

curl -L -X POST "https://api.sms.to/sms/estimate" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
    \"message\": \"This is test\",
    \"to\": \"+9779856034616\",
    \"sender_id\": \"SMS.to\",
    \"callback_url\": \"https://sms.to/callback/handler\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/estimate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"message\": \"This is test\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n    \"message\": \"This is test\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.sms.to/sms/estimate");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://api.sms.to',
  'path': '/sms/estimate',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n    \"message\": \"This is test\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/estimate")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n    \"message\": \"This is test\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = "{\n    \"message\": \"This is test\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/sms/estimate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"message\": \"This is test\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/estimate")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/sms/estimate"
  method := "POST"

  payload := strings.NewReader("{\n    \"message\": \"This is test\",\n    \"to\": \"+9779856034616\",\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "sms_count": 1,
    "estimated_cost": 0.113,
    "contact_count": 1,
    "invalid_count": 0
}

POST https://api.sms.to/sms/estimate

Estimate the cost of sending single message

Parameters

Parameter In Type Required Description
message body string Yes Your message
to body string Yes Phone number
sender_id body string No The displayed value of who sent the message
callback_url body string No A callback URL that will be used to send back information about updates of message status. Click here for more details.

Estimate campaign message

curl -L -X POST "https://api.sms.to/sms/estimate" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
    \"message\": \"This is test\",
    \"to\": [
        \"+9779856034616\",
        \"+9779856034617\"
    ],
    \"sender_id\": \"SMS.to\",
    \"callback_url\": \"https://sms.to/callback/handler\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/estimate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"message\": \"This is test\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n    \"message\": \"This is test\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.sms.to/sms/estimate");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://api.sms.to',
  'path': '/sms/estimate',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n    \"message\": \"This is test\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/estimate")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n    \"message\": \"This is test\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = "{\n    \"message\": \"This is test\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/sms/estimate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"message\": \"This is test\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/estimate")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/sms/estimate"
  method := "POST"

  payload := strings.NewReader("{\n    \"message\": \"This is test\",\n    \"to\": [\n        \"+9779856034616\",\n        \"+9779856034617\"\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "sms_count": 1,
    "estimated_cost": 0.226,
    "contact_count": 2,
    "invalid_count": 0
}

POST https://api.sms.to/sms/estimate

Estimate the cost of sending message to multiple recipients (phone numbers)

Parameters

Parameter In Type Required Description
message body string Yes Your message
to body array Yes Array of phone number (e.g. ["+35794585001", "+35794585002"])
sender_id body string No The displayed value of who sent the message
callback_url body string No A callback URL that will be used to send back information about updates of message status. Click here for more details.

Estimate personalized message

curl -L -X POST "https://api.sms.to/sms/estimate" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
    \"messages\": [
        {
            \"message\": \"This is test\",
            \"to\": \"+9779856034616\"
        }
    ],
    \"sender_id\": \"SMS.to\",
    \"callback_url\": \"https://sms.to/callback/handler\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/estimate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}",
  CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var data = "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.sms.to/sms/estimate");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>");

xhr.send(data);
var https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'https://api.sms.to',
  'path': '/sms/estimate',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}";

req.write(postData);

req.end();
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/estimate")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
request.body = "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"

response = https.request(request)
puts response.read_body

import http.client
conn = http.client.HTTPSConnection("https://api.sms.to")
payload = "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/sms/estimate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/estimate")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")
  .build();
Response response = client.newCall(request).execute();
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.sms.to/sms/estimate"
  method := "POST"

  payload := strings.NewReader("{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+9779856034616\"\n        }\n    ],\n    \"sender_id\": \"SMS.to\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

RESPONSE:

{
    "estimated_cost": 0.113,
    "sms_count": 1,
    "min_sms_count": 1,
    "max_sms_count": 1,
    "contact_count": 2,
    "invalid_count": 0
}

POST https://api.sms.to/sms/estimate

Estimate the cost of sending unique (personalized) messages to different phone numbers

Parameters

Parameter In Type Required Description
messages body array Yes Array containing JSON representation of messages and related recipient phone numbers. See below for more details.
sender_id body string No The displayed value of who sent the message
callback_url body string No A callback URL that will be used to send back information about updates of message status. Click here for more details.

The messages parameter that is specified in the body should include an array of messages and related recipient phone numbers in JSON format with following parameters:

Parameter Type Required Description
message string Yes Your message for the specified phone number.
to string No The recipient phone number

Example of messages array:

[{"message":"Hi John!", "to":"35794585001"}, {"message":"Hello Mike!", "to":"35794585002"}]