API Endpoints
Requesting access-token
POST: https://api.sms.to/v1/oauth/token
Once you have created an API client, you may request an access token by issuing a POST request to this route with the user's email address, password, client_id and client_secret.
Headers
Header | Value |
---|---|
Accept | application/json |
Body
Parameter | Value | Required |
---|---|---|
grant_type | password | Yes |
client_id | xyz | Yes |
client_secret | xxyyzzxxyyzzxxyyzzxxyyzz | Yes |
username | your@email.com | Yes |
password | your-password | Yes |
scope | * | Yes |
curl --location --request POST "https://api.sms.to/v1/oauth/token" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"grant_type\": \"password\",
\"client_id\": xyz,
\"client_secret\": \"xxyyzzxxyyzzxxyyzzxxyyzzxxyyzzxxyyzz\",
\"username\": \"your@email.com\",
\"password\": \"your-password\",
\"scope\": \"*\"
}"
axios.post('https://api.sms.to/v1/oauth/token', {
grant_type: 'password',
client_id: 'xyz',
client_secret: 'xxyyzzxxyyzzxxyyzzxxyyzzxxyyzzxxyyzz',
username: 'your@email.com',
password: 'your-password',
scope: '*',
}).then(function (response) {
console.log(response);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sms.to/v1/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>'{"grant_type": "password","client_id": xyz,"client_secret": "xxyyzzxxyyzzxxyyzzxxyyzzxxyyzzxxyyzz","username": "your@email.com","password": "your@email.com","scope": "*"}',
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Accept: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
?>
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"grant_type\": \"password\",\"client_id\": xyz,\"client_secret\": \"xxyyzzxxyyzzxxyyzzxxyyzzxxyyzzxxyyzz\",\"username\": \"your@email.com\",\"password\": \"your@email.com\",\"scope\": \"*\"}");
Request request = new Request.Builder()
.url("https://api.sms.to/v1/oauth/token")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.sms.to/v1/oauth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddParameter("application/json", "{\"grant_type\": \"password\",\"client_id\": xyz,\"client_secret\": \"xxyyzzxxyyzzxxyyzzxxyyzzxxyyzzxxyyzz\",\"username\": \"your@email.com\",\"password\": \"your@email.com\",\"scope\": \"*\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\"grant_type\": \"password\",\"client_id\": xyz,\"client_secret\": \"xxyyzzxxyyzzxxyyzzxxyyzzxxyyzzxxyyzz\",\"username\": \"your@email.com\",\"password\": \"your@email.com\",\"scope\": \"*\"}"
headers = {
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "/v1/oauth/token", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://api.sms.to/v1/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Accept"] = 'application/json'
request.body = "{\"grant_type\": \"password\",\"client_id\": xyz,\"client_secret\": \"xxyyzzxxyyzzxxyyzzxxyyzzxxyyzzxxyyzz\",\"username\": \"your@email.com\",\"password\": \"your@email.com\",\"scope\": \"*\"}"
response = http.request(request)
puts response.read_body
Response
{
"token_type": "Bearer",
"expires_in": "xyzxyz",
"access_token": "xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"refresh_token": "xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz"
}
Get Balance
POST: https://api.sms.to/v1/balance
Get Current Balance
Headers
Header | Value |
---|---|
Accept | application/json |
curl --location --request POST "https://api.sms.to/v1/balance --header "Accept: application/json"
axios.post('https://api.sms.to/v1/balance', {}).then(function (response) {
console.log(response);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sms.to/v1/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Accept: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
?>
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{}");
Request request = new Request.Builder()
.url("https://api.sms.to/v1/balance")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.sms.to/v1/balance");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{}"
headers = {
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "/v1/balance", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://api.sms.to/v1/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Accept"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body
Response
{
"balance": 123,
"currency": "EUR"
}
Sending single SMS to one number
POST: https://api.sms.to/v1/sms/single/send
Sends personalized SMS to a single number or array of numbers with personalized SMS.
Headers
Header | Value |
---|---|
Accept | application/json |
Authorization | Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz |
Body
Parameter | Value | Required |
---|---|---|
messages | [{"to": "+355692179931", "message": "This is test SMS for +355692179931"}] | Yes |
sender_id | SMS.to | No |
callback_url | https://your-website.com/handle-notification | No |
messages
- Array of destination numbers with their respective personalized messages to be sent
sender_id
- the sender ID which is optional
callback_url
- this will be an optional URL where we will POST some information about the status of SMS as soon as we have an update
To send SMS to a single number
curl --location --request POST "https://api.sms.to/v1/sms/single/send" \
--header "Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data "{
\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}],
\"sender_id\": \"SMS.to\",
\"callback_url\": \"https://your-website.com/handle-notification\"
}"
To send personalized SMS to multiple numbers
curl --location --request POST "https://api.sms.to/v1/sms/single/send" \
--header "Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data "{
\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}, {\"to\":\"+355692179932\", \"message\": \"This is a message to +355692179932\"}],
\"sender_id\": \"SMS.to\",
\"callback_url\": \"https://your-website.com/handle-notification\"
}"
To send SMS to a single number
let config = {
headers: {
"Authorization": "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept": "application/json",
"Content-Type": "application/json"
}
};
axios.post('https://api.sms.to/v1/sms/single/send', {
messages: [{"to":"+355692179931", "message": "This is a message to +355692179931"}],
sender_id: 'SMS.to',
callback_url: 'https://your-website.com/handle-notification'
}, config).then(function (response) {
console.log(response);
});
To send personalized SMS to multiple numbers
let config = {
headers: {
"Authorization": "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept": "application/json",
"Content-Type": "application/json"
}
};
axios.post('https://api.sms.to/v1/sms/single/send', {
messages: [{"to":"+355692179931", "message": "This is a message to +355692179931"}, {"to":"+355692179932", "message": "This is a message to +355692179932"}],
sender_id: 'SMS.to',
callback_url: 'https://your-website.com/handle-notification'
}, config).then(function (response) {
console.log(response);
});
To send SMS to a single number
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sms.to/v1/sms/single/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>'{"messages":[{"to":"+355692179931", "message": "This is a message to +355692179931"}],"sender_id":"SMS.to","caller_id":"https://your-website.com/handle-notification"}',
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept: application/json",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
?>
To send personalized SMS to multiple numbers
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sms.to/v1/sms/single/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>'{"messages":[{"to":"+355692179931", "message": "This is a message to +355692179931"}, {"to":"+355692179932", "message": "This is a message to +355692179932"}],"sender_id":"SMS.to","caller_id":"https://your-website.com/handle-notification"}',
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept: application/json",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
?>
To send SMS to a single number
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, {
\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}],
\"sender_id\": \"SMS.to\",
\"callback_url\": \"https://your-website.com/handle-notification\"
}");
Request request = new Request.Builder()
.url("https://api.sms.to/v1/sms/single/send")
.post(body)
.addHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
To send personalized SMS to multiple numbers
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}, {\"to\":\"+355692179932\", \"message\": \"This is a message to +355692179932\"}],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"
}");
Request request = new Request.Builder()
.url("https://api.sms.to/v1/sms/single/send")
.post(body)
.addHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
To send SMS to single number
var client = new RestClient("https://api.sms.to/v1/sms/single/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddParameter("application/json", "{\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
To send personalized SMS to multiple numbers
var client = new RestClient("https://api.sms.to/v1/sms/single/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddParameter("application/json", "{\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}, {\"to\":\"+355692179932\", \"message\": \"This is a message to +355692179932\"}],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
To send SMS to single number
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}"
headers = {
'Authorization': "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "/v1/sms/single/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
To send personalized SMS to multiple numbers
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}, {\"to\":\"+355692179932\", \"message\": \"This is a message to +355692179932\"}],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}"
headers = {
'Authorization': "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "/v1/sms/single/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
To send SMS to single number
require 'uri'
require 'net/http'
url = URI("https://api.sms.to/v1/sms/single/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'
request["Content-Type"] = 'application/json'
request["Accept"] = 'application/json'
request.body = "{\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}"
response = http.request(request)
puts response.read_body
To send personalized SMS to multiple numbers
require 'uri'
require 'net/http'
url = URI("https://api.sms.to/v1/sms/single/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'
request["Content-Type"] = 'application/json'
request["Accept"] = 'application/json'
request.body = "{\"messages\": [{\"to\":\"+355692179931\", \"message\": \"This is a message to +355692179931\"}, {\"to\":\"+355692179932\", \"message\": \"This is a message to +355692179932\"}],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}"
response = http.request(request)
puts response.read_body
Response
{
"success": true,
"message": "Messages are queued for sending. Please check message logs on dashboard"
}
Sending single SMS to multiple numbers
POST: https://api.sms.to/v1/sms/send
This will send a message to multiple numbers specified in request body.
Headers
Header | Value |
---|---|
Accept | application/json |
Authorization | Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz |
Body
Parameter | Value | Required |
---|---|---|
body | A new post on your favourite forum. Check it out. | Yes |
to | ["+355692179931", "+355684064062"] | Yes |
sender_id | SMS.to | No |
callback_url | https://your-website.com/handle-notification | No |
body
- the textual part of the SMS
to
- the destination numbers
sender_id
- the sender ID which is optional
callback_url
- this will be an optional URL where we will POST some information about the status of SMS as soon as we have an update
curl --location --request POST "https://{{API_DOMAIN}}/v1/sms/send" \
--header "Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data "{
\"body\": \"A new post on your favourite forum. Check it out.\",
\"to\": [\"+355692179931\", \"+355684064062\"],
\"sender_id\": \"SMS.to\",
\"callback_url\": \"https://your-website.com/handle-notification\"
}"
let config = {
headers: {
"Authorization": "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept": "application/json",
"Content-Type": "application/json"
}
};
axios.post('https://api.sms.to/v1/sms/send', {
body: 'A new post on your favourite forum. Check it out.',
to: ['+355692179931', '+355684064062'],
sender_id: 'SMS.to',
callback_url: 'https://your-website.com/handle-notification'
}, config).then(function (response) {
console.log(response);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sms.to/v1/sms/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>'{"body": "A new post on your favourite forum. Check it out.","to": ["+355692179931", "+355684064062"],"sender_id": "SMS.to","callback_url": "https://your-website.com/handle-notification"}',
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept: application/json",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
?>
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"body\": \"A new post on your favourite forum. Check it out.\",\"to\": [\"+355692179931\", \"+355684064062\"],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}");
Request request = new Request.Builder()
.url("https://api.sms.to/v1/sms/send")
.post(body)
.addHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.sms.to/v1/sms/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddParameter("application/json", "{\"body\": \"A new post on your favourite forum. Check it out.\",\"to\": [\"+355692179931\", \"+355684064062\"],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\"body\": \"A new post on your favourite forum. Check it out.\",\"to\": [\"+355692179931\", \"+355684064062\"],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}"
headers = {
'Authorization': "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "/v1/sms/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://api.sms.to/v1/sms/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'
request["Content-Type"] = 'application/json'
request["Accept"] = 'application/json'
request.body = "{\"body\": \"A new post on your favourite forum. Check it out.\",\"to\": [\"+355692179931\", \"+355684064062\"],\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}"
response = http.request(request)
puts response.read_body
Response
{
"success": true,
"data": {
"trackingId": 734,
"body": "A new post on your favourite forum. Check it out.",
"to": "+355692179931,+355684064062",
"to_list_id": null,
"from": "SMS.to",
"created_at": {
"date": "2019-02-08 19:33:10.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"status": "ongoing",
"callback_url": "https://your-website.com/handle-notification"
}
}
Sending single SMS to a list
POST: https://api.sms.to/v1/sms/send
Sending single SMS to a list
Headers
Header | Value |
---|---|
Accept | application/json |
Authorization | Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz |
Body
Parameter | Value | Required |
---|---|---|
body | A new post on your favourite forum. Check it out. | Yes |
to_list_id | 12 | Yes |
sender_id | SMS.to | No |
callback_url | https://your-website.com/handle-notification | No |
body
- the textual part of the SMS
to_list_id
- the list ID, which you can get viahttps://api.sms.to/v1/lists
endpoint
sender_id
- the sender ID which is optional
callback_url
- this will be an optional URL where we will POST some information about the status of SMS as soon as we have an update
curl --location --request POST "https://api.sms.to/v1/sms/send" \
--header "Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data "{
\"body\": \"A new post on your favourite forum. Check it out.\",
\"to_list_id\": 12,
\"sender_id\": \"SMS.to\",
\"callback_url\": \"https://your-website.com/handle-notification\"
}"
let config = {
headers: {
"Authorization": "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept": "application/json",
"Content-Type": "application/json"
}
};
axios.post('https://api.sms.to/v1/sms/send', {
body: 'A new post on your favourite forum. Check it out.',
to_list_id: 12,
sender_id: 'SMS.to',
callback_url: 'https://your-website.com/handle-notification'
}, config).then(function (response) {
console.log(response);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sms.to/v1/sms/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>'{"body": "A new post on your favourite forum. Check it out.","to_list_id": 12,"sender_id": "SMS.to","callback_url": "https://your-website.com/handle-notification"}',
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept: application/json",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
?>
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"body\": \"A new post on your favourite forum. Check it out.\",\"to_list_id\": 12,\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}");
Request request = new Request.Builder()
.url("https://api.sms.to/v1/sms/send")
.post(body)
.addHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.sms.to/v1/sms/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddParameter("application/json", "{\"body\": \"A new post on your favourite forum. Check it out.\",\"to_list_id\": 12,\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
payload = "{\"body\": \"A new post on your favourite forum. Check it out.\",\"to_list_id\": 12,\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}"
headers = {
'Authorization': "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "/v1/sms/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://api.sms.to/v1/sms/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'
request["Content-Type"] = 'application/json'
request["Accept"] = 'application/json'
request.body = "{\"body\": \"A new post on your favourite forum. Check it out.\",\"to_list_id\": 12,\"sender_id\": \"SMS.to\",\"callback_url\": \"https://your-website.com/handle-notification\"}"
response = http.request(request)
puts response.read_body
Response
{
"success": true,
"data": {
"trackingId": 736,
"body": "A new post on your favourite forum. Check it out.",
"to": null,
"to_list_id": "12",
"from": "SMS.to",
"created_at": {
"date": "2019-02-08 19:54:55.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"status": "ongoing",
"callback_url": "https://your-website.com/handle-notification"
}
}
Fetch paginated lists
GET: https://api.sms.to/v1/lists
Get paginated lists.
Headers
Header | Value |
---|---|
Accept | application/json |
Authorization | Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz |
Body
Parameter | Value | Required |
---|---|---|
limit | 100 | No |
page | 1 | No |
sort | created_at | No |
search | list-name | No |
limit
- number of records per page
page
- the page number, when you are using pagination
sort
- the field which you want to sort, e.g. usecreated_at
for ASC order or-created_at
for DESC order
search
- keywords to search for a list name
curl --location --request GET "https://api.sms.to/v1/lists?limit=10&page=2" \
--header "Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz" \
--header "Accept: application/json"
let config = {
headers: {
"Authorization": "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept": "application/json"
},
params: {
limit: 10,
page: 2
}
};
axios.get('https://api.sms.to/v1/lists', config).then(function (response) {
console.log(response);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sms.to/v1/lists?limit=10&page=2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
?>
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.sms.to/v1/lists?limit=10&page=2")
.get()
.addHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.sms.to/v1/lists?limit=10&page=2");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz");
request.AddHeader("Accept", "application/json");
IRestResponse response = client.Execute(request);
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
headers = {
'Authorization': "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
'Accept': "application/json"
}
conn.request("GET", "/v1/lists?limit=10&page=2", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://api.sms.to/v1/lists?limit=10&page=2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'
request["Accept"] = 'application/json'
response = http.request(request)
puts response.read_body
Response
{
"success": true,
"message": "Data fetched successfully.",
"data": [
{
"id": 12,
"user_id": 146,
"name": "My list name",
"description": "List description.",
"favorite": "1",
"from_deleted_user": "0",
"created_at": {
"date": "2019-02-08 19:54:55.000000",
"timezone_type": 3,
"timezone": "UTC"
}
}
...
],
"links": {
"first": "https://api.sms.to/v1/lists?page=1",
"last": "https://api.sms.to/v1/lists?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://api.sms.to/v1/lists",
"per_page": 10,
"to": 7,
"total": 7
}
}
Fetch single list
GET: https://api.sms.to/v1/lists/{ID}
Get a single list with the specified ID.
Initially you need to make a request to fetch all lists. From that you can get the ID of a specific list and then fetch its data separately.
Headers
Header | Value |
---|---|
Accept | application/json |
Authorization | Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz |
curl --location --request GET "https://api.sms.to/v1/lists/12" \
--header "Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz" \
--header "Accept: application/json"
let config = {
headers: {
"Authorization": "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept": "application/json"
}
};
axios.get('https://api.sms.to/v1/lists/12', config)
.then(function (response) {
console.log(response);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sms.to/v1/lists/12",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
"Accept: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
?>
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.sms.to/v1/lists/12")
.get()
.addHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.sms.to/v1/lists/12");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz");
request.AddHeader("Accept", "application/json");
IRestResponse response = client.Execute(request);
import http.client
conn = http.client.HTTPSConnection("api.sms.to")
headers = {
'Authorization': "Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz",
'Accept': "application/json"
}
conn.request("GET", "/v1/lists/12", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
url = URI("https://api.sms.to/v1/lists/12")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'
request["Accept"] = 'application/json'
response = http.request(request)
puts response.read_body
Response
{
"success": true,
"message": "Data fetched successfully.",
"data": {
"id": 12,
"user_id": 146,
"name": "My list name",
"description": "List description.",
"favorite": "1",
"from_deleted_user": "0",
"created_at": {
"date": "2019-02-08 19:54:55.000000",
"timezone_type": 3,
"timezone": "UTC"
}
}
}