SMS API
Send an SMS from your server through BluePay.
SMS API
Outbound SMS is built into BluePay. Call one API endpoint from your server; messages are sent from the BluePay sender ID (BLUEPAY). You do not integrate a separate SMS vendor, pass sender_name, or configure gateway URLs — BluePay handles delivery. Safaricom numbers only. Use a unique reference per message for idempotency.
POST
https://bluepay.co.ke/api/v1/sms/sendAuth: same as STK — api_secret, account_id, and channel_id. Not for browser use.
Body
| Field | Required | Notes |
|---|---|---|
api_secret | Yes | API secret from API Keys. |
account_id | Yes | Account ID from API Keys. |
channel_id | Yes | Channel ID from API Keys. |
phone | Yes | Safaricom MSISDN only — 071x/072x/074x/079x or 2547…; newer 011x numbers as 2541…. Alias mobile. |
message | Yes | Max 480 chars. Alias text. |
reference | Yes | Your idempotency key (max 64; A-Za-z0-9._-). Re-posting a successful reference returns the same result. |
{
"api_secret": "YOUR_API_SECRET",
"account_id": "BP-XXXX-XXXX",
"channel_id": "BP23356",
"phone": "254712345678",
"message": "Your order #8821 is ready for pickup.",
"reference": "ORDER-8821-SMS"
}
200 — success
{
"ok": true,
"success": true,
"reference": "ORDER-8821-SMS",
"phone": "254712345678",
"status": "SENT",
"fee_kes": 1.5,
"segments": 1,
"message_id": 12345,
"sender_name": "BLUEPAY",
"balance_kes": 97.5,
"sms_id": 1
}
Example (cURL)
curl -sS -X POST 'https://bluepay.co.ke/api/v1/sms/send' \
-H "Content-Type: application/json" \
-d '{"api_secret":"YOUR_API_SECRET","account_id":"BP-XXXX-XXXX","channel_id":"BP23356","phone":"254712345678","message":"Your order is ready.","reference":"ORDER-8821-SMS"}'
View sends in the dashboard under SMS. The fee is KES 1.50 from service tokens on each successful send. A repeat of a reference that already succeeded returns the same result and is not charged again.
Troubleshooting
- 404 or HTML instead of JSON — wrong BluePay URL. Use exactly
POST https://bluepay.co.ke/api/v1/sms/sendwithContent-Type: application/json. SMS_GATEWAY_ERROR— BluePay could not complete delivery on the network. Retry with a newreference; if it persists, contact BluePay support.- 422 phone — Safaricom numbers only (
2547…/071…).
error_code values
| HTTP | error_code | When |
|---|---|---|
| 402 | INSUFFICIENT_PREPAID | Service balance below SMS fee (required_kes, balance_kes) |
| 409 | REFERENCE_IN_USE | Same reference still PENDING |
| 422 | SMS_VALIDATION_FAILED | Invalid phone (non-Safaricom or bad format), message, or reference |
| 404 | NOT_FOUND | Wrong path — use exactly POST /api/v1/sms/send (not /api/sms/send without v1) |
| 502 | SMS_GATEWAY_ERROR | BluePay SMS service could not reach the mobile network — retry or contact support |
| 502 | SMS_PROVIDER_REJECTED | Message rejected (network or content rules) |
| 503 | SMS_NOT_CONFIGURED | SMS not enabled on this BluePay environment |