Get Into Messaging!
SMS API Endpoint https://api.bulk.ke/sms/sendsms
Below is a quick step by step guide on how to integrate into our Bulk and Short code / Premium messaging gateway through an application programming interface (API).
To use this API, you need an API Key. If you have already signed up, you can get your API Key from your account.
NOTE: You can import the cURL examples into Postman and generate sample code in different languages
Send SMS - Bulk & Shortcodes
# cURL example
curl --location --request POST 'https://api.bulk.ke/sms/sendsms' \
--header 'h_api_key: ' \
--header 'Content-Type: application/json' \
--data-raw '{
"mobile": "254748321607",
"response_type": "json",
"sender_name": "BULK_TECHY",
"service_id": 0,
"message": "This is a message.\n\nRegards\nBULK TECHNOLOGIES L.t.d."
}'
# PHP example
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.bulk.ke/sms/sendsms',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 15,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"mobile": "254748321607",
"response_type": "json",
"sender_name": "BULK_TECHY",
"service_id": 0,
"message": "This is a message.\n\nRegards\nBULK TECHNOLOGIES L.t.d."
}',
CURLOPT_HTTPHEADER => array(
'h_api_key: ', 'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Send a message to a mobile subscriber using a Sender Name (alphanumeric sender ID):https://api.bulk.ke/sms/sendsms
Request Type:POST
Parameters
Field | Type | Description |
---|---|---|
h_api_key | String | Your API key. It goes to the header |
mobile | String | The customer mobile number. This can be any format e.g. 722xxxyyy, 0722xxxyyy, +254 722xxx yyy |
response_type | String | [Optional, defaults to json] either json or plain |
sender_name | String | The origination alphanumeric or numeric code. e.g. BULK_TECHY for bulk messages or 12345 for shortcode messages |
service_id | Integer | An identifier of the service allocated to the customer. This is always 0 for bulk messaging |
link_id | String | [Optional] Leave this empty for bulk messages. For shortcode messages, the link_id received on incoming on-demand messages must be included here. |
message | String | The message to send to the end user. This can be to a maximum or 920 characters or 6 SMS units. Note that every unit of an SMS is charged. |
Messaging Status Codes
# Success status :
[
{
"status_code": "1000",
"status_desc": "Success",
"message_id": 9766667,
"mobile_number": "254748321607",
"network_id": "1",
"message_cost": "0.75",
"credit_balance": "4757",
}
]
# Failed status
[
{
"status_code": "1001",
"status_desc": "Invalid short code",
"message_id": "0",
"mobile_number": "254748321607",
"network_id": "",
"message_cost": "",
"credit_balance": ""
}
]
Status Id | Status Code | Status Description |
---|---|---|
1 | 1000 | Success |
2 | 1001 | Invalid short code |
3 | 1002 | Network not allowed |
4 | 1003 | Invalid mobile number |
5 | 1004 | Low bulk credits |
6 | 1005 | Internal system error |
7 | 1006 | Invalid credentials |
8 | 1007 | Db connection failed |
9 | 1008 | Db selection failed |
10 | 1009 | Data type not supported |
11 | 1010 | Request type not supported |
12 | 1011 | Invalid user state or account suspended |
13 | 1012 | Mobile number in DND |
14 | 1013 | Invalid API Key |
15 | 1014 | IP not allowed |
Send Multiple Messages
#cURL example
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.bulk.ke/sms/sendmultiple',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"serviceId": "0",
"shortcode": "BULK_TECHY",
"messages": [
{
"mobile": "254748321607",
"message": "This is a second message",
"client_ref": 6481
},
{
"mobile": "254748321607",
"message": "This is a first message",
"client_ref": 6092
}
]
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'h_api_key: '
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"status_code": 1000,
"status_desc": "Success",
"credit_balance": "-10615.0000",
"schedule_details": [
{
"message_id": 335951830,
"client_ref": 60970,
"mobile": "254705941410",
"schedule_status": "1",
"schedule_desc": "Success",
"network_id": "1",
"message_cost": 1
},
{
"message_id": 335951831,
"client_ref": 64871,
"mobile": "254705941419",
"schedule_status": "1",
"schedule_desc": "Success",
"network_id": "1",
"message_cost": 1
}
]
}
Sending Multiple Messages to Multiple Mobile Numbers:
Request Type: POST
Request Parameters
Field | Type | Description |
---|---|---|
serviceId | Integeer | The Service Id. if its bulk SMS and other integer values for premium services. |
shortcode | String | Sender Name for whitelabeling |
messages | Array | A list of all the messages each containing mobile;the recipeint phone number, message;the message content,client_ref;The reference to help hnadle delivery report. |
Validate Mobile Number
#cURL example
curl --location --request GET 'https://api.bulk.ke/sms/mobile?mobile=748321607' \
--header 'h_api_key: '
# PHP example
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.bulk.ke/sms/mobile?return=json&mobile=748321607',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 15,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'h_api_key: '
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Validate and check the network a mobile number belongs to:
Request Type: GET
Request Parameters
Field | Type | Description |
---|---|---|
return | String | The return type: either json or just the validated mobile number |
mobile | String | The mobile number to be validated |
Send Delivery Report
#cURL example
curl --location --request POST '/client.endpoint/dlr' \
# PHP example
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/client.endpoint/dlr',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 15,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'
{ "messageId":"27312989",
"dlrTime":"2022-02-22 11:46:42",
"dlrStatus":"1",
"dlrDesc":"DeliveredToTerminal",
"tat":10005,
"network":"1",
"destaddr":"254767209917",
"sourceaddr":"118",
"origin":"Safaricom"}
'
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Send Delivery report from Mobile Network Operator in realtime:
Request Type: POST
Request Parameters
Field | Type | Description |
---|---|---|
messageId | Integer | The messageId which is returned with every successful request. |
dlrTime | DateTime | DateTime for the time of delivery. |
dlrStatus | Integer | Status value as integer. |
dlrDesc | String | Description of the delivery report staus. |
tat | Integer | The time it took for system to get report. |
network | Integer | Numeric indicator of the Network. |
destaddr | String | The mobile to which the message was sent to. |
sourceaddr | String | The SenderId which originated the message |
origin | String | The The nework name |
GET ACCOUNT BALANCE
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.bulk.ke/sms/getbalance',
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',
CURLOPT_POSTFIELDS =>'{
"response_type":"json"
}',
CURLOPT_HTTPHEADER => array(
'h_api_key: adeedccd2199f41f7e731e3150b4c8009de4cded064b6407a310573e28978680',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Get Account balance for your account using only your API KEY https://api.bulk.ke/sms/getbalance
Request Type: POST
Request Parameters
Field | Type | Description |
---|---|---|
h_api_key | String | Your API key. It goes to the header |
response_type | String | [Optional, defaults to json] either json or plain |