BluePayAPI
Ask AI
BluePay
API Keys Support Dashboard

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.

POSThttps://bluepay.co.ke/api/v1/sms/send

Auth: same as STK — api_secret, account_id, and channel_id. Not for browser use.

Body

FieldRequiredNotes
api_secretYesAPI secret from API Keys.
account_idYesAccount ID from API Keys.
channel_idYesChannel ID from API Keys.
phoneYesSafaricom MSISDN only — 071x/072x/074x/079x or 2547…; newer 011x numbers as 2541…. Alias mobile.
messageYesMax 480 chars. Alias text.
referenceYesYour 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/send with Content-Type: application/json.
  • SMS_GATEWAY_ERROR — BluePay could not complete delivery on the network. Retry with a new reference; if it persists, contact BluePay support.
  • 422 phone — Safaricom numbers only (2547… / 071…).

error_code values

HTTPerror_codeWhen
402INSUFFICIENT_PREPAIDService balance below SMS fee (required_kes, balance_kes)
409REFERENCE_IN_USESame reference still PENDING
422SMS_VALIDATION_FAILEDInvalid phone (non-Safaricom or bad format), message, or reference
404NOT_FOUNDWrong path — use exactly POST /api/v1/sms/send (not /api/sms/send without v1)
502SMS_GATEWAY_ERRORBluePay SMS service could not reach the mobile network — retry or contact support
502SMS_PROVIDER_REJECTEDMessage rejected (network or content rules)
503SMS_NOT_CONFIGUREDSMS not enabled on this BluePay environment