NAV Navigation
Shell PHP Node.JS Ruby Python Java Go

Authentication

To make successful API requests, you need a verified account on SMS.to and 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:

Examples of using API Key as
Authorization Header :Authorization: Bearer IS8xkzlSzI5Kcw4uFNHyujSqlnaQunYL
Query String :https://yourdomain.com?api_key=IS8xkzlSzI5Kcw4uFNHyujSqlnaQunYL

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

Example of using Access Token
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGgtYXBpLnRlc3Qvb2F1dGgvdG9rZW4iLCJpYXQiOjE1NjY4Mzc1OTYsImV4cCI6MTU2NzQ0MjM5NiwibmJmIjoxNTY2ODM3NTk2LCJqdGkiOiI5RlhnbkRCSkgxaFh6NzB1Iiwic3ViIjo4MTkzLCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.U6NqFpbo1QQ4NP9F-xWDZJT5FG8cSN-ySkZgQsiG2kI

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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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("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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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("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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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("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>"

OR

// Using API Key via Query Param
curl -L -X GET "https://auth.sms.to/api/balance?api_key=API_KEY"
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "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;

OR

// Using API Key via Query Param

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://auth.sms.to/api/balance?api_key=API_KEY",
  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",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
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();

OR
// Usng API Key via Query Param
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'https://auth.sms.to',
  'path': '/api/balance?api_key=API_KEY',
  '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

OR
// Using API Key via Query Param
require "uri"
require "net/http"

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

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

request = Net::HTTP::Get.new(url)

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"))

OR
## Using API Key via Query Param

import http.client
conn = http.client.HTTPSConnection("https://auth.sms.to")
payload = ''
headers = {
  
}
conn.request("GET", "/api/balance?api_key=API_KEY", 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();


OR
// Using API Key via Query Param
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://auth.sms.to/api/balance?api_key=API_KEY")
  .method("GET", null)
  .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))
}

OR
// Using API Key via Query Param
package main

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

func main() {

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

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

  if err != nil {
    fmt.Println(err)
  }

  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/people/lists/create" \
-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.to/v1/people/lists/create",
  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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'sms.to',
  'path': '/v1/people/lists/create/',
  '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/people/lists/create")

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("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/people/lists/create/", 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/people/lists/create")
  .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/people/lists/create"
  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",
        "created_at": "2019-08-26 17:20:17"
    },
    "message": "List created."
}

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

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
share_with_team body boolean No This field allow list to be shared with team. 1 for sharing and 0 for NOT sharing with team

Create contact to list

curl --location --request POST 'https://sms.to/v1/people/contacts/create' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>' \
--data-raw '{
    "phone": "+35799596247",
    "firstname": "John",
    "lastname": "Doe",
    "email": "john.doe@sms.to",
    "custom1": "Custom A",
    "custom2": "Custom B",
    "is_optout": 0,
    "list_ids": 1
}'
 'https://sms.to/v1/people/contacts/create',
  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 =>'{
    "phone": "+35799596247",
    "firstname": "John",
    "lastname": "Doe",
    "email": "john.doe@sms.to",
    "custom1": "Custom A",
    "custom2": "Custom B",
    "is_optout": 0,
    "list_ids": 1
}',
  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 https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'sms.to',
  'path': '/v1/people/contacts/create',
  '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 = JSON.stringify({"phone":"+35799596247","firstname":"John","lastname":"Doe","email":"john.doe@sms.to","custom1":"Custom A","custom2":"Custom B","is_optout":0,"list_ids":1});

req.write(postData);

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

url = URI("https://sms.to/v1/people/contacts/create")

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    \"phone\": \"+35799596247\",\n    \"firstname\": \"John\",\n    \"lastname\": \"Doe\",\n    \"email\": \"john.doe@sms.to\",\n    \"custom1\": \"Custom A\",\n    \"custom2\": \"Custom B\",\n    \"is_optout\": 0,\n    \"list_ids\": 1\n}"

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

import http.client

conn = http.client.HTTPSConnection("sms.to")
payload = "{\n    \"phone\": \"+35799596247\",\n    \"firstname\": \"John\",\n    \"lastname\": \"Doe\",\n    \"email\": \"john.doe@sms.to\",\n    \"custom1\": \"Custom A\",\n    \"custom2\": \"Custom B\",\n    \"is_optout\": 0,\n    \"list_ids\": 1\n}"
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/v1/people/contacts/create", 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    \"phone\": \"+35799596247\",\n    \"firstname\": \"John\",\n    \"lastname\": \"Doe\",\n    \"email\": \"john.doe@sms.to\",\n    \"custom1\": \"Custom A\",\n    \"custom2\": \"Custom B\",\n    \"is_optout\": 0,\n    \"list_ids\": 1\n}");
Request request = new Request.Builder()
  .url("https://sms.to/v1/people/contacts/create")
  .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/people/contacts/create"
  method := "POST"

  payload := strings.NewReader(`{
    "phone": "+35799596247",
    "firstname": "John",
    "lastname": "Doe",
    "email": "john.doe@sms.to",
    "custom1": "Custom A",
    "custom2": "Custom B",
    "is_optout": 0,
    "list_ids": 1
}`)

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

  if err != nil {
    fmt.Println(err)
    return
  }
  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)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "message": "Contact created successfully."
}

POST https://sms.to/v1/people/contacts/create

Create contact into the specified list

Parameters

The parameters 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
list_ids string or array Yes List Ids to be imported to
email string No The email address
custom1 string No The custom field
custom2 string No The custom field

Fetch contacts from list

curl --location --request GET 'https://sms.to/v1/people/contacts?page=1&order_by=phone&direction=asc' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
 'https://sms.to/v1/people/contacts?page=1&order_by=phone&direction=asc',
  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 https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'sms.to',
  'path': '/v1/people/contacts?page=1&order_by=phone&direction=asc',
  '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/people/contacts?page=1&order_by=phone&direction=asc")

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>"
form_data = []
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body

import http.client
import mimetypes
from codecs import encode

conn = http.client.HTTPSConnection("sms.to")
boundary = ''
payload = ''
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>',
  'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("GET", "/v1/people/contacts?page=1&order_by=phone&direction=asc", 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/people/contacts?page=1&order_by=phone&direction=asc")
  .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"
  "bytes"
  "mime/multipart"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/people/contacts?page=1&order_by=phone&direction=asc"
  method := "GET"

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


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

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

  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

RESPONSE:

{
    "current_page": 1,
    "data": [
        {
            "id": 2,
            "user_id": 501,
            "network_id": 301,
            "is_optout": 0,
            "phone": "+35794585002",
            "firstname": "James",
            "lastname": "Constantinou",
            "email": "test_2@sms.to",
            "custom1": "custom A",
            "custom2": "custom B",
            "country_code": "357",
            "a2_code": "CY",
            "created_at": "2020-04-16 06:49:12",
            "updated_at": "2020-04-16 06:49:12",
            "deleted_at": null,
            "list_contacts": [
                {
                    "id": 7,
                    "user_list_id": 2,
                    "contact_id": 2,
                    "is_optout": 0,
                    "created_at": "2020-04-16 06:49:12",
                    "updated_at": "2020-04-16 06:49:12",
                    "deleted_at": null
                }
            ]
        }
    ],
    "first_page_url": "https://sms.to/v1/people/contacts?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "https://sms.to/v1/people/contacts?page=1",
    "next_page_url": null,
    "path": "https://sms.to/v1/people/contacts",
    "per_page": 15,
    "prev_page_url": null,
    "to": 2,
    "total": 2
}

GET https://sms.to/v1/people/contacts

Fetch paginated contacts of a list

Parameters

Parameter In Type Required Description Default Value
list_ids path string 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
order_by query string No Sort by firstname or lastname (ASC) firstname
direction query string No ASC or DESC ASC

Example of URL with query params:

https://sms.to/v1/people/contacts?page=1&order_by=phone&direction=asc

Fetch lists

curl --location --request GET 'https://sms.to/v1/people/lists?page=1&name=Red&direction=asc' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
 "https://sms.to/v1/people/lists?page=1&name=Red&direction=asc",
  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 https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'sms.to',
  'path': '/v1/people/lists?page=1&name=Red&direction=asc',
  '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/people/lists?page=1&name=Red&direction=asc")

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>"
form_data = []
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body

import http.client
import mimetypes
conn = http.client.HTTPSConnection("sms.to")
boundary = ''
payload = ''
headers = {
  'accept': 'application/json',
  'content-type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>',
  'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("GET", "/v1/people/lists?page=1&name=Red&direction=asc", 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/people/lists?page=1&name=Red&direction=asc")
  .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"
  "bytes"
  "mime/multipart"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sms.to/v1/people/lists?page=1&name=Red&direction=asc"
  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("accept", "application/json")
  req.Header.Add("content-type", "application/json")
  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:

{
  "current_page": 1,
  "data": [
    {
      "id": 3,
      "name": "Red",
      "description": "This list  shared with team members",
      "share_with_team": 1,
      "created_at": "2020-04-16 05:31:27",
      "updated_at": "2020-04-16 05:31:27",
      "list_contacts_count": 2
    }
  ],
  "first_page_url": "https://sms.to/v1/people/lists?page=1",
  "from": 1,
  "last_page": 1,
  "last_page_url": "https://sms.to/v1/people/lists?page=1",
  "next_page_url": null,
  "path": "https://sms.to/v1/people/lists",
  "per_page": 15,
  "prev_page_url": null,
  "to": 1,
  "total": 1
}

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

Fetch paginated lists

Parameters

Parameter In Type Required Description Default Value
page query integer No The page number. 1
name query string No Search list by name.
direction query string No The records are sorted by created_at. This field will provide direction: ASC or DESC ASC

Example of URL with query params:

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

Get Recent Optouts

curl --location --request GET 'https://sms.to/v1/recent/optouts?api_key=:API_KEY' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'
 "https://sms.to/v1/recent/optouts?api_key=:API_KEY",
  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"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'sms.to',
  'path': '/v1/recent/optouts?api_key=:API_KEY',
  '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);
  });
});

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

url = URI("https://sms.to/v1/recent/optouts?api_key=:API_KEY")

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"

response = https.request(request)
puts response.read_body
import http.client
import mimetypes
conn = http.client.HTTPSConnection("sms.to")
payload = ''
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json'
}
conn.request("GET", "/v1/recent/optouts?api_key=:API_KEY", 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/recent/optouts?api_key=:API_KEY")
  .method("GET", null)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
package main

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

func main() {

  url := "https://sms.to/v1/recent/optouts?api_key=:API_KEY"
  method := "GET"

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

  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:

[
    {
        "timestamp": "2020-05-28 04:21:43 UTC",
        "unsubscribed_number": "+9779801634616",
        "source": "List: 13159",
        "id": 1
    }
]

GET https://sms.to/v1/recent/optouts

You will be able to get optouts detail that were opted out in last 1hr

Optin contacts

curl --location --request POST 'https://sms.to/v1/people/contacts/optin' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>' \
--data-raw '{
    "phone": "+35799596247",
    "list_id": 1
}'

 'https://sms.to/v1/people/contacts/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 =>'{
    "phone": "+35799596247",,
    "list_id": 1
}',
  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 https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'sms.to',
  'path': '/v1/people/contacts/optin',
  '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 = JSON.stringify({"phone":"+35799596247","list_id":1});

req.write(postData);

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

url = URI("https://sms.to/v1/people/contacts/optin")

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    \"phone\": \"+35799596247\",\n    \"list_id\": 1\n}"

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

import http.client

conn = http.client.HTTPSConnection("sms.to")
payload = "{\n    \"phone\": \"+35799596247\",\n    \"list_id\": 1\n}"
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/v1/people/contacts/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    \"phone\": \"+35799596247\",\n    \"list_idxxxxxxxx\": 1\n}");
Request request = new Request.Builder()
  .url("https://sms.to/v1/people/contacts/optin")
  .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/people/contacts/optin"
  method := "POST"

  payload := strings.NewReader(`{
    "phone": "+35799596247",
    "list_idc ": 1
}`)

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

  if err != nil {
    fmt.Println(err)
    return
  }
  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)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "message": "Contact Optin successfully."
}

POST https://sms.to/v1/people/contacts/optin

Optin Contact to a list or system list (Remove list_id from request payload)

Parameters

The parameters 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.
list_id string or array No List Ids to optin to

Optout contacts

curl --location --request POST 'https://sms.to/v1/people/contacts/optout' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>' \
--data-raw '{
    "phone": "+35799596247",
    "list_id": 1
}'

 'https://sms.to/v1/people/contacts/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 =>'{
    "phone": "+35799596247",,
    "list_id": 1
}',
  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 https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'sms.to',
  'path': '/v1/people/contacts/optout',
  '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 = JSON.stringify({"phone":"+35799596247","list_id":1});

req.write(postData);

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

url = URI("https://sms.to/v1/people/contacts/optout")

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    \"phone\": \"+35799596247\",\n    \"list_id\": 1\n}"

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

import http.client

conn = http.client.HTTPSConnection("sms.to")
payload = "{\n    \"phone\": \"+35799596247\",\n    \"list_id\": 1\n}"
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/v1/people/contacts/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    \"phone\": \"+35799596247\",\n    \"list_idxxxxxxxx\": 1\n}");
Request request = new Request.Builder()
  .url("https://sms.to/v1/people/contacts/optout")
  .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/people/contacts/optout"
  method := "POST"

  payload := strings.NewReader(`{
    "phone": "+35799596247",
    "list_idc ": 1
}`)

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

  if err != nil {
    fmt.Println(err)
    return
  }
  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)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "message": "Contact Optout successfully."
}

POST https://sms.to/v1/people/contacts/optout

Optout Contact to a list or system list (Remove list_id from request payload)

Parameters

The parameters 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.
list_id string or array No List Ids to optout to

Delete list

curl --location --request DELETE 'https://sms.to/v1/people/lists/3020/delete' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
 'https://sms.to/v1/people/lists/3020/delete',
  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',
  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 https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'DELETE',
  'hostname': 'sms.to',
  'path': '/v1/people/lists/3020/delete',
  '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/people/lists/3020/delete")

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

request = Net::HTTP::Delete.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"
form_data = []
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body


import http.client
import mimetypes
from codecs import encode

conn = http.client.HTTPSConnection("sms.to")
boundary = ''
payload = ''
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>',
  'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("DELETE", "/v1/people/lists/3020/delete", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main

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

func main() {

  url := "https://sms.to/v1/people/lists/3020/delete"
  method := "DELETE"

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


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

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

  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

RESPONSE:

{
    "success": true,
    "message": "List deleted successfully."
}

DELETE https://sms.to/v1/people/lists/3020/delete

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 test and \n this is a new line\",
    \"to\": \"+35799999999999\",
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/callback/handler\"
}"

OR
// Using API Key via Query Param
curl -L -X GET "https://api.sms.to/sms/send?api_key={api_key}&to=9779856034616&message=This is test and %0A this is a new line&sender_id=smsto"\
<?php

$curl = curl_init();

$headers = ["Content-Type: application/json",
	    "Accept: application/json",
	    "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>"];

$params = ['to' => '+35799999999999',
	    'message' => "This is test \n   This is a new line",
	    //'callback_url' => "https://example.com/callback/handler",
	    'sender_id' => 'SMSto'];

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 => json_encode($params),  
  CURLOPT_HTTPHEADER => $headers,
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

OR
// Using API Key via Query Param

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/send?api_key={api_key}&to=9779856034616&message=This is test and %0A this is a new line&sender_id=smsto",  
  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",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

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

var options = {
  'method': 'POST',
  'hostname': '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 test and \n this is a new line\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}";

req.write(postData);

req.end();

OR
// Using API Key via Query Param
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'api.sms.to',
  'path': '/sms/send?api_key={api_key}&to=9779856034616&message=This is test and %0A this is a new line&sender_id=smsto',  
  '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://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 test and \n this is a new line\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}"

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

OR
// Using API Key via Query Param
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/send?api_key={api_key}&to=9779856034616&message=This is test and %0A this is a new line&sender_id=smsto")

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

request = Net::HTTP::Get.new(url)

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

import http.client
import json
conn = http.client.HTTPSConnection("api.sms.to")
payload = {
    "message" : "This is testÄ and \n this is a new line", 
    "to" : "+35799999999999", 
    "sender_id" : "SMSto"
    }
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/sms/send", json.dumps(payload), headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

OR
// Using API Key via Query Param
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = ""

conn.request("POST", "/sms/send?api_key={api_key}&to=9779856034616&message=This is test and %0A this is a new line&sender_id=smsto", 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 and \n this is a new line\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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();

OR
// Using API Key via Query Param
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/send?api_key={api_key}&to=9779856034616&message=This is test and %0A this is a new line&sender_id=smsto")
  .method("GET", body)
  .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 test and \n this is a new line\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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))
}

OR
// Using API Key via Query Param
package main

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

func main() {

  url := "https://api.sms.to/sms/send?api_key={api_key}&to=9779856034616&message=This is test and %0A this is a new line&sender_id=smsto"  
  method := "GET"

  payload := strings.NewReader("")

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

  if err != nil {
    fmt.Println(err)
  }

  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 More info
callback_url body string No A callback URL that will be used to send back information about updates of message status. See here 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.

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\": [
        \"+35799999999999\",
        \"+35799999999998\"
    ],
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}"

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

import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\n    \"message\": \"This is a test message\",\n    \"to\": [\n        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 More info
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 Message to a list or multiple list in array

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 test\",
    \"list_id\": 1,
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/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 test\",\n    \"list_id\": 1,\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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 test\",\n    \"list_id\": 1,\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 test\",\n    \"list_id\": 1,\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}"

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

import http.client
import json
conn = http.client.HTTPSConnection("api.sms.to")
payload = {
    "message" : "This is testÄ", 
    "to" : "+35799999999999", 
    "sender_id" : "SMSto"
    }
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/sms/send", json.dumps(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    \"list_id\": 1,\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 test\",\n    \"list_id\": 1,\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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": "e7745289-7236-497f-acf2-f9cfd6a86f16"
}

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

Send Message to a list or multiple list in array

Parameters

Parameter In Type Required Description
message body string Yes Your message
list_id body string Yes List ID
sender_id body string No The displayed value of who sent the message More info
callback_url body string No A callback URL that will be used to send back information about updates of message status. See 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\": \"+35799999999999\"
        },
        {
            \"message\": \"Hello world!\",
            \"to\": \"+35799585001\"
        }
    ],
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}"

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

import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\n    \"messages\": [\n        {\n            \"message\": \"This is a test message\",\n            \"to\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 More info
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\": \"+35799999999999\"
        },
        {
            \"message\": \"This is test\",
            \"to\": \"+35799999999998\"
        }
    ],
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+35799999999998\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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\": \"+35799999999999\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+35799999999998\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+35799999999998\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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("api.sms.to")
payload = "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+35799999999999\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+35799999999998\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+35799999999998\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        },\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+35799999999998\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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.

Send flash message

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

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/fsms/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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}";

req.write(postData);

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

url = URI("https://api.sms.to/fsms/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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}"

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

import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\n    \"message\": \"This is a test message\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/fsms/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/fsms/send"
  method := "POST"

  payload := strings.NewReader("{\n    \"message\": \"This is a test message\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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/fsms/send

Send flash 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 More info
callback_url body string No A callback URL that will be used to send back information about updates of message status. See here 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.

Send viber message

curl -L -X POST "https://api.sms.to/viber/send" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
    \"message\": \"This is a test message\",
    \"to\": \"+35799999999999\",
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/callback/handler\",
    \"viber_image_url\": \"https://example.com/callback/handler\",
    \"viber_target_url\": \"https://example.com/callback/handler\",
    \"viber_caption\": \"Test\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/viber/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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\",\"viber_image_url\": \"https://example.com/callback/handler\",\"viber_target_url\": \"https://example.com/callback/handler\",\"viber_caption\": \"Test\"\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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'api.sms.to',
  'path': '/viber/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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\",\"viber_image_url\": \"https://example.com/callback/handler\",\"viber_target_url\": \"https://example.com/callback/handler\",\"viber_caption\": \"Test\"\n}";

req.write(postData);

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

url = URI("https://api.sms.to/viber/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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\",\"viber_image_url\": \"https://example.com/callback/handler\",\"viber_target_url\": \"https://example.com/callback/handler\",\"viber_caption\": \"Test\"\n}"

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

import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\n    \"message\": \"This is a test message\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\",\"viber_image_url\": \"https://example.com/callback/handler\",\"viber_target_url\": \"https://example.com/callback/handler\",\"viber_caption\": \"Test\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/viber/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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\",\"viber_image_url\": \"https://example.com/callback/handler\",\"viber_target_url\": \"https://example.com/callback/handler\",\"viber_caption\": \"Test\"\n}");
Request request = new Request.Builder()
  .url("https://api.sms.to/viber/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/viber/send"
  method := "POST"

  payload := strings.NewReader("{\n    \"message\": \"This is a test message\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\",\"viber_image_url\": \"https://example.com/callback/handler\",\"viber_target_url\": \"https://example.com/callback/handler\",\"viber_caption\": \"Test\"\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/viber/send

Send viber 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 More info
callback_url body string No A callback URL that will be used to send back information about updates of message status. See here for more details.
viber_image_url body string Yes Image URL to Viber
viber_target_url body string Yes Target URL
viber_caption body string No Message Caption

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.

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 https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': '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("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": "+35799999999999",
            "status": "SCHEDULED",
            "our_cost": 0,
            "client_cost": 0.113,
            "callback_url": "https://example.com/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. 15
order_direction query string No Sort messages. desc
order_by query string No Field to sort by created_at
status query string No Filter by created at REJECTED
created_at query string No Filter by status 2020-03-09
to query string No Filter by recipient number +3579865333

Get message by id

curl -L -X GET "https://api.sms.to/message/:id" \
-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/message/:id",
  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 https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'api.sms.to',
  'path': '/message/:id',
  '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/message/:id")

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("api.sms.to")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("GET", "/message/:id", 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/message/:id")
  .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/message/:id"
  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": "969ad54e-9dc2-4dec-b493-9481c661ce01",
    "campaign_id": null,
    "sender_id": "SMSto",
    "message": "This is test",
    "to": "+35799999999999",
    "status": "SCHEDULED",
    "cost": 0.113,
    "callback_url": "https://example.com/callback/handler",
    "scheduled_for": 1576131300,
    "sms_count": 1,
    "type": "sms",
    "sent_at": "2020-05-27 12:17:00"
}

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

Get the message that you have sent by ID

Get Recent Incoming SMS

curl --location --request GET 'https://sms.to/v1/recent/inbound-sms?api_key=:API_KEY' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'
 "https://sms.to/v1/recent/inbound-sms?api_key=:API_KEY",
  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"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'sms.to',
  'path': '/v1/recent/inbound-sms?api_key=:API_KEY',
  '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);
  });
});

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

url = URI("https://sms.to/v1/recent/inbound-sms?api_key=:API_KEY")

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"

response = https.request(request)
puts response.read_body
import http.client
import mimetypes
conn = http.client.HTTPSConnection("sms.to")
payload = ''
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json'
}
conn.request("GET", "/v1/recent/inbound-sms?api_key=:API_KEY", 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/recent/inbound-sms?api_key=:API_KEY")
  .method("GET", null)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
package main

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

func main() {

  url := "https://sms.to/v1/recent/inbound-sms?api_key=:API_KEY"
  method := "GET"

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

  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:

[
    {
        "from": "+357123346657",
        "to": "+357123346789",
        "parts": 1,
        "message": "Test for output",
        "receivedDate": "2020-05-28T04:32:08Z",
        "id": 1
    }
]

GET https://sms.to/v1/recent/inbound-sms

You will be able to get inbound-sms detail that were received in last 1hr on your rented number

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 https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': '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("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": "+35799999999999",
    "status": "SCHEDULED",
    "our_cost": 0,
    "client_cost": 0.113,
    "callback_url": "https://example.com/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/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 https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'api.sms.to',
  '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/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("api.sms.to")
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/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/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": "+35799999999999, +35799999999998",
            "list_id": 0,
            "status": "ONGOING",
            "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/campaigns?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "https://api.sms.to/campaigns?page=1",
    "next_page_url": null,
    "path": "https://api.sms.to/campaigns",
    "per_page": 50,
    "prev_page_url": null,
    "to": 1,
    "total": 1
}

GET https://api.sms.to/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/campaigns?limit=10&page=1&search=2019-11-18

Get campaign By ID

curl -L -X GET "https://api.sms.to/campaigns/{{id}}" \
-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/{{id}}",
  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 https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'api.sms.to',
  'path': '/campaigns/{{id}}',
  '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/campaigns/{{id}}")

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("api.sms.to")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("GET", "/campaigns/{{id}}", 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/campaigns/{{id}}")
  .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/campaigns/{{id}}"
  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": "+35799999999999, +35799999999998",
    "list_id": 0,
    "status": "ONGOING",
    "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/campaigns/{{id}}

Fetch Campaign By ID

Example of URL with query params:

https://api.sms.to/campaigns/{{id}}

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 https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': '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("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": "+35799999999999, +35799999999998",
    "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\": \"+35799999999999\",
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/callback/handler\"
}"

OR
// Using API Key via Query Param
curl -L -X GET "https://api.sms.to/sms/estimate?api_key={api_key}&to=9779856034616&message=test&sender_id=smsto"\
<?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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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;

OR
// Using API Key via Query Param

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sms.to/sms/estimate?api_key={api_key}&to=9779856034616&message=test&sender_id=smsto",
  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",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

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

var options = {
  'method': 'POST',
  'hostname': '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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}";

req.write(postData);

req.end();

OR
// Using API Key via Query Param
var https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'api.sms.to',
  'path': '/sms/estimate?api_key={api_key}&to=9779856034616&message=test&sender_id=smsto',
  '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://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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}"

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

OR
// Using API Key via Query Param
require "uri"
require "net/http"

url = URI("https://api.sms.to/sms/estimate?api_key={api_key}&to=9779856034616&message=test&sender_id=smsto")

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

request = Net::HTTP::Get.new(url)

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

import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\n    \"message\": \"This is test\",\n    \"to\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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"))

OR
// Using API Key via Query Param
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = ""

conn.request("POST", "/sms/estimate?api_key={api_key}&to=9779856034616&message=test&sender_id=smsto", 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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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();

OR
// Using API Key via Query Param
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://api.sms.to/sms/estimate?api_key={api_key}&to=9779856034616&message=test&sender_id=smsto")
  .method("GET", body)
  .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\": \"+35799999999999\",\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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))
}

OR
// Using API Key via Query Param
package main

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

func main() {

  url := "https://api.sms.to/sms/estimate?api_key={api_key}&to=9779856034616&message=test&sender_id=smsto"
  method := "GET"

  payload := strings.NewReader("")

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

  if err != nil {
    fmt.Println(err)
  }

  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 More info
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\": [
        \"+35799999999999\",
        \"+35799999999998\"
    ],
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}"

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

import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\n    \"message\": \"This is test\",\n    \"to\": [\n        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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        \"+35799999999999\",\n        \"+35799999999998\"\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 More info
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\": \"+35799999999999\"
        }
    ],
    \"sender_id\": \"SMSto\",
    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': '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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/callback/handler\"\n}"

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

import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\n    \"messages\": [\n        {\n            \"message\": \"This is test\",\n            \"to\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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\": \"+35799999999999\"\n        }\n    ],\n    \"sender_id\": \"SMSto\",\n    \"callback_url\": \"https://example.com/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 More info
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"}]

Shortlinks

Everything about creating and manipulating shortlinks. For more details about shortlinks, please visit: https://intergo.freshdesk.com/support/solutions/articles/43000522806-how-to-use-shortlink

curl -L -X POST "https://sms.to/api/v1/shortlink/" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>" \
-d "{
	\"name\": \"Google\",
	\"url\": \"https://www.google.com\"
}"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://sms.to/api/v1/shortlink/",
  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\": \"Google\",\n\t\"url\": \"https://www.google.com\"\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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'sms.to',
  'path': '/api/v1/shortlink/',
  '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\": \"Google\",\n\t\"url\": \"https://www.google.com\"\n}";

req.write(postData);

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

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

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\": \"Google\",\n\t\"url\": \"https://www.google.com\"\n}"

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

import http.client
conn = http.client.HTTPSConnection("sms.to")
payload = "{\n\t\"name\": \"Google\",\n\t\"url\": \"https://www.google.com\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/api/v1/shortlink/", 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\": \"Google\",\n\t\"url\": \"https://www.google.com\"\n}");
Request request = new Request.Builder()
  .url("https://sms.to/api/v1/shortlink/")
  .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/api/v1/shortlink/"
  method := "POST"

  payload := strings.NewReader("{\n	\"name\": \"Google\",\n	\"url\": \"https://www.google.com\"\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":29,
        "user_id":2,
        "name":"Google",
        "shortlink":"aaKC4",
        "fullLink":"sms.to/l/aaKC4",
        "ctr":null,
        "url":"https://google.com",
        "clicks":null,
        "last_click_at":null,
        "created_at":"2020-07-15 19:26"
    },
    "message":"Shortlink has been successfully created."
}

POST https://sms.to/api/v1/shortlink

Create a new shortlink

Parameters

Parameter In Type Required Description
name body string Yes Your shortlink name
url body string Yes URL of the shortlink (including https:// or http://)
curl -L -X GET "https://sms.to/api/v1/shortlinks/" \
-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.to/api/v1/shortlinks/",
  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 https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'sms.to',
  'path': '/api/v1/shortlinks/',
  '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/api/v1/shortlinks/")

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("sms.to")
boundary = ''
payload = ''
headers = {
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>',
  'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("GET", "/api/v1/shortlinks/", 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/api/v1/shortlinks/")
  .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/api/v1/shortlinks/"
  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":2,
            "name":"YouTube",
            "shortlink":"OgUL2",
            "fullLink":"sms.to/l/OgUL2",
            "ctr":"No info",
            "url":"https://www.youtube.com",
            "clicks":null,
            "last_click_at":null,
            "created_at":"2020-02-14 16:56"
        },
        {
            "id":2,
            "user_id":2,
            "name":"Google",
            "shortlink":"IyUE8",
            "fullLink":"sms.to/l/IyUE8",
            "ctr":"100%",
            "url":"https://www.google.com",
            "clicks":5,
            "last_click_at":null,
            "created_at":"2020-02-14 16:56"
        },
        {
            "id":3,
            "user_id":2,
            "name":"Yahoo - UNIQUE SHORTLINK",
            "shortlink":"Unique per number",
            "fullLink":"Unique per number",
            "ctr":"225 %",
            "url":"https://yahoo.com/",
            "clicks":9,
            "last_click_at":"2020-02-12 13:09",
            "created_at":"2020-02-12 12:30"
        }
    ],
    "success": true,
    "message": "Data fetched successfully."
}

GET https://sms.to/api/v1/shortlinks

Get paginated shortlinks

Parameters

Parameter In Type Required Description Default Value
limit query integer No The number of shortlinks per page. 20
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

Example of URL with query params:

https://sms.to/api/v1/shortlinks?limit=10&page=1&sort=created_at

curl -L -X GET "https://sms.to/api/v1/shortlinks/5" \
-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.to/api/v1/shortlinks/5",
  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 https = require('follow-redirects').https;

var options = {
  'method': 'GET',
  'hostname': 'sms.to',
  'path': '/api/v1/shortlinks/5',
  '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/api/v1/shortlinks/5")

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("sms.to")
boundary = ''
payload = ''
headers = {
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>',
  'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("GET", "/api/v1/shortlinks/5", 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/api/v1/shortlinks/5")
  .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/api/v1/shortlinks/5"
  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,
            "os":"Linux",
            "os_icon":"linux",
            "device":"Desktop",
            "country":"United States",
            "flag":"us",
            "num_clicks":10,
            "first_click":"2020-02-12 14:47:05",
            "last_click":"2020-04-08 07:37:49",
            "created_at":"2020-02-12 14:47:05",
            "updated_at":"2020-04-08 07:37:49",
            "mobile_number":"",
            "browser":"Chrome",
            "language":"en-us, en"
        }
    ]
}

GET https://sms.to/api/v1/shortlinks/id

Get shortlink details

Parameters

Parameter In Type Required Description
id URL integer Yes The id of the shortlink.

Example of URL with id parameter:

https://sms.to/api/v1/shortlinks/5

curl -L -X POST "https://sms.to/api/v1/shortlinks/5/delete" \
-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.to/api/v1/shortlinks/5/delete",
  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 =>"",
  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 https = require('follow-redirects').https;

var options = {
  'method': 'POST',
  'hostname': 'sms.to',
  'path': '/api/v1/shortlinks/5/delete',
  '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 =  "";

req.write(postData);

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

url = URI("https://sms.to/api/v1/shortlinks/5/delete")

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 = ""

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

import http.client
conn = http.client.HTTPSConnection("sms.to")
payload = ""
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <YOUR_API_KEY_OR_ACCESS_TOKEN>'
}
conn.request("POST", "/api/v1/shortlinks/5/delete", 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://sms.to/api/v1/shortlinks/5/delete")
  .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/api/v1/shortlinks/5/delete"
  method := "POST"

  payload := strings.NewReader("")

  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":"Shortlink deleted successfully"
}

POST https://sms.to/api/v1/shortlinks/id/delete

Delete the specified shortlink

Parameters

Parameter In Type Required Description
id URL integer Yes The id of the shortlink.

Example of URL with id parameter:

https://sms.to/api/v1/shortlinks/5/delete