Webhooks
Swahilies notifies your server of asynchronous results — a collection settling, a
payout completing, a card payment finishing 3-D Secure — by POSTing a signed
JSON event to an endpoint you configure in the dashboard.
Event shape
{
"event": "collection.paid",
"id": "FT26289M2C91",
"created_at": "2026-10-20T09:12:00Z",
"data": {
"merchant_txn_ref": "order_1042",
"rail": "tembo",
"status": "paid",
"amount_minor": 150000,
"currency": "TZS"
}
}event is <product>.<status> (e.g. collection.paid). id is the event's
idempotency key — key your handler off it, since delivery is at-least-once.
| Event | Sent when |
|---|---|
collection.paid | A collection settled: mobile money push, mobile money or bank transfer. |
collection.failed | A mobile-money collection was declined, expired or refused. |
payout.completed / payout.failed | A cross-border payout finished. |
Headers
Every delivery carries these headers:
| Header | Value |
|---|---|
X-Swahilies-Signature | hex HMAC-SHA256 over "{timestamp}.{raw_body}", using your signing secret |
X-Swahilies-Timestamp | Unix-seconds timestamp used in the signed string |
X-Swahilies-Event | the event name, e.g. collection.paid |
X-Swahilies-Delivery | delivery id (for your logs / dedupe) |
Your signing secret is returned once when you configure your endpoint
(PUT /api/psp/callbacks/endpoint).
Verifying the signature
Recompute the HMAC over the raw body and compare it to X-Swahilies-Signature:
import hashlib, hmac
def verify(request, secret: str) -> bool:
timestamp = request.headers["X-Swahilies-Timestamp"]
signature = request.headers["X-Swahilies-Signature"]
raw_body = request.get_data() # raw bytes, before any JSON parsing
expected = hmac.new(
secret.encode(),
f"{timestamp}.".encode() + raw_body,
hashlib.sha256,
).hexdigest()
return hmac.compare_digest(expected, signature)Compute the HMAC over the raw request body, before any JSON parsing or re-serialisation. Reject the request if the signature doesn't match, or if the timestamp is too old (guards against replay).
Responding
- Return
2xxas soon as you've stored the event. Do slow work afterwards. - Any non-
2xxresponse, or a timeout, is retried with backoff. - Delivery is at-least-once: the same event may arrive more than once. Key
your handler off the event id (or the
merchant_txn_ref/reference) and make it idempotent.
Recommended handler
- Read the raw body. 2. Verify the signature. 3. Look up the transaction by your reference. 4. Apply the state change once.
- Return
200.