Security Best Practices
Implement these security measures to protect your webhook endpoints:Always use a secure (HTTPS) URL for your webhook endpoint
Always use a secure (HTTPS) URL for your webhook endpoint
HTTP connections are unencrypted and vulnerable to man-in-the-middle attacks. HTTPS ensures data transmitted between Tonder and your endpoint remains secure and tamper-proof.
Use an authentication method to verify requests from Tonder
Use an authentication method to verify requests from Tonder
Configure authentication (BEARER, API_TOKEN, or BASIC_AUTH) when creating your webhook to prevent unauthorized requests from malicious actors attempting to trigger false events in your system.
Validate the event structure and content before processing
Validate the event structure and content before processing
Check that required fields are present and contain expected data types before processing webhook events to prevent errors from malformed or unexpected payloads.
Implementation Best Practices
Follow these implementation guidelines for reliable webhook processing:Acknowledge receipt immediately with a 200 OK status
Acknowledge receipt immediately with a 200 OK status
Tonder has a 30-second timeout for webhook responses. Return a success status immediately upon receiving the webhook, then process the actual business logic (like updating databases or sending emails) in the background to avoid timeouts.
Use the event_id to deduplicate events
Use the event_id to deduplicate events
Store processed event IDs temporarily (24-48 hours) and check against this list before processing new events. Tonder’s retry mechanism may send the same event multiple times if your endpoint is temporarily unavailable.
Keep detailed logs of all incoming webhook events
Keep detailed logs of all incoming webhook events
Log the full webhook payload, processing status, and any errors to help troubleshoot issues. Include timestamps and event IDs to correlate webhook events with your application’s business logic.
Ensure errors don't crash your entire system
Ensure errors don't crash your entire system
Wrap webhook processing in try-catch blocks and handle errors gracefully. A failed webhook should not bring down your entire application or prevent other webhooks from being processed.
Next Steps
After implementing webhook best practices:- Create your first payment to test webhook notifications.
- Review HTTP response codes for proper webhook response handling.
- Check rate limits to understand webhook delivery patterns.