Webhooks Guide

How webhooks work

  1. Create a webhook in your merchant dashboard, or via Create Webhook
  2. Save the signing secret. It's shown only once
  3. Implement a receiver on your server
  4. Verify the signature of every incoming payload
  5. Process the event based on its event field
  6. Return 200 OK within 10 seconds

Kawrie retries failed deliveries with exponential backoff for up to 24 hours.

Webhook events

| Event | Description | | --- | --- | | collection.completed | A payment was successfully received | | collection.failed | A payment attempt failed | | collection.reversed | A completed payment was reversed | | settlement.completed | A payout was successfully sent | | settlement.failed | A payout attempt failed | | kyc.approved | A merchant KYC review was approved | | kyc.rejected | A merchant KYC review was rejected |

Webhook payload

json
{
  "event": "collection.completed",
  "timestamp": "2026-06-28T10:30:00.000Z",
  "data": {
    "kawrie_reference": "KW-20260628-A1B2C3D4",
    "amount": 25000,
    "fee": 1875,
    "net_amount": 23125,
    "currency": "UGX",
    "customer_phone": "+256712345678",
    "customer_name": "John Doe"
  }
}

Verifying the signature

Every request includes a Kawrie-Signature header in the form t=<timestamp>,v1=<signature>. Recompute the signature with your webhook's signing secret and compare it before trusting the payload:

javascript
const crypto = require('crypto');

function verifyWebhookSignature(payload, signatureHeader, secret) {
  const [timestampPart, signaturePart] = signatureHeader.split(',');
  const timestamp = timestampPart.split('=')[1];
  const receivedSignature = signaturePart.split('=')[1];

  const stringToSign = timestamp + payload.event + payload.data.kawrie_reference;
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(stringToSign)
    .digest('hex');

  return receivedSignature === expectedSignature;
}

Reject any payload where the timestamp is more than five minutes old, to guard against replay attacks.