Airtime API
The Airtime API allows you to disburse airtime to your customer base.
Authentication
To interact with the application, you will need to acquire an APP_KEY and APP_TOKEN.
Steps to Obtain API Credentials:
- Log in to your QuickSMS account.
- On the left-side menu, click on Utility Apps.
- Create a new app or select an existing one.
- Click on Settings.
- Generate an APP_TOKEN and store it safely (it will only be displayed once).
- Copy your APP_KEY and use it in your application.
Required Headers
| Header | Value |
|---|---|
| Content-Type | application/json |
| App-Key | [YOUR_APP_KEY] |
| App-Token | [YOUR_APP_TOKEN] |
POST Method
Endpoint:
https://{{url}}/api/v3/airtime/send
Request Body:
{
"recipients": [
{"recipient": "2547XXXXXX", "amount": 100},
{"recipient": "2547XXXXXX", "amount": 100}
]
}
Sample Success Response:
{
"code": 200,
"message": "Total:1 Success:1 Failed:0",
"results": [
{"recipient": "2547XXXXXXXX", "amount": 100, "code": 201, "discount": 0.4, "message": "queued for disbursal", "request_id": 10990},
{"recipient": "2547XXXXXXXX", "amount": 100, "code": 201, "discount": 0.4, "message": "queued for disbursal", "request_id": 10991}
]
}
Key Considerations
- You can have from one up to 1,000 recipients per request.
- Maximum amount is KES 10,000.
- Minimum amount is KES 10.
Code Examples (POST Request)
<?php
$payload = json_encode([
"recipients" => [
["recipient"=>"2547XXXXXX","amount"=>100],
["recipient"=>"2547XXXXXX","amount"=>100]
]
]);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL=>"https://{{url}}/api/endpoint",
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>$payload,
CURLOPT_HTTPHEADER=>["Content-Type: application/json"]
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
const axios = require('axios');
const data = { recipients: [{recipient:"2547XXXXXX",amount:100},{recipient:"2547XXXXXX",amount:100}] };
axios.post("https://{{url}}/api/endpoint", data, { headers: {"Content-Type":"application/json"} })
.then(res=>console.log(res.data))
.catch(err=>console.error(err));
import requests
url = "https://{{url}}/api/endpoint"
headers = {"Content-Type":"application/json"}
payload = {"recipients":[{"recipient":"2547XXXXXX","amount":100},{"recipient":"2547XXXXXX","amount":100}]}
response = requests.post(url,json=payload,headers=headers)
print(response.json())