SEND INDIVIDUAL SMS
You can use this endpoint directly to send SMS to a contact number.
| ENDPOINT | https://api.ozonesender.com/v1/send/ | https://api.ozonesender.com/ v1/send/ |
|---|---|---|
| TYPE | GET OR POST | |
| RETURN TYPE | JSON |
SEND INDIVIDUAL SMS PARAMETERS
| Key | Value | Required | |
|---|---|---|---|
| user_id | User ID from your Documentation page. | YES | |
| api_key | API key from your Documentation page. | YES | |
| sender_id | Your approved Sender ID. Use “oZone Demo” for testing. This one is case sensitive. | YES | |
| message | The message. Max: 612 chars for ASCII, 268 for UNICODE | YES | |
| recipient_contact_no | recipient_ contact_no |
The Number of the Recipient. (E.g. 94711111111) | YES |
API RESPONSE SAMPLE
{ "status_code": 204, "msg_id": "14364" }
API RESPONSE PARAMETERS
| Key | Description |
|---|---|
| status_code | Your Status Code |
| msg_id | Message Id |
API STATUS CODE LIST
| HTTP Response | Response |
|---|---|
| 201 | Client API Status is Inactive |
| 202 | Invalid API Key |
| 203 | Contact Number is Invalid or Operator not Support |
| 204 | Successfully Sent the Message |
| 205 | Length of Contact is Invalid |
| 206 | Country is not Available for Sending SMS |
| 207 | No Contact Numbers |
| 208 | Account Balance is Insufficient |
| 209 | Sending the Message is Unsuccessful |
| 210 | Client is Suspended |
| 211 | No Sender ID / Sender Id is not Approved |
| 212 | Rate Card is not Set for the Country |
| 213 | Route is not Set for the Country |
SAMPLE CODE FOR SENDING INDIVIDUAL SMS
<?php
// send_sms function in PHP - cURL
function send_sms($client_id,$api_key,$sender_id,$message,$rec_contact_no){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.ozonesender.com/v1/send/?
user_id=$client_id&api_key=$api_key&sender_id=$sender_id&message=$message&recipient_contact_no=$rec_contact_no",
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;
}
//set variables
$client_id = "11XXXX"; // Replace your client ID
$api_key = "121XXXXE"; // Replace your api key
$sender_id = "oZone Demo"; // Replace your sender id
$message = "Hello"; // Message
$rec_contact_no = "94xxxxxxx"; // Recipient contact no
// call send_sms function
send_sms($client_id,$api_key,$sender_id,$message,$rec_contact_no);
?>
<script>
// send_sms function in JavaScript - Fetch
function send_sms(client_id,api_key,sender_id,message,recipient_contact_no){
var requestOptions = {
method: "GET",
redirect: "follow"
};
fetch("https://api.ozonesender.com/v1/send/?user_id="+client_id+"&api_key="+api_key+"&sender_id="+sender_id+
"&message="+message+"&recipient_contact_no="+recipient_contact_no, requestOptions)
.then(response => response.text())
.then(result => document.write(result))
.catch(error => document.write("error", error));
}
// set variables
var client_id = "11XXXX"; // Replace your client ID
var api_key = "121XXXXE"; // Replace your api key
var sender_id = "oZone Demo"; // Replace your sender id
var message = "Hello"; // Message
var recipient_contact_no = "94xxxxxxx"; // Recipient contact no
// call send_sms function
send_sms(client_id,api_key,sender_id,message,recipient_contact_no);
</script>
<script>
// send_sms function in JavaScript - Jquery
function send_sms(client_id,api_key,sender_id,message,recipient_contact_no){
var settings = {
"url": : "https://api.ozonesender.com/v1/send/?user_id="+client_id+"&api_key="+api_key+"&sender_id="+sender_id+
"&message="+message+"&recipient_contact_no="+recipient_contact_no,
"method": "GET",
"timeout": 0,
};
$.ajax(settings).done( function (response) {
console.log(response);
});
}
// set variables
var client_id = "11XXXX"; // Replace your client ID
var api_key = "121XXXXE"; // Replace your api key
var sender_id = "oZone Demo"; // Replace your sender id
var message = "Hello"; // Message
var recipient_contact_no = "94xxxxxxx"; // Recipient contact no
// call send_sms function
send_sms(client_id,api_key,sender_id,message,recipient_contact_no);
</script>
// send_sms function in C - libcurl
function send_sms(client_id,api_key,sender_id,message,recipient_contact_no){
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl){
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.ozonesender.com/v1/send/?user_id=client_id&api_key=api_key&sender_id=sender_id&message=message&recipient_contact_no=recipient_contact_no");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
}
// set variables
int client_id = "1"; // Replace your client ID
ch api_key = "121XXXXE"; // Replace your api key
int sender_id = "oZone Demo"; // Replace your sender id
ch message = "Hello"; // Message
ch recipient_contact_no = "94755555555"; // Recipient contact no
//call send_sms function
send_sms(client_id,api_key,sender_id,message,recipient_contact_no);
// send_sms function in NodeJs - Native
function send_sms(client_id,api_key,sender_id,message,recipient_contact_no){
var https = require("follow-redirects").https;
var fs = require("fs");
var options = {
"method": "GET",
"hostname": "https://api.ozonesender.com",
"path": "/v1/send/?user_id=client_id&api_key=api_key&sender_id=sender_id&message=message&recipient_contact_no=recipient_contact_no",
"headers": {
},
"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();
}
// set variables
var client_id = "11XXXX"; // Replace your client ID
var api_key = "121XXXXE"; // Replace your api key
var sender_id = "oZone Demo"; // Replace your sender id
var message = "Hello"; // Message
var recipient_contact_no = "94xxxxxxx"; // Recipient contact no
//call send_sms function
send_sms(client_id,api_key,sender_id,message,recipient_contact_no);
<?php
// send_sms function in PHP - Guzzle
function send_sms($client_id,$api_key,$sender_id,$message,$recipient_contact_no){
$client = new Client();
$request = new Request("GET", "https://api.ozonesender.com/v1/send/?user_id=$client_id&api_key=$api_key&sender_id=$sender_id&message=$message&recipient_contact_no=$recipient_contact_no");
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
}
//set variables
$client_id = "11XXXX"; // Replace your client ID
$api_key = "121XXXXE"; // Replace your api key
$sender_id = "oZone Demo"; // Replace your sender id
$message = "Hello""; // Message
$recipient_contact_no = "94xxxxxxx"; // Recipient contact no
//call send_sms function
send_sms($client_id,$api_key,$sender_id,$message,$recipient_contact_no);
?>
// set variables
client_id = "11XXXX"; // Replace your client ID
api_key = "121XXXXE"; // Replace your api key
sender_id = "oZone Demo"; // Replace your sender id
message = "Hello"; // Message
recipient_contact_no = "94xxxxxxx"; // Recipient contact no
// Send SMS in Phython Requests
import requests
url = "https://api.ozonesender.com/v1/send/?user_id=client_id&api_key=api_key&sender_id=sender_id&message=message&recipient_contact_no=recipient_contact_no"
payload={}
headers = {}
response = requests.request( "GET", url, headers=headers, data=payload)
print(response.text)
public class SmsSender
{
public static async Task SendSms(string clientId, string apiKey, string senderId, string message, string recipientContactNo)
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.ozonesender.com/v1/send/");
var content = new MultipartFormDataContent();
content.Add(new StringContent(clientId), "user_id");
content.Add(new StringContent(apiKey), "api_key");
content.Add(new StringContent(senderId), "sender_id");
content.Add(new StringContent(message), "message");
content.Add(new StringContent(recipientContactNo), "recipient_contact_no");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
public class Program
{
public static async Task Main(string[] args)
{
// set variables
string clientId = "11XXXX"; // Replace your client ID
string apiKey = "121XXXXE"; // Replace your API key
string senderId = "oZone Demo"; // Replace your sender ID
string message = "Hello"; // Message
string recipientContactNo = "94xxxxxxx"; // Recipient contact no
// Call SendSms function
await SmsSender.SendSms(clientId, apiKey, senderId, message, recipientContactNo);
}
}
SEND BULK SMS
You can use this endpoint directly to send SMS to bulk contact numbers
| ENDPOINT | https://api.ozonesender.com/api/bulkSMS/ |
|---|---|
| TYPE | GET OR POST |
| RETURN TYPE | JSON |
SEND BULK SMS PARAMETERS
| Key | Value | Required |
|---|---|---|
| user_id | User ID from your Documentation page. |
YES |
| api_key | API key from your Documentation page. |
YES |
| sender_id | Your approved Sender ID.Use “oZone Demo” for testing. This one is case sensitive. |
YES |
| message | The message. Max: 612 chars for ASCII 268 for UNICODE |
YES |
| recipient_ contact_no |
The Numbers of the Recipients. (E.g. 94711111111, 94722222222, 94733333333) |
YES |
API RESPONSE SAMPLE
{
"success": [
[
{
"number": "94711111111",
"msgId": "1000"
},
{
"number": "94773333333",
"msgId": "1001"
},
{
"number": "94752222222",
"msgId": "1002"
}
]
],
"unsuccess": [
[
{
"number": "94214545455",
"status": 203
},
{
"number": "58478",
"status": 203
}
]
]
}
API RESPONSE PARAMETERS
| Key | Description |
|---|---|
| success | Your Result (Success Messages Details) |
| unsuccess | Your Result (Unsuccess Messages Details) |
| number | Your Contact Number |
| status_code | Your Status Code |
| msg_id | Message Id |
API STATUS CODE LIST
| HTTP Response | Response |
|---|---|
| 201 | Client API Status is Inactive |
| 202 | Invalid API Key |
| 203 | Contact Number is Invalid or Operator not Support |
| 204 | Successfuly Sent the Message |
| 205 | Length of Contact is Invalid |
| 206 | Country is not Availble for Sending SMS |
| 207 | No Contact Numbers |
| 208 | Account Balance is Insufficient |
| 209 | Sending the Messsage is Unsuccessfull |
| 210 | Client is Suspended |
| 211 | No Sender ID / Sender Id is not Approved |
| 212 | Rate Card is not Set for the Country |
| 213 | Route is not Set for the Country |
SAMPLE CODE FOR SENDING BULK SMS
<?php
// send_bulk_sms function in PHP - cURL
function send_bulk_sms send_sms($client_id,$campaign_name,$api_key,$sender_id,$message,$recipient_contacts){
// curl post
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.ozonesender.com/v1/bulk/?");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS,
"user_id={$client_id}&campaign_name={$campaign_name}&api_key={$api_key}&sender_id={$sender_id}&message={$message}&recipient_contacts={$recipient_contacts}");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
//set variables
$client_id = "11XXXX"; // Replace your client ID
$campaign_name = "Test"; // Replace your client ID
$api_key = "121XXXXE"; // Replace your api key
$sender_id = "oZone Demo"; // Replace your sender id
$message = "Hello"; // Message
$recipient_contacts = "94711111111, 94773333333, 94752222222; "; // Recipient contact no
// call send_bulk_sms function
send_bulk_sms ($client_id, $campaign_name, $api_key, $sender_id, $message, $recipient_contacts);
?>
<script>
// send_bulk_sms function in JavaScript - Fetch
function send_bulk_sms(client_id,campaign_name,api_key,sender_id,message,recipient_contacts){
var requestOptions = {
method: "GET",
redirect: "follow"
};
fetch("https://api.ozonesender.com/v1/bulk/?user_id="
+client_id+&campaign_name="+campaign_name"&api_key="+api_key+"&sender_id="+sender_id+"&message="+message+"&recipient_contacts="+recipient_contacts, requestOptions)
.then(response => response.text())
.then(result => document.write(result))
.catch(error => document.write("error", error));
}
// set variables
var client_id = "11XXXX"; // Replace your client ID
var campaign_name = "Test"; // Replace your client ID
var api_key = "121XXXXE"; // Replace your api key
var sender_id = "oZone Demo"; // Replace your sender id
var message = "Hello"; // Message
var recipient_contacts = "94711111111, 94773333333, 94752222222"; // Recipient contact no
// call send_bulk_sms function
send_bulk_sms(client_id,campaign_name,api_key,sender_id,message,recipient_contacts);
</script>
<script>
// send_bulk_sms function in JavaScript - Jquery
function send_bulk_sms(client_id,api_key,sender_id,message,recipient_contacts){
var settings = {
"url": "https://api.ozonesender.com/v1/bulk/?user_id="+client_id+"&api_key="+api_key+"&sender_id="+sender_id+"&message="+message+"&recipient_contacts="+recipient_contacts,
"method": "GET",
"timeout": 0,
};
$.ajax(settings).done(function (response) {
console.log(response);
});
}
// set variables
var client_id = "11XXXX"; // Replace your client ID
var api_key = "121XXXXE"; // Replace your api key
var sender_id = "oZone Demo"; // Replace your sender id
var message = "Hello"; // Message
var recipient_contacts = "94711111111, 94773333333, 94752222222, 94214545455, 58478"; // Recipient contact no
// call send_bulk_sms function
send_bulk_sms(client_id,api_key,sender_id,message,recipient_contacts);
</script>
// send_bulk_sms function in C - libcurl
function send_bulk_sms(client_id,api_key,sender_id,message,recipient_contacts){
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl){
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.ozonesender.com/v1/bulk/?user_id=client_id&api_key=api_key&sender_id=sender_id&message=message&recipient_contacts=recipient_contacts");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
}
// set variables
int client_id = "11XXXX"; // Replace your client ID
ch api_key = "121XXXXE"; // Replace your api key
int sender_id = "oZone Demo"; // Replace your sender id
ch message = "Hello"; // Message
ch recipient_contacts = "94711111111, 94773333333, 94752222222, 94214545455, 58478"; // Recipient contact no
//call send_bulk_sms function
send_bulk_sms(client_id,api_key,sender_id,message,recipient_contacts);
// send_bulk_sms function in NodeJs - Native
function send_bulk_sms(client_id,api_key,sender_id,message,recipient_contacts){
var https = require("follow-redirects").https;
var fs = require("fs");
var options = {
"method": "GET",
"hostname": "https://api.ozonesender.com",
"path": "/v1/bulk/?user_id=client_id&api_key=api_key&sender_id=sender_id&message=message&recipient_contacts=recipient_contacts",
"headers": {
},
"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();
}
// set variables
var client_id = "11XXXX"; // Replace your client ID
var api_key = "121XXXXE"; // Replace your api key
var sender_id = "oZone Demo"; // Replace your sender id
var message = "Hello"; // Message
var recipient_contacts = "94711111111, 94773333333, 94752222222, 94214545455, 58478"; // Recipient contact no
//call send_bulk_sms function
send_bulk_sms(client_id,api_key,sender_id,message,recipient_contacts);
<?php
// send_bulk_sms function in PHP - Guzzle
function send_bulk_sms($client_id,$api_key,$sender_id,$message,$recipient_contacts){
$client = new Client();
$request = new Request("GET", "https://api.ozonesender.com/v1/bulk/?user_id=$client_id&api_key=$api_key&sender_id=$sender_id&message=$message&recipient_contacts=$recipient_contacts");
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
}
//set variables
$client_id = "11XXXX"; // Replace your client ID
$api_key = "121XXXXE"; // Replace your api key
$sender_id = "oZone Demo"; // Replace your sender id
$message = "Hello"; // Message
$recipient_contacts = "94711111111, 94773333333, 94752222222, 94214545455, 58478"; // Recipient contact no
//call send_bulk_sms function
send_bulk_sms($client_id,$api_key,$sender_id,$message,$recipient_contacts);
?>
// set variables
client_id = "11XXXX"; // Replace your client ID
api_key = "121XXXXE"; // Replace your api key
sender_id = "oZone Demo"; // Replace your sender id
message = "Hello"; // Message
recipient_contacts = "94711111111, 94773333333, 94752222222, 94214545455, 58478"; // Recipient contact no
// Send SMS in Phython Requests
import requests
url = "https://api.ozonesender.com/v1/bulk/?user_id=client_id&api_key=api_key&sender_id=sender_id&message=message&recipient_contacts=recipient_contacts"
payload={}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
public class SmsSender
{
private static readonly HttpClient client = new HttpClient();
public static async Task SendBulkSms(string clientId, string campaignName, string apiKey, string senderId, string message, string recipientContacts)
{
var url = "https://api.ozonesender.com/v1/bulk/?";
var content = new MultipartFormDataContent();
content.Add(new StringContent(clientId), "user_id");
content.Add(new StringContent(campaignName), "campaign_name");
content.Add(new StringContent(apiKey), "api_key");
content.Add(new StringContent(senderId), "sender_id");
content.Add(new StringContent(message), "message");
content.Add(new StringContent(recipientContacts), "recipient_contacts");
var request = new HttpRequestMessage(HttpMethod.Post, url) { Content = content };
try
{
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ", e.Message);
}
}
}
// Main function to call send_bulk_sms
public class Program
{
public static async Task Main(string[] args)
{
string clientId = "11XXXX"; // Replace your client ID
string campaignName = "Test"; // Replace your campaign name
string apiKey = "121XXXXE"; // Replace your API key
string senderId = "oZone Demo"; // Replace your sender ID
string message = "Hello"; // Message
string recipientContacts = "94711111111, 94773333333, 94752222222"; // Recipient contacts
await SmsSender.SendBulkSms(clientId, campaignName, apiKey, senderId, message, recipientContacts);
}
}
