SMS API Documentation

Powerful messaging API for bulk SMS and premium services

Overview

The SMS API allows you to send SMS messages through our bulk and shortcode messaging gateway. This documentation provides everything you need to integrate SMS functionality into your application.

Note: You need an API Key to use this API. If you have already signed up, you can get your API Key from your account.

API Endpoint

POST https://api.bulk.ke/sms/sendsms Bulk SMS

Authentication

All API requests require authentication using your API key in the request header.

Header Parameter

Header Type Description Required
h_api_key String Your API key (64 characters) Yes
Content-Type String Must be application/json Yes

Example Header


--header 'h_api_key: ' \
--header 'Content-Type: application/json'

Send Single SMS

Send a message to a mobile subscriber using a Sender Name (alphanumeric sender ID).

POST https://api.bulk.ke/sms/sendsms Bulk SMS

Request Parameters

Field Type Description Required
mobile String The customer mobile number (e.g., 722xxx, 0722xxx, +254722xxx) Yes
sender_name String The origination alphanumeric or numeric code (e.g., "BULK_TECHY") Yes
message String The message to send (max 920 characters or 6 SMS units) Yes
response_type String [Optional] Either "json" or "plain", defaults to "json" No
service_id Integer Service identifier (always 0 for bulk messaging) Yes
link_id String [Optional] For shortcode messages only No

Code Examples


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."
}'

Response Example

Success Response

Status: 1000 - Success

[
    {
        "status_code": "1000",
        "status_desc": "Success",
        "message_id": 8738598,
        "mobile_number": "254748321607",
        "network_id": "1",
        "message_cost": "0.75",
        "credit_balance": "9871"
    }
]

Error Response

Status: 1001 - Invalid short code

[
    {
        "status_code": "1001",
        "status_desc": "Invalid short code",
        "message_id": "0",
        "mobile_number": "254748321607",
        "network_id": "",
        "message_cost": "",
        "credit_balance": ""
    }
]
            

Send Multiple SMS

Send multiple SMS messages to different recipients in a single API call.

POST https://api.bulk.ke/sms/sendmultiple Bulk SMS

Request Parameters

Field Type Description Required
serviceId Integer The Service Id (0 for bulk SMS) Yes
shortcode String Sender Name for whitelabeling Yes
messages Array List of message objects Yes
messages[].mobile String Recipient phone number Yes
messages[].message String Message content Yes
messages[].client_ref String/Integer Reference for delivery reports No

Code Example


curl --location --request POST 'https://api.bulk.ke/sms/sendmultiple' \
--header 'Content-Type: application/json' \
--header 'h_api_key: ' \
--data-raw '{
    "serviceId": "0",
    "shortcode": "BULK_TECHY",
    "messages": [
        {
            "mobile": "254748321607",
            "message": "This is a first message",
            "client_ref": 6481
        },
        {
            "mobile": "+254712244244",
            "message": "This is a second message",
            "client_ref": 6092
        }
    ]
}'

Response Example

Success Response

Status: 1000 - Success

{
    "status_code": 1000,
    "status_desc": "Success",
    "credit_balance": "-10615.0000",
    "schedule_details": [
        {
            "message_id": 335951830,
            "client_ref": 60970,
            "mobile": "254748321607",
            "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
        }
    ]
}
                

Validate Mobile Number

Validate and check the network a mobile number belongs to.

GET https://api.bulk.ke/sms/mobile Bulk SMS

Request Parameters

Field Type Description Required
mobile String The mobile number to validate Yes
return String [Optional] Return type: "json" or mobile number only No

Code Example


curl --location --request GET 'https://api.bulk.ke/sms/mobile?mobile=712244243&return=json' \
--header 'h_api_key: '

Delivery Reports

Receive delivery reports from Mobile Network Operators in real-time.

POST /client.endpoint/dlr Shortcode
Note: This endpoint should be configured on your server to receive delivery reports.

Request Parameters

Field Type Description Required
messageId Integer The messageId returned with every successful request Yes
dlrTime DateTime DateTime for the time of delivery (YYYY-MM-DD HH:MM:SS) Yes
dlrStatus Integer Delivery status value as integer Yes
dlrDesc String Description of the delivery report status Yes
tat Integer Time taken for system to get report (in seconds) No
network Integer Numeric indicator of the Network No
destaddr String The mobile number the message was sent to Yes
sourceaddr String The SenderId which originated the message Yes
origin String The network name (e.g., "Safaricom") No

Example Delivery Report


curl --location --request POST '/client.endpoint/dlr' \
--header 'Content-Type: application/json' \
--data-raw '{
    "messageId": "27312989",
    "dlrTime": "2022-02-22 11:46:42",
    "dlrStatus": "1",
    "dlrDesc": "DeliveredToTerminal",
    "tat": 10005,
    "network": "1",
    "destaddr": "254767209917",
    "sourceaddr": "118",
    "origin": "Safaricom"
}'

Account Balance

Get your current account balance using your API key.

GET https://api.bulk.ke/sms/getbalance Bulk SMS

Request Parameters

Field Type Description Required
response_type String [Optional] Either "json" or "plain", defaults to "json" No

Code Example


curl --location --request GET 'https://api.bulk.ke/sms/getbalance' \
--header 'h_api_key: adeedccd2199f41f7e731e3150b4c8009de4cded064b6407a310573e28978680' \
--header 'Content-Type: application/json' \
--data-raw '{"response_type":"json"}'

Receiving Inbound Messages

The client will provide an endpoint that accepts the following JSON data through a POST request

POST http://client.example.com/inbound SMS Shortcode

Request Parameters

Field Type Description Required
api_token String The token supplied by a partner for our service request authentication purposes. This can be an encrypted value of their username, server IP, timestamp, and password. No
timestamp String Timestamp in the format YmdHis to be used in password decryption. No
mobile String All mobile numbers are validated before a request is accepted Format: 254722000000 Yes
message String The message as received from the end user. Yes
shortcode Int The short code associated with the service. Yes
inbox_id Int A unique identifier of the message. Yes
service_id Int The service identifier for the service. Yes
network_name String A network identifier e.g Safaricom, Airtel, Yu, Equitel & Telkom Yes
link_id String Received for On-Demand shortcode messages. This should be used when sending out replies. Yes

Code Example


curl --location --request POST 'http://client.example.com/inbound' \
--header 'Content-Type: application/json' \
--data-raw '{
  "api_token": "944a73412bed1240b5a2afa381a928a6",
  "timestamp": "20180217065028",
  "mobile": "254748321607",
  "message": "Test inbox",
  "shortcode": "11223",
  "inbox_id": "4448236",
  "service_id": "32",
  "network_name": "Safaricom",
  "link_id": "7637236723672261"
}'

Response Example

Success Response

Status: OK

    {
        "result_code": 1,
        "result_desc": "OK",
        "result_message": "Thank you for your message."
    }

Sending Short Code Message

This is the same as sending a bulk message. The only difference is that a service_id will be added to this request. See example JSON below.

POST https://api.bulk.ke/prs/sendprs SMS Shortcode

Request Parameters

Field Type Description Required
service_id Integer [Mandatory] You must request the Service ID from the CSP for your service No
mobile String All mobile numbers are validated before a request is accepted Format: 254722000000 Yes
shortcode Integer The short code associated with the service. Yes
link_id String Received for On-Demand shortcode messages. This should be used when sending out replies. Yes
message String The message as received from the end user. Yes
response_type String [Optional] Either "json" or "plain", defaults to "json" No

Code Example


curl --location --request POST 'https://api.bulk.ke/prs/sendprs' \
--header 'h_api_key: ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "service_id": 1,
    "mobile": "254748321607",
    "shortcode": "11223",
    "link_id": 3231232jhIGyigiggigigi87676967,
    "message": "This is a shortcode message.\n\nRegards\nBULK TECHNOLOGIES L.t.d.",
    "response_type": "json"
}'

Response Example

Success Response

Status: 1000 - Success

   {
    "status_code": "1000",
    "status_desc": "Success",
    "message_id": 10,
    "mobile_number": "254748321607",
    "network_id": "1",
    "message_cost": 1,
    "credit_balance": -100
}

Status Codes

Reference table for all API response status codes and their descriptions.

Status ID Code Description Type
1 1000 Success success
2 1001 Invalid short code error
3 1002 Network not allowed error
4 1003 Invalid mobile number error
5 1004 Low bulk credits error
6 1005 Internal system error error
7 1006 Invalid credentials error
8 1007 Db connection failed error
9 1008 Db selection failed error
10 1009 Data type not supported error
11 1010 Request type not supported error
12 1011 Invalid user state or account suspended error
13 1012 Mobile number in DND error
14 1013 Invalid API Key error
15 1014 IP not allowed error

API Tester

Test the SMS API endpoints directly from this documentation.

POST https://api.bulk.ke/sms/sendsms
Note: This is a client-side tester. For security, API calls will be simulated. In a real implementation, this would make actual API calls.