API for Developers

For 3rd-party developers that would like to make use of our SMS gateway from their own applications or website, we provide a simple to use RESTful API to achieve this.

Through our API, you can

  • Send SMS immediately
  • Schedule SMS for sending later
  • Get your SMS units balance

You can download sample PHP code here to consume our APIs.


SEND SMS
REQUEST FORMAT
[ END POINT: https://www.bracketsms.com/index.php/api/sendSMS ]
[ REQUEST METHOD: POST ]

The request is to be sent in JSON format and should contain the following fields
  • apikey: Your API key is your means of authenticating and can be found on the "Edit Profile" page after logging in.
  • msg: This is the content of the SMS to be sent to recipients.
  • phone: This is either a single phone number or a comma-separated list of phone numbers to which the SMS would be sent. They should also be in international format. eg. 2348011111111, 2348022222222, 2348033333333
  • route: This is the route through which the SMS would be sent. Allowed values are "1" and "2". Please, note that
    • When = 1, it uses the default route where the charge is 1 unit per SMS, but DND numbers are not delivered
    • When = 2, it uses the alternate route where the charge is 1.5 unit per SMS and DND numbers are delivered to MTN lines only. Furthermore, the sendername would always be "rUPDATE" irrespective of the sender name that you specify.
    Please, note that if no route is specified, the system would always default to "1".
  • sendername: This is the name that would appear to recipients of the SMS as the sender. Maximum length for alphanumeric sender name is 11 and 18 for numeric sender name. If this field is not specified in your request, we'll use the default sender name set on your account and if no default is set, we'll use BracketSMS.
  • schedule: This is a boolean value. Set to false if you want the SMS to be sent immediately or true if you want it sent at a later date/time.
  • schedule_date: This specifies the date and time that a message should be sent if the schedule field is true. It must be in the format YYYY-MM-DD HH:II
SAMPLE REQUEST (Send immediately)
{
    "apikey":"ABCDE12345",
    "msg":"This is a sample text message.",
    "phone":"2348011111111, 2348022222222, 2348033333333",
    "sendername":"BracketSMS",
    "route":"1",
    "schedule":"false",
    "schedule_date":""
}
SAMPLE REQUEST (Send later)
{
    "apikey":"ABCDE12345",
    "msg":"This is a sample text message.",
    "phone":"2348011111111, 2348022222222, 2348033333333",
    "sendername":"BracketSMS",
    "route":"1",
    "schedule":"true",
    "schedule_date":"2017-05-23 14:25"
}
RESPONSE FORMAT
For the sendSMS API, the following fields are always returned
  • status: This is a boolean value that shows whether the call was successful or not.
  • resp_code: This is a 2-digit response code that tells you the actual status of the call. Please, refer to the list of response codes.
  • resp_desc: This describes the response code. Please, refer to the list of response codes.
  • sms_charge: This is the number of SMS units that was charged for this call.
  • balance: This is your SMS balance after processing this request and charging your account.
SAMPLE SUCCESS RESPONSE
{
    "status":true,
    "resp_code":"00",
    "resp_desc":"Success",
    "sms_charge": 10000,
    "balance": 54100
}
SAMPLE FAILED RESPONSE
{
    "status":false,
    "resp_code":"02",
    "resp_desc":"Insufficient SMS Units",
    "sms_charge": 0,
    "balance": 8125
}
GET BALANCE
REQUEST FORMAT
[ END POINT: https://www.bracketsms.com/index.php/api/getBalance ]
[ REQUEST METHOD: GET ]

The request is to be sent as part of the URL and should contain the field below.
  • apikey: Your API key is your means of authenticating and can be found on the "Edit Profile" page after logging in.
SAMPLE REQUEST
Assuming your apiKey is ABCDE12345
https://www.bracketsms.com/index.php/api/getBalance/ABCDE12345
RESPONSE FORMAT
For the getBalance API, the following fields are always returned
  • status: This is a boolean value that shows whether the call was successful or not.
  • resp_code: This is a 2-digit response code that tells you the actual status of the call. Please, refer to the list of response codes.
  • resp_desc: This describes the response code. Please, refer to the list of response codes.
  • balance: This contains your SMS balance.
SAMPLE SUCCESS RESPONSE
{
    "status":true,
    "resp_code":"00",
    "resp_desc":"Success",
    "balance": 54100
}
SAMPLE FAILED RESPONSE
{
    "status":false,
    "resp_code":"01",
    "resp_desc":"Invalid API Key",
    "balance": 0
}
LIST OF RESPONSE CODES 
RESPONSE CODE RESPONSE DESCRIPTION
00 Success
01 Invalid API key / Account is not enabled for API use / Email address has not been confirmed
02 Insufficient SMS Units
03 No recipient was specified or no valid phone number found
04 Schedule date not in the specified format
05 Invalid JSON request
SAMPLE CODE 

You can download sample PHP code here to consume our APIs.

OR simple copy it below and insert your API key to get started.

class BracketSMS{
	
	function __construct(){
		$this->api_key = 'YOUR_API_KEY_HERE';
	}
	
	
	public function sendSMS($msg, $recipients, $sendername, $route, $schedule, $schedule_date){
		$endpoint = 'https://www.bracketsms.com/index.php/api/sendSMS';
		$api_key = $this->api_key;
		$data = <<<JSONDATA
{
    "apikey":"$api_key",
    "msg":"$msg",
    "phone":"$recipients",
    "sendername":"$sendername",
	"route":"$route",
    "schedule":"$schedule",
    "schedule_date":"$schedule_date"
}
JSONDATA;
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $endpoint);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$response = curl_exec($ch);
		curl_close($ch);
		return $response;
	}



	public function getBalance(){
		$endpoint = 'https://www.bracketsms.com/index.php/api/getBalance/' . $this->api_key;
		$response = file_get_contents($endpoint);
		return $response;
	}
	
	
}
	
	$bracket = new BracketSMS();
	
	//Get balance
	// echo $bracket->getBalance();

	//Send SMS
	$msg = 'This is a sample message sent via API.';
	$recipients = '2348011111111,2348022222222,2348033333333';
	$sendername = 'BracketSMS';
	$route = 2;
	$schedule = true;
	$schedule_date = '2017-09-23 17:00';
	echo $bracket->sendSMS($msg, $recipients, $sendername, $route, $schedule, $schedule_date);            

Navigation

Social Media