URL: /api/airtimeapi
Methods: POST
, GET
This API endpoint allows users to purchase airtime credits for mobile phones.
To access this endpoint, users must include their API key and secret key in the request headers.
See usage example in the code snippets below:
POST request to purchase airtime:
Content-Type: application/json api-key: your-api-key secret-key: your-secret-key { "phone": "08032566178", "firstLevel": "MTN", "amount": 100 }
Response:
- Status Code: 200 { "message": "Transaction successful", "airtimeHistory": { "transactionId": "1234567890", "email": "user@example.com", "activity": "MTN airtime", "status": "Success", "recipient": "08032566178", "amount": 100, "amountUsed": 99, "initialBalance": 500, "finalBalance": 401 "Method": API, } } - The `amountUsed` field represents the actual amount deducted from the user's balance based on user level.
{ "error": "Transaction failed", "airtimeHistory": { "transactionId": "1234567890", "email": "user@example.com", "activity": "MTN airtime", "status": "Failed", "recipient": "08032566178", "amount": 100, "initialBalance": 500, "finalBalance": 500 "Method": API, } }
See usage example in the code snippets below:
GET request for available firstLevel:
Content-Type: application/json api-key: your-api-key secret-key: your-secret-key
Response:
- Status Code: 200 { "MTN": { "available": true }, "GLO": { "available": true }, "AIRTEL": { "available": true }, "9MOBILE": { "available": true } }