Get API Key

    API Endpoint
    https://api.qserve.co.ke/version1
                

254sms API provides access to Send Bulk SMS, Delivery reports, error codes, Disburse Airtime, M-Pesa C2B, Mpesa Integrations... e.t.c

To use API, Navigate to 254sms menu, access API section.

get API Key 254sms

Send Bulk SMS


$message ='Hello world';
$sender_id = '254sms'; //Default senderId
$phone = '25472256565,254722998999'; //for multiple concatinate with comma(,)
$apikey = '254SMS APIKEY'; // Check under HTTP API in 254sms.com
$username= '254SMS USERNAME'; // Your 254sms.com Username
$url = 'https://api.qserve.co.ke/version1/sendsms';
$data = array(
    'username' => $username,
    'api_key' => $apikey,
    'sender_id' => $sender_id,
    'phone' => $phone,
    'message' => $message  
);
$payload = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
if (!$result) {

die("ERROR on URL[$url] | error[" . curl_error($ch) . "] |
 error code[" . curl_errno($ch) . "]\n");
}   
                

To Send BulkSMS you need to make a POST call to the following url :
https://api.qserve.co.ke/version1/sendsms


QUERY PARAMETERS

Field Type Description
api_key String Your API key.
sender_id String Your senderId. Default is 254sms
username String Your 254sms Account Username
phone String Phone Number. list of numbers concatinated by comma.
message String Message to be sent out via bulkSMS

Send Bulk SMS Response


[
{
    recipientsCount: 2,
    statusMessage: "Success",
    statusCode: 101, 
    Balance: 8823,  //Remaining Account SMS Credits
    messageDetails: [
        {
            recipient: "25472256565",
            message: "Hello world",
            statusCode: "Successfully Sent",
            statusMessage: 2 
        },
        {
            recipient: "254722998999",
            message: "Hello world",
            statusCode: "Successfully Sent",
            statusMessage: 2
        }
    ]
}
]                           
            
    

These are the repsonses after sending BulkSMS to the above API endpoint.

QUERY PARAMETERS

Field Type Description
recipientsCount String No. of recpients t receive the sent message
statusCode String STatus code for sending the message
Balance String Your 254SMS balance after sending SMS
statusMessage String Current status report for the sent SMS
messageDetails Array An array with list of message objects

SMS Credits


$apikey = '254SMS_APIKEY'; // Check under HTTP API  in 254sms.com
$username= '254SMS_USERNAME'; // Your 254sms.com Username
$url = 'https://api.qserve.co.ke/version1/credits';
$data = array(
    'username' => $username,
    'api_key' => $apikey 
);
$payload = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;  
if (!$result) {

die("ERROR on URL[$url] | error[" . curl_error($ch) . "] | error code[" . curl_errno($ch) . "]\n");
}    
            

To get your 254sms Credits balance, you need to make a POST call to the following url :
https://api.qserve.co.ke/version1/credits


QUERY PARAMETERS

Field Type Description
username String Your 254sms Username.
api_key String Your API Key

SMS Credits Response


[
{
    credits: "345",
    statusCode: 101
}
]                 
                                    
            
    

These are the repsonses after sending BulkSMS to the above API endpoint.

QUERY PARAMETERS

Field Type Description
credits String Your 254sms Credits balance
statusCode String STatus Code

Errors

The 254sms API uses the following error codes:

Error Code Meaning
X000 Some parameters are missing. This error appears when you don't pass every mandatory parameters.
X001 Unknown or unvalid secret_key. This error appears if you use an unknow API key or if your API key expired.
X002 Unvalid secret_key for this domain. This error appears if you use an API key non specified for your domain. Developper or Universal API keys doesn't have domain checker.
X003 Unknown or unvalid user token. This error appears if you use an unknow user token or if the user token expired.