Webhook Implementation
Receive real-time notifications when events occur in usmewe.Overview
Webhooks allow your application to react to events as they happen:- Loan funded/repaid
- Vault deposits/withdrawals
- Trust Score changes
- Social Vault alerts
Setting Up Webhooks
1. Create an Endpoint
Create an HTTPS endpoint to receive webhook events:2. Register the Webhook
Register your endpoint via API:3. Verify Signatures
Always verify webhook signatures:Event Structure
All webhook events follow this structure:Available Events
Loan Events
loan.created
loan.funded
loan.repaid
loan.overdue
Vault Events
vault.deposit
vault.withdraw
Trust Score Events
trust_score.updated
Social Vault Events
social_vault.withdrawal_requested
social_vault.locked
Event Handling
Recommended Pattern
Error Handling
Retry Logic
We retry failed webhooks with exponential backoff:| Attempt | Delay |
|---|---|
| 1 | Immediate |
| 2 | 1 minute |
| 3 | 5 minutes |
| 4 | 30 minutes |
| 5 | 2 hours |
| 6 | 24 hours |
Handling Failures
Testing Webhooks
Send Test Event
Local Development
Use ngrok or similar for local testing:Best Practices
Respond Quickly
Respond Quickly
Return 200 OK within 5 seconds. Process asynchronously:
Handle Duplicates
Handle Duplicates
Use event IDs for idempotency:
Log Everything
Log Everything
Log all webhooks for debugging:
Monitor Health
Monitor Health
Track webhook success rates and latencies.
Troubleshooting
Common Issues
| Issue | Solution |
|---|---|
| Invalid signature | Check secret matches, verify raw body |
| Missing events | Confirm webhook is active and events subscribed |
| Timeouts | Process async, return 200 quickly |
| Duplicate processing | Implement idempotency with event IDs |