What are Webhooks?
Webhooks are HTTP callbacks that Devdraft sends to your application when specific events occur. When an event happens (like a payment completion or transfer update), Devdraft makes an HTTP POST request to a URL you specify, containing details about the event.Key Benefits
Real-Time Updates
Receive instant notifications when events occur, enabling immediate response to critical changes
Efficient Integration
Eliminate the need for constant API polling, reducing server load and improving performance
Reliable Delivery
Built-in retry mechanisms and delivery confirmations ensure events reach your application
Secure Communication
Cryptographic signatures and optional encryption protect webhook payload integrity
How Webhooks Work
1
Event Occurs
An event happens in your Devdraft account (e.g., payment completed, transfer initiated)
2
Event Queued
Devdraft queues the event for delivery to all registered webhook endpoints
3
HTTP Request Sent
Devdraft sends an HTTP POST request to your webhook URL with event details
4
Your App Responds
Your application processes the event and returns an HTTP 200 status code
5
Delivery Confirmed
Devdraft marks the event as delivered and updates delivery statistics
Supported Event Types
Devdraft supports a comprehensive range of webhook events across different areas of functionality:Payment Events
Payment Lifecycle
Payment Lifecycle
- payment.created - New payment initiated
- payment.pending - Payment is being processed
- payment.completed - Payment successfully processed
- payment.failed - Payment processing failed
- payment.refunded - Payment has been refunded
- payment.disputed - Payment dispute initiated
Payment Links
Payment Links
- payment_link.created - Payment link created
- payment_link.paid - Payment link successfully paid
- payment_link.expired - Payment link expired
- payment_link.cancelled - Payment link cancelled
Transfer Events
Cross-Chain Transfers
Cross-Chain Transfers
- transfer.initiated - Transfer process started
- transfer.pending - Transfer being processed
- transfer.completed - Transfer successfully completed
- transfer.failed - Transfer processing failed
- transfer.refunded - Failed transfer refunded
Stablecoin Conversions
Stablecoin Conversions
- conversion.started - Conversion process initiated
- conversion.completed - Conversion successfully completed
- conversion.failed - Conversion failed
- conversion.rate_expired - Exchange rate expired
Wallet Events
Balance Changes
Balance Changes
- wallet.balance_updated - Wallet balance changed
- wallet.deposit_received - New deposit detected
- wallet.withdrawal_processed - Withdrawal completed
- wallet.low_balance - Balance below threshold
Wallet Management
Wallet Management
- wallet.created - New wallet created
- wallet.activated - Wallet activated
- wallet.suspended - Wallet suspended
- wallet.archived - Wallet archived
Customer Events
Customer Lifecycle
Customer Lifecycle
- customer.created - New customer registered
- customer.updated - Customer profile updated
- customer.verified - KYC verification completed
- customer.suspended - Customer account suspended
KYC Events
KYC Events
- kyc.submitted - KYC documents submitted
- kyc.approved - KYC verification approved
- kyc.rejected - KYC verification rejected
- kyc.expired - KYC verification expired
Invoice Events
Invoice Lifecycle
Invoice Lifecycle
- invoice.created - New invoice created
- invoice.sent - Invoice sent to customer
- invoice.paid - Invoice payment received
- invoice.overdue - Invoice past due date
- invoice.cancelled - Invoice cancelled
- invoice.refunded - Invoice refunded
Webhook Configuration
Basic Setup
Create webhooks through the API or Devdraft console:
Advanced Configuration
Retry Policies
Retry Policies
- Automatic retries: Failed deliveries are retried automatically
- Exponential backoff: Increasing delays between retry attempts
- Maximum attempts: Up to 5 retry attempts per event
- Failure handling: Events marked as failed after all retries exhausted
Rate Limiting
Rate Limiting
- Delivery rate: Up to 100 events per second per webhook
- Burst handling: Short bursts of events handled efficiently
- Queue management: Events queued during high-traffic periods
- Priority delivery: Critical events prioritized in delivery queue
Filtering Options
Filtering Options
- Event types: Subscribe to specific event categories
- Conditional delivery: Filter based on event properties
- Application scoping: Events filtered by application context
- Custom filters: Advanced filtering based on business logic
Security Features
Signature Verification
Every webhook payload includes a cryptographic signature for verification:Payload Encryption
For sensitive data, enable payload encryption:Webhook Payload Structure
All webhook events follow a consistent payload structure:Payload Fields
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the webhook event |
type | string | Event type (e.g., “payment.completed”) |
api_version | string | API version when event was generated |
created | string | ISO 8601 timestamp when event was created |
data | object | Event-specific data containing the main object |
metadata | object | Additional context about the event |
Implementation Best Practices
Endpoint Requirements
HTTP Requirements
HTTP Requirements
- HTTPS only: Use HTTPS endpoints for security
- Valid SSL certificate: Ensure proper SSL/TLS configuration
- Fast response: Return HTTP 200 within 30 seconds
- Idempotency: Handle duplicate events gracefully
Error Handling
Error Handling
- Return appropriate status codes: 200 for success, 4xx/5xx for errors
- Log webhook events: Maintain logs for debugging and auditing
- Graceful degradation: Handle webhook failures without breaking your app
- Retry logic: Implement your own retry logic for critical operations
Performance Optimization
1
Async Processing
Process webhook events asynchronously to respond quickly:
2
Queue Management
Use message queues for high-volume webhook processing:
3
Database Optimization
Optimize database operations for webhook processing:
Testing and Debugging
Local Development
Use ngrok to expose local development servers:
Debugging Tools
Webhook Logs
Webhook Logs
- Delivery logs: Track webhook delivery attempts and responses
- Error logs: Detailed error information for failed deliveries
- Performance metrics: Response times and success rates
- Payload inspection: View full webhook payload for debugging
Testing Utilities
Testing Utilities
- Event replay: Replay webhook events for testing
- Payload validation: Validate webhook payloads against schemas
- Signature testing: Test signature verification implementation
- Load testing: Test webhook endpoint performance under load
Common Integration Patterns
Event-Driven Architecture
State Machine Updates
Getting Started
Ready to implement webhooks in your application? Follow these steps:1
Set Up Endpoint
Create a webhook endpoint in your application that can receive HTTP POST requests
2
Create Webhook
Use the Create Webhook API to register your endpoint
3
Implement Verification
Add signature verification to ensure webhook authenticity
4
Handle Events
Process webhook events and update your application state accordingly
5
Monitor Performance
Use the Fetch Webhook API to monitor delivery statistics
API Reference
Explore the webhook management endpoints:Create Webhook
Register new webhook endpoints for receiving events
List Webhooks
Retrieve all webhooks associated with your application
Fetch Webhook
Get detailed information about a specific webhook
Delete Webhook
Remove webhook endpoints from your application
Next Steps
- Create Your First Webhook - Set up webhook endpoints
- Event Reference - Explore available event types
- Security Guide - Implement secure webhook handling
- Testing Guide - Test webhook integrations