Webhooks

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.

EventSent when
collection.paidA collection settled: mobile money push, mobile money or bank transfer.
collection.failedA mobile-money collection was declined, expired or refused.
payout.completed / payout.failedA cross-border payout finished.

Headers

Every delivery carries these headers:

HeaderValue
X-Swahilies-Signaturehex HMAC-SHA256 over "{timestamp}.{raw_body}", using your signing secret
X-Swahilies-TimestampUnix-seconds timestamp used in the signed string
X-Swahilies-Eventthe event name, e.g. collection.paid
X-Swahilies-Deliverydelivery 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 2xx as soon as you've stored the event. Do slow work afterwards.
  • Any non-2xx response, 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

  1. Read the raw body.   2. Verify the signature.   3. Look up the transaction by your reference.   4. Apply the state change once.  
  2. Return 200.