Webhook Management
Manage webhook endpoints through the API to receive real-time transaction notifications.Create Webhook
List Webhooks
Update Webhook
Delete Webhook
204 No Content
status, indicating the webhook has been successfully deleted and there is no further information to return.
Test Webhook
Webhook Configuration
The following tables give you a quick overview of the available webhook authentication methods and status values.Authentication Methods
These are the available webhook authentication methods.Method | Description | Credentials Format |
---|---|---|
BEARER | Bearer token authentication | {"token": "your_bearer_token"} |
API_TOKEN | Custom header with API key | {"header": "X-API-Key", "token": "your_api_key"} |
BASIC_AUTH | HTTP Basic Authentication | {"username": "user", "password": "pass"} |
NONE | No authentication | {} (not recommended for production) |
Webhook Status
These are the available webhook status values.Status | Description |
---|---|
active | Webhook is operational and receiving notifications |
inactive | Webhook is configured but not receiving notifications |
error | Webhook endpoint failed connectivity test |
Webhook Events
Tonder sends webhook notifications for various transaction events:Payment Events
- Transaction status changes (pending → authorized → success)
- Payment failures and declines
- 3DS authentication completions
- Cash payment confirmations (OXXO, SafetyPay)
Withdrawal Events
- Withdrawal processing updates
- Payout completions and failures
- SPEI transfer confirmations
- Debit card deposit completions
Webhook Payload Structure
All webhook notifications follow a consistent payload structure:Field | Type | Description |
---|---|---|
event_type | string | Type of event that occurred |
event_id | string | Unique identifier for this webhook event |
created_at | string | ISO 8601 timestamp when event occurred |
data | object | Transaction data and details |
data.status | string | Current transaction status |
data.previous_status | string | Previous transaction status |
Implementation Examples
The following examples show how to implement webhook handling in different programming languages.Webhook Delivery & Retry Logic
Tonder’s webhook service ensures reliable delivery of webhook notifications through AWS SQS-based retry mechanisms and comprehensive error handling. The following are the retry configuration for webhook delivery:Setting | Value | Description |
---|---|---|
Maximum retry attempts | 3 | Each webhook delivery will be tried up to 3 times |
Processing timeout | 30 seconds per attempt | Each delivery attempt has a 30-second processing window |
Visibility timeout | 60 seconds between retries | 60 seconds wait before a failed attempt is retried |
Total retry window | Up to 3 minutes (3 × 60 seconds) | Maximum time spent retrying a single webhook |
Message retention | 14 days in the primary queue | Messages are kept for up to 14 days if not delivered |
Retry Behavior
When a webhook delivery fails, the system automatically:- Logs the failure with detailed error information and attempt tracking
- Returns the message to the SQS queue for retry
- Waits 60 seconds before the next retry attempt becomes available
- Repeats up to 3 times total
Failure Handling
These are the reasons why a webhook delivery is considered to have failed straight away:- Network connection errors
- HTTP timeout (30 seconds)
- Non-2xx HTTP response codes
- Invalid webhook endpoints
Success Criteria
A webhook delivery is considered successful when:- HTTP response status is 2xx (200-299)
- Response received within 30 seconds
- No network or connection errors
Best Practices for Webhook Endpoints
Below are some best practices to help you build reliable, secure, and robust webhook endpoints.Testing Webhooks
There are two main approaches to testing webhook integration: local development testing and production environment testing. Use this code example to create a test endpoint that works for both local and production testing approaches:Test Webhook Endpoint
Local Development Testing
Use this approach during development to test webhook integration:- Use ngrok for local testing:
ngrok http 5000
- Configure webhook URL with the ngrok URL
- Process test transactions to trigger webhooks
- Verify payload structure and authentication
Production Environment Testing
Use this approach to test webhooks in a production-like environment:- Test connectivity using the test webhook endpoint
- Verify authentication works correctly
- Check retry behaviour by temporarily returning errors
- Monitor webhook logs for delivery success
Monitoring and Observability
The webhook service provides comprehensive logging for:- Individual delivery attempts with timing metrics
- Retry attempt tracking (attempt_number, max_attempts, will_retry)
- Performance metrics (request duration, processing time)
- Failure analysis with exception details
- Monitor webhook delivery success rates
- Set up alerts for repeated failures
- Track webhook processing times
- Monitor endpoint uptime and availability
- Review failed webhook logs regularly
Troubleshooting
These are the most common issues you might encounter and how to resolve them:Issue | Cause | Solution |
---|---|---|
401 Authentication errors | Invalid credentials | Verify webhook authentication settings |
404 Endpoint not found | Incorrect URL | Check webhook URL configuration |
Timeout errors | Slow processing | Optimize webhook processing time |
500 Server errors | Processing failures | Check webhook endpoint logs |
- Check webhook configuration - Verify URL and authentication
- Test endpoint manually - Use curl or Postman to test
- Review logs - Check both Tonder and your endpoint logs
- Verify network connectivity - Ensure endpoint is accessible
- Test with simple payload - Use webhook test endpoint
Next Steps
- Review Error Handling for comprehensive error management
- Check Production Readiness for webhook monitoring setup
- Learn about Status Checking as a webhook backup
- Explore Payment Methods for method-specific webhook events