How to get Safaricom Daraja API keys for your Paybill or Till
Daraja is Safaricom's developer portal. It is how software, including a rent management system, receives notifications of payments to your Paybill or Till and sends M-Pesa prompts to tenants. You do not need to be a developer to get the keys, but you do need access to your shortcode's M-Pesa business account.
What you need before you start
- A Paybill or Till number registered to your business.
- The details of the person who administers that shortcode on Safaricom's M-Pesa business portal. Safaricom confirms ownership by sending them a one-time code.
- An email address for your Daraja account.
Steps
- Create a Daraja account at developer.safaricom.co.ke and confirm your email.
- Create an app. Daraja immediately gives you sandbox (test) keys. These only work with Safaricom's test system, not real money.
- Go live. Use the "Go Live" option in Daraja, choose your shortcode (Paybill or Till) and follow the verification. Safaricom checks that you control the shortcode before issuing production access.
- Copy your production keys. Your live app shows a consumer key and consumer secret. Treat them like a password.
- Get the passkey for M-Pesa prompts (Lipa na M-Pesa Online). Safaricom issues it for your shortcode once you go live, usually by email. If it does not arrive, contact Safaricom's Daraja support team through the portal.
For a Till number, prompts are sent through the store (head office) number linked to the till. Have both numbers ready.
Connecting the keys to the app
In the app go to Settings → Paybill, choose Paybill or Till, enter the shortcode and paste the consumer key, consumer secret and passkey. The app registers the payment notification addresses (callback URLs) with Safaricom for you, so payments start appearing against tenants straight away.
Your keys are stored encrypted and are never shown again after you save them. If you ever suspect they have leaked, generate new ones in Daraja and paste them in again.
Common problems
- Payments arrive but are not recorded: the callback URLs were not registered, or were registered by another system using the same shortcode. Only one system can receive notifications for a shortcode at a time.
- "Invalid credentials" when sending a prompt: you pasted sandbox keys, or the passkey belongs to a different shortcode.
- Tenants get no prompt: the phone number must be a Safaricom line in the format 07XXXXXXXX or 2547XXXXXXXX, and the phone must be on.
Next: how to collect rent by Paybill and match every payment.
Try it free
Invoices, M-Pesa to your own Paybill, reminders and caretaker access. Free for up to 10 units.
Create your free account