Webhooks
What is a Webhook?
POST
request) from one application to another when a specific event occurs. Unlike traditional polling, where a system repeatedly checks for updates, webhooks push data automatically, reducing latency and improving efficiency.How Webhooks Work
1.
2.
3.
POST
request to the webhook URL, containing the event details in JSON or XML format.4.
5.
200 OK
for success). If the request fails, the sender may retry to ensure reliable delivery.Example of a Webhook Flow in Banking
Scenario: A Real-Time Payment Notification Webhook
1.
https://merchant.com/webhook/payment
2.
3.
4.
{
"event": "payment.success",
"transaction_id": "TXN123456789",
"amount": 5000,
"currency": "NGN",
"customer": {
"name": "John Doe",
"email": "john.doe@example.com"
},
"status": "successful",
"timestamp": "2025-04-03T14:30:00Z"
}
Webhook vs. API Polling: Why Webhooks Are Better?
1. Webhooks (Push Mechanism)
2. API Polling (Pull Mechanism)
Comparison Table
Feature | Webhooks | API Polling |
---|---|---|
Data Delivery | Instant (push) | Delayed (pull) |
Efficiency | High | Low |
Server Load | Low | High (frequent requests) |
Bandwidth Usage | Minimal | High |
Real-time Updates | Yes | No |
Reliability | Requires proper handling of retries | Can miss updates if polling interval is too long |
Complexity | Requires webhook endpoint setup | Simpler but inefficient for frequent updates |
When to Use Webhooks vs. API Polling
Transactions Payload
Regular Transaction Payload
Transfer Payload
{
"id": 1445,
"nuban": "0020000015",
"amount": 20,
"note": "Inward Test - MOHAMMED BALARABE OLATEJU",
"transactionType": "Deposit",
"balance": 66,
"createdDate": "2024-10-27T06:00:48Z",
"currency": "NGN",
"transactionReference": "000012241027065934422656001526",
"transferDetails": {
"amount": 20,
"sourceBankName": "STANBICIBTC BANK",
"transactionStatus": "CONFIRMED",
"transactionReference": "000012241027065934422656001526",
"sessionId": "000012241027065934422656001526",
"type": "INWARD_TRANSFER",
"destinationAccountNUBAN": "0020000015",
"destinationAccountName": "Mohammed Olateju",
"destinationInstitutionCode": "090605",
"sourceAccountNUBAN": "0040088210",
"narration": "Inward Test",
"sourceInstitutionCode": "0000122",
"destinationBankName": "Madobi Microfinance Bank",
"sourceAccountName": "MOHAMMED BALARABE OLATEJU"
}
}
Modified at 2025-04-03 20:11:02