Welcome Geeks

Choose a service on the left to browse API endpoints, request examples, and response formats.

Get Into Messaging!

SMS API Endpoint

https://api.taifamobile.co.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.taifamobile.co.ke/sms/sendsms' \
--header 'api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
  "mobile": "+254707556633",
  "response_type": "json",
  "sender_name": "TaifaMobile",
  "service_id": 0,
  "message": "This is a message.\n\nRegards\nTaifa Mobile Ltd"
}'

PHP example

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.taifamobile.co.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": "+254707556633",
    "response_type": "json",
    "sender_name": "TaifaMobile",
    "service_id": 0,
    "message": "This is a message.\n\nRegards\nTaifa Mobile Ltd"
}',
  CURLOPT_HTTPHEADER => array(
    'api-key: YOUR_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.taifamobile.co.ke/sms/sendsms
Request Type: POST

Parameters

FieldTypeDescription
api-keyStringYour API key. It goes to the header.
mobileStringThe customer mobile number. Can be 722xxxyyy, 0722xxxyyy, or +254722xxxyyy. For multiple numbers, separate with commas.
response_typeString[Optional, defaults to json] either json or plain.
sender_nameStringThe origination alphanumeric or numeric code, e.g. TaifaMobile or 12345 for shortcode messages.
service_idIntegerIdentifier of the service allocated to the customer. This is always 0 for bulk messaging.
link_idString[Optional] Leave empty for bulk messages. For shortcode on-demand messages, include the received link_id.
messageStringThe message to send. Maximum 920 characters (up to 6 SMS units). Every SMS unit is charged.

Messaging Status Codes

Success status

[
  {
    "status_code": "1000",
    "status_desc": "Success",
    "message_id": 8692671,
    "mobile_number": "+254707556633",
    "network_id": "1",
    "message_cost": "0.75",
    "credit_balance": "7231"
  }
]

Failed status

[
  {
    "status_code": "1001",
    "status_desc": "Invalid short code",
    "message_id": "0",
    "mobile_number": "+254707556633",
    "network_id": "",
    "message_cost": "",
    "credit_balance": ""
  }
]
Status IdStatus CodeStatus Description
11000Success
21001Invalid short code
31002Network not allowed
41003Invalid mobile number
51004Low bulk credits
61005Internal system error
71006Invalid credentials
81007Db connection failed
91008Db selection failed
101009Data type not supported
111010Request type not supported
121011Invalid user state or account suspended
131012Mobile number in DND
141013Invalid API Key
151014IP not allowed

Validate Mobile Number

cURL example

curl --location --request GET 'https://api.taifamobile.co.ke/sms/mobile?mobile=707556633' \
--header 'api-key: YOUR_API_KEY'

PHP example

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.taifamobile.co.ke/sms/mobile?return=json&mobile=707556633',
  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(
    'api-key: YOUR_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

FieldTypeDescription
returnStringThe return type: either json or just the validated mobile number.
mobileStringThe mobile number to be validated.