Forward an existing integration
If your server already receives Daraja or KopoKopo callbacks and you can't re-register the URLs, relay them to us. We verify each payment with the provider and deliver it like any other.
Your forwarding URLs
Each account has a secret forward key. Its URLs are on the account's page in the dashboard, under Forwarding:
# Daraja STK callback
https://api.mypayments.co.ke/webhooks/forward/{forward_key}/stk
# Daraja C2B confirmation
https://api.mypayments.co.ke/webhooks/forward/{forward_key}/confirmation
# Daraja C2B validation
https://api.mypayments.co.ke/webhooks/forward/{forward_key}/validation
# KopoKopo webhook
https://api.mypayments.co.ke/webhooks/forward/{forward_key}/eventThe key identifies the account and is the only credential on these URLs: keep it on your server. Rotating it in the dashboard keeps the old key working for a grace period while you switch.
Relaying
POST the provider's body unchanged, with Content-Type: application/json. For KopoKopo, pass its X-KopoKopo-Signature header through too. Keep answering the provider yourself as you do now.
// Inside your existing Daraja confirmation handler, after your own processing:
await fetch(process.env.MYPAYMENTS_FORWARD_CONFIRMATION_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: rawBody, // exactly what Safaricom sent
});For validation, our answer comes back in Daraja's format ({"ResultCode": "0", ...}): pass it back to Safaricom if you want us to accept or decline by account number.
What happens to forwarded money
- A forwarded callback is a claim from your server, so we confirm it with the provider (STK Query, or Transaction Status for C2B) before it counts.
- A forwarded C2B payment first sends
payment.received(verified: false,source: "forward"), thenpayment.settledonce Safaricom confirms it. Fulfil onpayment.settled. - Re-forwarding the same callback is harmless: the receipt is unique.
Transaction Status needs an initiator
has_payout_credentials: true). Without them forwarded C2B payments stay unconfirmed.Shared Mypayments paybills cannot be forwarded to: their callbacks come to us directly.