Kenya at a Glance

DetailValue
Country Code254
CurrencyKES (Kenyan Shillings)
OperatorsSafaricom M-Pesa, Airtel Money

Phone Number Format

Format: 254{9 digit subscriber number}
Example: 254712345678  (Safaricom M-Pesa)
         254733123456  (Airtel Money)

Local to international:
  0712 345 678  →  254712345678
  +254 712 345 678  →  254712345678

Test Configuration

curl -X POST https://api.rohopay.com/api/v1/collect \
  -H "Authorization: Bearer test_YOUR_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "phone": "254700000000",
    "amount": 1000,
    "currency": "KES",
    "description": "Test Kenya payment"
  }'

Operators

Safaricom M-Pesa

  • USSD: *334#
  • Prefixes: 0700–0709, 0710–0729, 0740–0749, 0757–0759, 0790–0799
  • Send/Receive limit: KES 300,000 per transaction
  • Support: Safaricom — 0722 000 000

Airtel Money Kenya

  • USSD: *334#
  • Prefixes: 0730–0739, 0751–0756
  • Support: Airtel Kenya — 0800 724 000

Common KES Amounts

KESAPI Value
1010
100100
500500
1,0001000
5,0005000
10,00010000

Integration Example (Kenya)

async function collectKenyaPayment(localPhone: string, amountKES: number) {
  const digits = localPhone.replace(/\D/g, "");
  const phone = digits.startsWith("254") ? digits
    : digits.startsWith("0") ? "254" + digits.slice(1)
    : "254" + digits;

  if (!/^254[0-9]{9}$/.test(phone)) {
    throw new Error("Invalid Kenya phone number");
  }

  return fetch("https://api.rohopay.com/api/v1/collect", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.ROHOPAY_API_KEY}`,
      "Idempotency-Key": crypto.randomUUID(),
    },
    body: JSON.stringify({
      phone,
      amount: amountKES,
      currency: "KES",
      callback_url: "https://your-app.com/webhooks/rohopay",
    }),
  }).then(r => r.json());
}

M-Pesa STK Push Flow

For Kenya, M-Pesa uses the STK Push mechanism:
  1. Your app sends the collection request with the customer’s phone
  2. M-Pesa sends an STK Push prompt to the customer’s phone
  3. Customer enters their M-Pesa PIN to approve
  4. RohoPay receives the webhook and notifies your callback URL
This is equivalent to the USSD flow in Uganda — the user experience is the same.