This website uses cookies in order to offer you the most relevant information and services online. Please accept cookies for optimal performance.
Learn More

Sending Transactional SMS using ReSTful API

This guide will walk you through sending transactional SMS using ReST API. We shall use PHP for the example.

Go to http://smsindia.batoi.hosting/ and login with your user details as shown in Figure 1. If you do not have an 'Account', then create an 'Account' by clicking on the link Creating Transactional SMS Panel.

Figure 1
Figure 1

From the 'Dashboard', Go to 'Setting' and then click on the menu 'API Keys' as shown in Figure 2.

Figure 2
Figure 2

On the 'API Keys' page, click on the button 'Create New Key' as shown in Figure 3.

Figure 3
Figure 3

If you want to restrict the 'API Key' with certain IPs, then enter the 'IP Address' in the text box or you can leave the section blank in order to access the 'API Key' from any IP as shown in Figure 4. Click the button 'Save New Key' in order to create the key as shown in Figure 4.

Figure 4
Figure 4

You can find the key in the list page as shown in Figure 5.

Figure 5
Figure 5

Use the below written code to send message using the 'API Key' through browser.
http://smsindia.batoi.hosting/api2/send?<Your API Key>&username=<Your User Name>&hash=<Your Password>&message=<Your Message>&sender=<Your Sender ID>&numbers=<Recipent Mobile Numbers>;
NOTE: If you want to send the message to multiple mobile numbers, then type all the numbers separated with comma.


Use the below written code to 'Send Message' using the 'API Key' from PHP
// Authorisation details.
$username = "xxx";
$hash = "xxx";

$test = "0";

// Data for text message. This is the text message data.
$sender = "xxx"; // This is who the message appears to be from.
$numbers = "910000000000"; // A single number or a comma-seperated list of numbers
$message = "This is a test message from the PHP API script.";
// 612 chars or less
// A single number or a comma-seperated list of numbers
$message = urlencode($message);
$data = "username=".$username."&hash=".$hash."&message=".$message."&sender=".$sender."&numbers=".$numbers."&test=".$test;
$ch = curl_init('http://smsindia.batoi.hosting/api2/send/?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); // This is the result from the API
curl_close($ch);

Use the below written code to 'Inject Contact' using the 'API Key' from PHP
// Authorisation details.
$username = "xxx";
$hash = "xxx";

// Contact details
$group = "5"; // You can see group IDs via the Reports area on your control panel
$numbers = "910000000000"; // The number you want to save
// You shouldn't need to change anything here.
$data = "username=".$username."&hash=".$hash."&group=".$group."&numbers=".$numbers;
$ch = curl_init('http://smsindia.batoi.hosting/api2/create_contacts/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); // Our API reply
curl_close($ch);

Use the below written code to 'Check SMS Credit' using the 'API Key' from PHP
// Authorisation details.
$username = "xxx";
$hash = "xxx";

// You shouldn't need to change anything here.
$data = "username=".$userame."&hash=".$hash;
$ch = curl_init('http://smsindia.batoi.hosting/api2/balance');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$credits = curl_exec($ch);
// This is the number of credits you have left
curl_close($ch);

To view the API sending report, go to 'Reports' from the 'Dashboard' and click the menu 'API Message' as shown in Figure 6.

Figure 6
Figure 6

On the list page, you can able to view the 'API Sending Report' for the last '30 days' in a tabular format as shown in Figure 7.

Figure 7
Figure 7

You can also download the 'API Sending Report' in a 'CSV' format by clicking the button 'Export as CSV' as shown in Figure 7.

If you are facing any problems regarding the use of 'API Key', email us at Batoi Support from your registered email ID* or you can call us at +91 (0) 706 444 1000.
* Primary email ID of your Batoi Panel.

Give your feedback to improve the article

Latest Product Updates

Get the latest news and updates about Batoi Products - articles and product releases.

Need our assistance? We are available with you.

Existing Customer?
Get Support
Talk To Consultant?
Get An Appointment
Contact Us

Batoi global offices and contact details

Stay Connected

Join our community, newsletters, and social media.

Batoi's Annual Cloud Conclave is coming soon. Please watch out.