Skip to main content
This guide takes you from sandbox keys to a completed collection and payout. It takes about ten minutes.

Before you start

You need a Tanda account with sandbox access. Sign in to the dashboard and open Developers → API keys to find your sandbox public key and API key.
Your API key is a secret. Keep it on your server, in an environment variable or secrets manager. Never put it in a browser, mobile app or repository.
1

Generate a bearer token

Send your API key in the api-key header and your public key in the body.
Response
The token lasts one hour. Send it as Authorization: Bearer <token> on every other request.
2

Check your account

Confirm the token works and see your sandbox balance and webhook URLs.
3

Collect a payment

Send an M-PESA prompt to a sandbox test number. 254712345678 always succeeds in sandbox.
Response
Want Tanda to host the payment page instead? Create a checkout session and redirect the customer to the link it returns.
4

Confirm the outcome

Fetch the transaction by its transactionId or your externalReference. In production you’d wait for a webhook instead of polling.
Fulfil only when chargeStatus is successful.
5

Send a payout

Pay out to an M-PESA wallet. In sandbox, 254712345678 succeeds and 254787654321 fails.
The final status arrives as a payout_updated webhook.

Next steps

Set up webhooks

Receive outcomes in real time instead of polling.

Test every outcome

Sandbox values for success, failure and every customer step.