https://cheapglobalsms.com/api_v1/
NOTE: Examine your automation program closely for problems. You are just as responsible for the SMS commands initiated by an automation program as if you had performed the action manually.
https://cheapglobalsms.com/api_v1/
via HTTP POST or GET method and the response will be returned in a JSON format.error
key is present in the JSON response, then the process was NOT successful, and the value of error
key is the description of what went wrong.Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created. | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be account_info |
account_info |
Filters (Optional Fields)
| ||
only_balance | Return only the numerical (not json string) value of the balance. Unless there's an authentication error | 1 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=account_info
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'account_info' ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg="Balance: ".$json['balance']; } } echo $msg; ?>
{"sub_account_id":"1","sub_account":"mysub1","user_id":"1","balance":"1209","notification_email":"[email protected]","default_dial_code":"234","timezone_offset":"1","default_sender_id":"tormuto"}Below is a sample response to a failed process, a JSON Object
{"error":"Incorrect sub_account name or password","error_code":"4"}
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created. | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be update_account_info |
update_account_info |
Optional Fields (At least one of the following must be supplied though)
| ||
new_sub_account_name | A new sub_account name without the prefix part | mysub2 |
new_notification_email | Your valid email address | [email protected] |
new_default_sender_id | A valid fallback value, incase you didn't specify sender-id when sending an sms. At most 11 characters (or at most 14 digits if entirely numerical) | MyCompany |
new_default_dial_code | Whenever you send and sms with to a recipient with the first digit as 0, that 0 will be replaced with this value. Such that 0799... could be interpreted as +1799.. if your default dial code is +1. | +1 |
new_timezone_offset | The hours difference between GMT and normal time of your recipients. (This is used for converting values in sms-reports and when scheduling for later delivery) | +6:00 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=update_account_info&new_sub_account_name=mysub2&new_default_sender_id=MyCompany&new_default_dial_code=%2B1&new_timezone_offset=%2B6%3A00
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'update_account_info', 'new_sub_account_name'=>'mysub2', 'new_default_sender_id'=>'MyCompany', 'new_default_dial_code'=>'+1', 'new_timezone_offset'=>'+6:00', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg=$json['success']; } } echo $msg; ?>
{"success":"Account info updated","updated":{"sub_account":"mysub2","default_dial_code":"1","timezone_offset":"+6:00","default_sender_id":"MyCompany"}}Below is a sample response to a failed process, a JSON Object
{"error":"This operation is only available for sub-accounts","error_code":"11"}
above, but here:add_sub_account
, the parameters are compulsory (except new_notification_email).Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be fetch_sub_accounts |
fetch_sub_accounts |
Filters (Optional Fields)
| ||
perpage |
To fetch large records, it's essential to paginate. If supplied, maximum is 300 while minimum is 1. |
20 |
p | This is only useful when paginating. It indicates the current page (e.g 1st page) of the record to be fetched. | 1 |
non_empty | If set as 1, the results will be only those sub-accounts that has balance | 0 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=fetch_sub_accounts&p=1&perpage=50&non_empty=0
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'fetch_sub_accounts', 'p'=>1, 'perpage'=>50, 'non_empty'=>0, ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { //you can now do whatever with the records $msg=$json['total']." records, page ".$json['p']." of ".$json['totalpages']; $msg.= "<br/> <ol>"; foreach($json['records'] as $row){ $msg.= "<li>".$row['sub_account'].": ".$row['balance']."credits </li>"; } $msg.= "</ol>"; } } echo $msg; ?>
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created. | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be alter_sub_balance |
alter_sub_balance |
amount | If this value is positive, credit will be added to the specified sub-account from main account, and reverse case if negative | 1000 |
sub_account_id | NOT sub-accout name NOR main user-id prefix. Rather, the sub_account_id itself, as returned during fetch_sub_accounts operation. | 120 |
Optional Fields (At least one of the following must be supplied though)
| ||
memo | Optional transaction note for reference. | This is for invoice xyz |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=update_account_info&amount=1000&sub_account_id=120&memo=for+invoice+xyz
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'update_account_info', 'amount'=>'1000', 'sub_account_id'=>'120', 'memo'=>'for invoice xyz', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg=$json['success']; } } echo $msg; ?>
{"success":"1000 credits transferred from main account to 'mysub1'. New sub-account balance: 1200"}Below is a sample response to a failed process, a JSON Object
{"error":"This operation is only available for main accounts","error_code":"11"}
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be fetch_sub_transactions |
fetch_sub_transactions |
Filters (Optional Fields)
| ||
perpage |
To fetch large records, it's essential to paginate. If supplied, maximum is 300 while minimum is 1. |
20 |
p | This is only useful when paginating. It indicates the current page (e.g 1st page) of the record to be fetched. | 1 |
search_term | If supplied, the records that contains either the sub_account name or transaction detail that 'roughly' matches the supplied value will be returned | xyz |
start_date | The begining filter of date-time of transactions. |
2016-04-22 13:45
or
2016-04-22
|
end_date | The end filter of date-time of transactions. |
28-04-2016 13:45
or
28-04-2016
|
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=fetch_sub_accounts&p=1&perpage=50&start_date=2024-12-14
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'fetch_sub_transactions', 'p'=>1, 'perpage'=>50, 'start_date'=>'2024-12-14', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { //you can now do whatever with the records $msg=$json['total']." records, page ".$json['p']." of ".$json['totalpages']; $msg.= "<br/> <ol>"; foreach($json['records'] as $row){ $msg.= "<li>".$row['amount'].": ".$row['details']."credits </li>"; } $msg.= "</ol>"; } } echo $msg; ?>
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be send_sms |
send_sms |
message | The message to be sent. | Hello, there will be a meeting today by 12 noon. |
recipients |
The recipient's phone numbers. Multiple numbers can be separated by comma (,).
Any mobile numbers starting with zero will have the zero stripped and replaced with the sub-account's default dial code. If the mobile number does not start with a zero, the default dial code will not be applied. E.G if the sub-account's default dial code is '+234', 08086689567,+2348094309926,4478128372838 will be converted to, 2348086689567,2348094309926,4478128372838 |
+2348094309926 |
Optional Fields | ||
type | 0 means normal sms, while 1 means flash-message. If this was not supplied, the message will be assumed to be normal SMS. |
0 |
unicode | 0 means non-unicode sms, while 1 means that the message contains some special characters (e.g chinese, korean,...) that must be preserved (hence the character encoding of the HTTP request is also UTF-8).
You can let the system automatically determine the encoding by setting this value as 2
Please note that when a message is in unicode format, the character limits of the messages reduces to 72 characters per page. |
0 |
route | 0 means Optimal Standard Route, 1 means Priority Delivery Route, 2 means Best Pricing Route, | 0 |
sender_id | What will appear to the recipient as the sender of the SMS. 3 to 11 characters (or 3 to 14 digits if numeric). If this was not supplied, the sub-account's default sender_id will be used. |
CGSMS |
default_dial_code | The number that will replace the leading-zero on the recipient's phone number. If this was not supplied, the sub-account's default_dial_code will be used. |
234 |
send_at | The message will be on queue, to be sent on the specified date. If this was not supplied, or if the value is a past date, the message will be sent immediately. |
2016-04-22 13:45
or
2016-04-22
or 13:45 |
timezone_offset | The timezone to be used for send_at. If this was not supplied, the sub-account's timezone_offset will be used. |
+1 |
contact_groups | Includes all numbers from the supplied contact groups of the sub-account with the recipients | default,My Customers |
ignore_groups | Excludes all numbers that appears in supplied contact groups of the sub-account from the recipients | My Customers,My Customers2 |
contacts |
A JSON Array of contacts, E.G: [{"phone":"+2348093216754","firstname":"Pearl"},{"phone":"08086689567","firstname":"Ibukun","lastname":"Oladipo","group_name":"Client","extra_data":"USER001"},{"phone":"+2348094309926","override_message":"Hello, bro. Please be around before 11:00am","override_date_time":"2016-04-22 09:30"}] ** 'phone' is the only compulsory field in a contact, when sending contacts in JSON format.
** If you include 'override_message' in a contact when sending message, it is the override_message that will be sent to that contact instead of the original message.
** If you include 'override_date_time' in a contact, message will rather be sent to the contact at the supplied override_date_time.
** If you include 'extra_data' (maxmum of 60 characters) in a contact when sending message, the value of the extra_data you supplied will be available in the record of the message when you later fetch_sms.
|
|
save_as | If this is supplied, the recipient phone number(s), will be saved under the group-name; specified as the value of this field, otherwise the numbers will not be saved to contacts | default |
callback_url |
If a url-encoded, valid url is specified, the delivery report will be sent as an encoded string of JSON Array, in an HTTP POST request to this supplied URL; under a POST key 'result'. (typically $_POST['result'] in php)
Sample format of the JSON string posted to the callback_url: [ { "sms_id":"137072", "batch_id":"1_1_1462391634", "units":1, "pages":1, "status":2, "status_msg":"DELIVERED", "info":"Message delivered to handset", "extra_data":"" },... ] |
http%3A%2F%2Fmydomain.com%2Fprocess_callback |
NOTE: All duplicate numbers will be automatically removed for you and SMS will be sent to unique recipients only. |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=send_sms&sender_id=CGSMS&message=Hello%2C+there+will+be+a+meeting+today+by+12+noon.&recipients=08086689567,2348094309926
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'send_sms', 'sender_id'=>'CGSMS', 'recipients'=>'08086689567,2348094309926', 'message'=>"Hello, there will be a meeting today by 12 noon." ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg="SMS sent to ".$json['total']." recipient(s)."; $sms_batch_id=$json['batch_id']; } } echo $msg; ?>
import requests import json payload = { "sub_account":"001_mysub1", "sub_account_pass":"pa55w0Rd", "action":"send_sms", "sender_id":"CGSMS", "recipients":"08086689567,2348094309926", "message":"Hello, there will be a meeting today by 12 noon." } r = requests.post(url = 'https://cheapglobalsms.com/api_v1/', json = payload) data = r.json() if r.status_code != 200: print(r.reason) else: print("Message sent to ",data['total']," Recipients. Batch ID: ",data['batch_id']," ACCEPTED LIST:",data['summary'])
const http = require('http'); var payload = { "sub_account":"001_mysub1", "sub_account_pass":"pa55w0Rd", "action":"send_sms", "sender_id":"CGSMS", "recipients":"08086689567,2348094309926", "message":"Hello, there will be a meeting today by 12 noon." } sendCGSMSCommand('send_sms',payload,function(responseCode,response){ if(response['error'])console.log(response['error']) else { console.log("Message sent to ",response['total']," Recipients. Batch ID: ",response['batch_id']," ACCEPTED LIST:",response['summary']) } }); /* @action: String @params: Object containing params @callbackFunct(json): the parsed http response get processed in this function */ function sendCGSMSCommand(action,params,callbackFunct){ if(!params.action)params.action=action; var postData = JSON.stringify(params); ; var options = { hostname: 'cheapglobalsms.com', port: 80, path: '/api_v1/', method: 'POST', json:true, headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/json', 'Content-Length': postData.length } }; var req = http.request(options, (res) => { var str=''; res.on('data',function(chunk){ str+=chunk; }); res.on('end',function(){ try{ obj=JSON.parse(str); callbackFunct(res.statusCode,obj); } catch(e){ var err="Error Parsing Response"+e+"\r\n"+str; callbackFunct(-1*res.statusCode,err); console.log(err) } }); }); req.on('error', (e) => { callbackFunct(-1,e); console.error(e); }); req.write(postData); req.end(); }
send_sms
request will be a JSON Object, containing the batch_id, and the total number of recipient numbers that are successfully parsed.
{ "batch_id":"1_1_1437039374", "total":"2", "summary":{ "2348086689567":{"initial_units":2,"pages":1,"pending_review":0}, "2348094309926":{"initial_units":2,"pages":1,"pending_review":0} } }Below is a sample JSON response to a failed process:
{"error":"insufficient credit","error_code":"1"}
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be fetch_sms |
fetch_sms |
Filters (Optional Fields)
Only those SMS that matches the specified criteria will be returned.
| ||
perpage |
To fetch large records, it's essential to paginate. If supplied, maximum is 300 while minimum is 1. |
100 |
p | This is only useful when paginating. It indicates the current page (e.g 1st page) of the record to be fetched. | 1 |
batch_id | The batch_id returned from a send_sms action. |
1_1_1437039374 |
sms_ids | If the sms_id of the message(s) were already known in advanced, they can be used for filtering. | 572,228 |
stage | This can be pending, sent or failed. | sent |
status |
The specific (numerical) status of the SMS. Possible statuses and their meanings are 2 = DELIVERED, 1 = ACCEPTED, 0 = PENDING, -1 = FAILED, -2 = REJECTED, -3 = EXPIRED, -4 = UNDELIVERABLE The stage and status key can not be used together (stage key will be ignored) |
2 |
type | 0 means normal sms, while 1 means flash-message. | 0 |
recipient | The recipient number, to which the SMS had been sent, e.g 08094309926 or 2348094309926 or +2348094309926 | 2348094309926 |
sender_id | 3 to 11 characters (or 3 to 14 digits if numeric) | CGSMS |
dial_code | International number prefix. Useful for filtering by country | 234 |
search_term | If supplied, the records that contains either the recipient, sender_id or message body that 'roughly' matches the supplied value will be returned | CGSMS 2348094309926 |
start_date | The minimum: time sent, or scheduled time, of the messages to be returned. |
2016-04-22 13:45
or
2016-04-22
|
end_date | The maximum: time sent, or scheduled time, of the messages to be returned. |
28-04-2016 13:45
or
28-04-2016
|
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=fetch_sms&batch_id=1_1_1437039374
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'fetch_sms', 'batch_id'=>'1_1_1437039374', //'stage'=>'sent' ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { //you can now do whatever with the records //(e.g check the recipient, fetch the next page or display a message) $msg=$json['total']." SMS records, page ".$json['p']." of ".$json['totalpages']; $msg.= "<br/> <ol>"; foreach($json['records'] as $sms) { $msg.= "<li>To: ".$sms['recipient']."<br/> ".$sms['message']."</li>"; } $msg.= "</ol>"; } } echo $msg; ?>
{ "total":19,"totalpages":1,"p":1,"perpage":100,"timezone_offset":"1", "records":[ {"sms_id":"68", "sender":"ibukun", "recipient":"2022451175", "message":"checking wrong number", "sub_account_id":"1", "user_id":"1", "time_scheduled":"1448224505", "batch_id":"1_1_1448224505", "status":"-2", "type":"0", "units":"1", "reference":"", "time_submitted":"1448224505", "time_sent":"1448224505", "units_confirmed":"0", "locked":"1", "info":"Network is forbidden", "firstname":"Gotv", "lastname":"NUMBER", "group_name":"default", "status_msg":"REJECTED", "submitted_at":"2015-11-22 20:35", "scheduled_to":"2015-11-22 20:35", "sent_at":"2015-11-22 20:35", "extra_data":"" }, {"sms_id":"67","sender":"ibukun","recipient":"2348094309926","message":"hello; how're you doing","sub_account_id":"1","user_id":"1","time_scheduled":"1448223878","batch_id":"1_1_1448223878","status":"2","type":"0","units":"2","reference":"","time_submitted":"1448223878","time_sent":"1448223878","units_confirmed":"1","locked":"0","info":"Message delivered to handset","firstname":null,"lastname":null,"group_name":null,"status_msg":"DELIVERED","submitted_at":"2015-11-22 20:24","scheduled_to":"2015-11-22 20:24","sent_at":"2015-11-22 20:24","extra_data":""}, ... ,"filter":{"sub_account_id":"1","batch_id":"","sms_id":"","sms_ids":"","type":"","recipient":"","search_term":"","sender_id":"","stage":"","start_date":"","end_date":"","p":"","perpage":100,"offset":0} }
Code | Status | Details |
---|---|---|
2 | DELIVERED | Message was delivered to destination. |
1 | SENT | The message was accepted by the Network server. Awaiting delivery status. |
0 | PENDING | This message is on queue, to be sent. |
-1 | FAILED | An issue occured while attempting to send the SMS. |
-2 | REJECTED | The message was rejected. The message was undeliverable. |
-3 | EXPIRED | Message validity period has expired. (e.g phone off or not in coverage area) |
-4 | UNDELIVERABLE | The message was undeliverable |
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key can be either stop_sms , delete_sms or get_total_units |
stop_sms |
Optional Filters
IMPORTANT: When deleting or stopping SMS, you must specify some kind of filter(s), otherwise your entire sms records will be premanently deleted/stopped | ||
batch_id |
Typically a batch_id returned from a send_sms action.An attempt will be made to stop all SMS in this batch. |
1_1_1437039374 |
sms_ids | Typically one or more sms_id from the SMS objects array returned from a fetch_sms action. |
572,228 |
stage | This can be pending, sent or failed. | sent |
status |
The specific (numerical) status of the SMS. Possible statuses and their meanings are 2 = DELIVERED, 1 = ACCEPTED, 0 = PENDING, -1 = FAILED, -2 = REJECTED, -3 = EXPIRED, -4 = UNDELIVERABLE The stage and status key can not be used together (stage key will be ignored) |
2 |
type | 0 means normal sms, while 1 means flash-message (flash sms appears temporarily on screen rather than saved-inbox). | 0 |
recipient | The recipient number, to which the SMS had been sent, e.g 08094309926 or 2348094309926 or +2348094309926 | 2348094309926 |
sender_id | 3 to 11 characters (or 3 to 14 digits if numeric) | CGSMS |
start_date | The minimum: time sent, or scheduled time, of the messages to be returned. |
2016-04-22 13:45
or
2016-04-22
|
end_date | The maximum: time sent, or scheduled time, of the messages to be returned. |
28-04-2016 13:45
or
28-04-2016
|
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=stop_sms&batch_id=1_1_1437039374
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'stop_sms', 'batch_id'=>'1_1_1437039374' ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg=$json['total']." messages stopped"; } } echo $msg; ?>
{"total":"10"}Below is a sample response to a failed process, a JSON Object
{"error":"no record found.","error_code":"10"}
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be get_delivery_stat |
get_delivery_stat |
batch_id | The batch id for consideration | 1_1_1462391634 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=get_delivery_stat&batch_id=1_1_1462391634
<?php $batch_id='1_1_1462391634'; $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'get_delivery_stat', 'batch_id'=>$batch_id ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { //you can perform any operation on the available data now print_r($json); } } echo $msg; ?>
{"UNDELIVERABLE":{"sms_count":0,"sms_units":0},"EXPIRED":{"sms_count":0,"sms_units":0},"REJECTED":{"sms_count":0,"sms_units":0},"FAILED":{"sms_count":0,"sms_units":0},"PENDING":{"sms_count":13,"sms_units":4},"ACCEPTED":{"sms_count":0,"sms_units":0},"DELIVERED":{"sms_count":0,"sms_units":0},"total":{"sms_count":13,"sms_units":4}}Below is a sample response to a failed process, a JSON Object
{"error":"No record found","error_code":11}
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be save_contacts |
save_contacts |
Optional/Elective Fields
At least one of 'phone_numbers' or 'contacts' must be supplied.
|
||
phone_numbers |
A string of phone numbers (multiple numbers can be separated by comma)
E.G: 08086689567,+2348094309926,4478128372838 Any mobile numbers starting with zero will have the zero stripped and replaced with the sub-account's default dial code.
|
+2348094309926 |
contacts |
A JSON Array of contacts, E.G: [{"phone":"08086689567","firstname":"Ibukun","lastname":"Oladipo","group_name":"Client"},{"phone":"+2348094309926","firstname":"Pearl"}] 'phone' is the only compulsory field, when sending contacts in JSON format.
|
|
group_name | All the supplied numbers/contacts will be saved under this group_name, except those contacts in JSON Array, that also has a group_name defined. If group_name was not supplied via any means, the contacts will automatically be added under 'default' group_name. |
My Customers |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=save_contacts&group_name=My+Customers&contacts=08086689567,2348094309926
<?php $contacts=array( 0=>array('phone'=>'08086689567','firstname'=>'Ibukun','lastname'=>'Oladipo','group_name'=>'Client'), 1=>array('phone'=>'+2348094309926','firstname'=>'Pearl'), ); $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'save_contacts', 'contacts'=>json_encode($contacts), 'group_name'=>'My Customers', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg=$json['total']." contact(s) has been saved."; } } echo $msg; ?>
save_contacts
request will be a JSON Object, containing the batch_id, and the total number of recipient numbers that are successfully parsed.
{"total":"2"}Below is a sample JSON response to a failed process:
{"error_code":4,"error":"Incorrect sub_account name or password."}
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be fetch_contacts |
fetch_contacts |
Filters (Optional Fields)
Only those contacts that matches the specified criteria will be returned.
| ||
group_name | Return only those contacts in this group | My Customers |
search_term | This can be any of phone number, firstname, lastname to find, e.g: 08094309926 or ibukun or 08094309926 ibukun | 2348094309926 |
contact_ids | If the specific contact_id(s) to be fetch were already known, it can be used for filtering. | 5,7 |
perpage |
To fetch large records, it's essential to paginate. If supplied, maximum value is 300 while minimum is 1. |
100 |
p | This is only useful when paginating. It indicates the current page (e.g 1st page) of the record to be fetched. | 1 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=fetch_contacts&group_name=My+Customers
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'fetch_contacts', 'group_name'=>'My Customers', 'search_term'=>'ibukun' ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { //you can now do whatever with the contact records returned //(e.g check list the contacts, or even fetch the next page by running the same request with p=1) $msg=$json['total']." Contacts in total, page ".$json['p']." of ".$json['totalpages']; $msg.= "<br/> <ol>"; foreach($json['contacts'] as $contact) { $msg.= "<li>+".$contact['phone']."<br/> ".$contact['firstname']." ".$contact['lastname']." (".$contact['group_name'].")</li>"; } $msg.= "</ol>"; } } echo $msg; ?>
{ "filter":{"user_id":"1","sub_account_id":"1","perpage":10,"group_name":"My Customers","search_term":null,"offset":0}, "total":2,"p":1,"totalpages":1, "records":[{"contact_id":"20","user_id":"1","sub_account_id":"1","phone":"2348086689567","firstname":"","lastname":"","group_name":"My Customers","time":"1445721399"}, {"contact_id":"21","user_id":"1","sub_account_id":"1","phone":"2348094309926","firstname":"","lastname":"","group_name":"My Customers","time":"1445721399"} ] }
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be get_contact_groups |
get_contact_groups |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=get_contact_groups
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'get_contact_groups' ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg="Balance: ".$json['balance']; } } echo $msg; ?>
{"contact_groups":{"My Customers":"2","default":"4"}}
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be delete_contacts |
delete_contacts |
Filters (Optional Fields)
ALL those contacts that matches the specified criteria will be deleted.
| ||
group_name | Return only those contacts in this group | My Customers |
search_term | This can be any of phone number, firstname, lastname to find, e.g: 08094309926 or ibukun or 08094309926 ibukun | 2348094309926 |
contact_ids | Typically one or more contact_id, from the array of contact objects returned from a fetch_contacts action. |
5,7 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=delete_contacts&contact_ids=5%2C7
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'delete_contacts', 'contact_ids'=>'5,7' ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg="Total deleted contacts: ".$json['total']; } } echo $msg; ?>
{"total":"4"}Below is a sample response to a failed process, a JSON Object
{"error":"No contact_ids supplied to be deleted","error_code":"7"}
HTTP POST KEY | Description | Example Value |
---|---|---|
sender | The phone number that sent the SMS (without the leading +) | 2348093216754 |
recipient | Your phone number (that has been configured here), to which the SMS has been sent | 2348030000000 or 23451007 |
campaign_id | ID of the campaign that captured/intercept this message for you | 121 |
message | The full content of the message sent | STOP SERVICE1 James Richard |
pages | Number of SMS pages covered by this message | 1 |
keyword | The keyword that you specified while setting up the campaign | STOP |
clean_message | The remaining part of the message, after the keyword | James Richard |
https://example.com/inbound/cheapglobalsms?from={sender}&text={clean_message}
from
and text
are HTTP Get parameter names that your own app expects;{sender}
and {clean_message}
are placeholders for our data format from the table above.
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be fetch_inbox or delete_inbox |
fetch_inbox |
Filters (Optional Fields)
When fetching messages, only those messages that matches the specified criteria will be returned.
IMPORTANT: When deleting or stopping SMS, you must specify some kind of filter(s), otherwise your entire sms records will be permanently deleted/stopped
| ||
perpage |
To fetch large records, it's essential to paginate. If supplied, maximum is 300 while minimum is 1. |
100 |
p | This is only useful when paginating. It indicates the current page (e.g 1st page) of the record to be fetched. | 1 |
campaign_id | The campaign_id that captured the messages. | 1411 |
message_ids | If the message_id of the message(s) were already known in advanced, they can be used for filtering. | 572,228 |
keyword | This keywords that captured the messages | STOP |
recipient | The number you configured, to which the message was sent, e.g 08094309926 or 2348094309926 or +2348094309926 | 2348094309926 |
sender | The number that sends in the message | 2348094309923 |
search_term | If supplied, the records that contains either the recipient, sender or message body that 'roughly' matches the supplied value will be returned | STOP SERVICE1 |
start_date | The minimum time of the messages to be returned. |
2016-04-22 13:45
or
2016-04-22
|
end_date | The maximum time of the messages to be returned. |
28-04-2016 13:45
or
28-04-2016
|
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=fetch_inbox&campaign_id=1411
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'fetch_inbox', 'batch_id'=>'1411', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { //you can now do whatever with the records //(e.g check the sender, fetch the next page or display a message) $msg=$json['total']." messages, page ".$json['p']." of ".$json['totalpages']; $msg.= "<br/> <ol>"; foreach($json['records'] as $message) { $msg.= "<li>From: ".$sms['sender']."<br/> ".$sms['message']."</li>"; } $msg.= "</ol>"; } } echo $msg; ?>
{ "total":19,"totalpages":1,"p":1,"perpage":100,"timezone_offset":"1", "records":[ {"sms_id":"68", "sender":"ibukun", "recipient":"2022451175", "message":"checking wrong number", "sub_account_id":"1", "user_id":"1", "time_scheduled":"1448224505", "batch_id":"1_1_1448224505", "status":"-2", "type":"0", "units":"1", "reference":"", "time_submitted":"1448224505", "time_sent":"1448224505", "units_confirmed":"0", "locked":"1", "info":"Network is forbidden", "firstname":"Gotv", "lastname":"NUMBER", "group_name":"default", "status_msg":"REJECTED", "submitted_at":"2015-11-22 20:35", "scheduled_to":"2015-11-22 20:35", "sent_at":"2015-11-22 20:35", "extra_data":"" }, {"sms_id":"67","sender":"ibukun","recipient":"2348094309926","message":"hello; how're you doing","sub_account_id":"1","user_id":"1","time_scheduled":"1448223878","batch_id":"1_1_1448223878","status":"2","type":"0","units":"2","reference":"","time_submitted":"1448223878","time_sent":"1448223878","units_confirmed":"1","locked":"0","info":"Message delivered to handset","firstname":null,"lastname":null,"group_name":null,"status_msg":"DELIVERED","submitted_at":"2015-11-22 20:24","scheduled_to":"2015-11-22 20:24","sent_at":"2015-11-22 20:24","extra_data":""}, ... ,"filter":{"sub_account_id":"1","batch_id":"","sms_id":"","sms_ids":"","type":"","recipient":"","search_term":"","sender":"","stage":"","start_date":"","end_date":"","p":"","perpage":100,"offset":0} }
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be fetch_virtual_numbers |
fetch_virtual_numbers |
Filters (Optional Fields)
Only those virtual_numbers that matches the specified criteria will be returned.
| ||
country | Return only those virtual numbers for this country code | PL |
perpage |
To fetch large records, it's essential to paginate. If supplied, maximum value is 300 while minimum is 1. |
100 |
p | This is only useful when paginating. It indicates the current page (e.g 1st page) of the record to be fetched. | 1 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=fetch_virtual_numbers&country=PL
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'fetch_virtual_numbers', 'country'=>'PL', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { //you can now do whatever with the virtual_number records returned //(e.g acquire the virtual number, or even fetch the next page by running the same request with p=1) $msg=$json['total']." Virtual Numbers in total, page ".$json['p']." of ".$json['totalpages']; $msg.= "<br/> <ol>"; foreach($json['records'] as $virtual_number) { $msg.= "<li>+".$virtual_number['number']." :: ".$virtual_number['first_month_total_credits']." credits </li>"; } $msg.= "</ol>"; } } echo $msg; ?>
{ "total": 1250, "totalpages": 63, "p": 1, "perpage": 20, "timezone_offset": "1", "records": [ { "number": "48664078775", "number_key": "CE2B0D0F8E34FBF3B0EB915AD09433B4", "country": "Poland", "country_code": "PL", "country_code3": "POL", "type": "VIRTUAL_LONG_NUMBER", "instant_automated_setup": false, "monthly_renewal_credits": 2070, "first_month_credits": 2070, "first_month_setup_credits": 2070, "first_month_total_credits": 4140 }, { "number": "48664078779", "number_key": "6DFC8D8CCD29F8441AB5EDF88658BC0A", "country": "Poland", "country_code": "PL", "country_code3": "POL", "type": "VIRTUAL_LONG_NUMBER", "instant_automated_setup": false, "monthly_renewal_credits": 2070, "first_month_credits": 2070, "first_month_setup_credits": 2070, "first_month_total_credits": 4140 } ], "filter": { "sub_account_id": "1", "user_id": "1", "country": "PL", "p": "", "perpage": 20, "offset": 0 } }
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created. | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be acquire_number |
acquire_number |
number | The virtual number that you want to acquire. | 48664078775 |
country | The two-letter country-code of this virtual number. | PL |
number_key | The number_key for this virtual number (obtained from the fetch_virtual_numbers request). | CE2B0D0F8E34FBF3B0EB915AD09433B4 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=acquire_number&number=48664078775&country=PL&number_key=CE2B0D0F8E34FBF3B0EB915AD09433B4
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'acquire_number', 'number'=>'48664078775', 'country'=>'PL', 'number_key'=>'CE2B0D0F8E34FBF3B0EB915AD09433B4', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg=$json['success']; } } echo $msg; ?>
{"success":"You've successfully acquire +48664078775 for a month. Configure it now"}
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be fetch_campaigns |
fetch_campaigns |
Filters (Optional Fields)
| ||
country_code | Return only your campaigns with virtual numbers for this country code | PL |
search_term | If supplied, only the campaigns with virtual numbers that matches this filter will be returned. | 48664078775 |
status |
Filter by numerical status 0=>PAUSED, 1=>ACTIVE, -4=>EXPIRED |
1 |
perpage |
To fetch large records, it's essential to paginate. If supplied, maximum is 300 while minimum is 1. |
20 |
p | This is only useful when paginating. It indicates the current page (e.g 1st page) of the record to be fetched. | 1 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=fetch_campaigns&country_code=PL
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0Rd', 'action'=>'fetch_campaigns', 'country_code'=>'PL' ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { //you can now do whatever with the records $msg=$json['total']." records, page ".$json['p']." of ".$json['totalpages']; $msg.= "<br/> <ol>"; foreach($json['records'] as $row){ $msg.= "<li>ID: ".$row['campaign_id']." :: Virtual Number: +".$row['recipient']." </li>"; } $msg.= "</ol>"; } } echo $msg; ?>
Input Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created. | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be edit_campaign |
edit_campaign |
campaign_id | The campaign ID obtained from fetch_campaigns | 123 |
Optional Fields (At least one of the following must be supplied though)
| ||
callback_url | The endpoint where you remotely handle the HTTP POST request (as described in ) whenever someone sent an SMS to our line. | http%3A%2F%2Fmydomain.com%2Fprocess_callback |
add_contacts | This specifies a list of contact groups. If a line send an sms to your virtual number; the line will be added to each of these contact groups. | MyContactGroup1,MyContactGroup7 |
delete_contacts | This specifies a list of contact groups. If a line send an sms to your virtual number; and the line exists in any of this contact groups; the contact will be deleted from the group. | MyContactGroup1,MyContactGroup7 |
update_contact_firstname | This specifies a list of contact groups. If a line send an sms to your virtual number; and the line exists in any of this contact groups; firstname of this contact will be replaced by the message of the text received. | MyContactGroup1,MyContactGroup7 |
update_contact_lastname | This specifies a list of contact groups. If a line send an sms to your virtual number; and the line exists in any of this contact groups; lastname of this contact will be replaced by the message of the text received. | MyContactGroup1,MyContactGroup7 |
update_contact_group_name | This specifies a list of contact groups. If a line send an sms to your virtual number; and the line exists in any of this contact groups; this contact will be moved to the group name labelled by the text received. | MyContactGroup1,MyContactGroup7 |
auto_renew | Options are 0 and 1, When it's 1, this virtual number will be renewed upon expiry, from your balance. | 1 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=edit_campaign&campaign_id=123&add_contacts=MyContactGroup1
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'edit_campaign', 'campaign_id'=>'123', 'add_contacts'=>'MyContactGroup1', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg=$json['success']; } } echo $msg; ?>
{"success":"Your campaign as been successfully updated"}
extra_data
key will not contain the configurationKey when fetched with the fetch_campaignsInput Field Name | Description | Example Value |
---|---|---|
sub_account | A sub_account name that you have created. | 001_mysub1 |
sub_account_pass | Sub account password | pa55w0Rd |
action | The value for this key must be rectify_campaign |
rectify_campaign |
number | The virtual number with incomplete configuration, that you want to rectify. | 48664078775 |
https://cheapglobalsms.com/api_v1/?sub_account=001_mysub1&sub_account_pass=pa55w0Rd&action=rectify_campaign&number=48664078775
<?php $post_data=array( 'sub_account'=>'001_mysub1', 'sub_account_pass'=>'pa55w0R', 'action'=>'rectify_campaign', 'number'=>'48664078775', ); $api_url='https://cheapglobalsms.com/api_v1/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($response_code != 200)$response=curl_error($ch); curl_close($ch); if($response_code != 200)$msg="HTTP ERROR $response_code: $response"; else { $json=@json_decode($response,true); if($json===null)$msg="INVALID RESPONSE: $response"; elseif(!empty($json['error']))$msg=$json['error']; else { $msg=$json['success']; } } echo $msg; ?>
{"success":"Configuration successful finalized for +48664078775"}
Error Code | Description |
---|---|
1 | sub_account not supplied |
2 | sub_account_pass not supplied |
3 | action not supplied |
4 | Incorrect sub_account name or password |
5 | The sub-account is currently disabled |
6 | Invalid action |
7 | missing request parameter |
8 | incorrect request parameter |
9 | confusing request parameters |
10 | no record found |
11 | operation failed |
12 | insufficient balance |