Prerequisites
Before setting up webhooks, ensure you have:- An active Affonso account with an affiliate program
- A publicly accessible HTTPS endpoint to receive webhooks
- The ability to verify webhook signatures (recommended)
Creating a Webhook Endpoint
1
Navigate to Webhooks
Go to your Affonso dashboard and select Settings → Webhooks from the sidebar.
2
Add New Endpoint
Click Add Endpoint and enter your webhook URL:
3
Select Events
Choose which events you want to receive. You can select:
- All events - Receive every webhook event
- Specific events - Only receive selected event types
4
Copy Signing Secret
After creating the endpoint, copy your Signing Secret. You’ll need this to verify webhook signatures.The secret is a 64-character hex string. Use it as-is as a string key; do not hex-decode it.
Verifying Webhook Signatures
Always verify webhook signatures to ensure requests are from Affonso.Signature Header
Each webhook request includes two headers:X-Affonso-Timestamp— Unix timestamp (seconds) of when the signature was generatedX-Affonso-Signature— lowercase hex HMAC-SHA256 of{timestamp}.{rawBody}, with no prefix
Verification Process
Responding to Webhooks
Your endpoint must respond correctly for webhooks to be considered delivered.Success Response
Return a2xx status code to acknowledge receipt:
Response Time
Affonso waits up to 10 seconds for a response; slower responses count as failed and are retried. See the retry policy for how failed deliveries are retried. If processing takes longer:- Acknowledge the webhook immediately
- Process the event asynchronously
- Use a job queue for heavy processing
Testing Webhooks
Test Events
Use the Send Test Event button in your dashboard to send a test webhook to your endpoint.Local Development
For local development, use a tunneling service:Troubleshooting
Webhook not receiving events
Webhook not receiving events
- Verify your endpoint URL is correct and publicly accessible
- Check that your endpoint returns a 2xx status code
- Ensure you’ve selected the correct events to receive
Signature verification failing
Signature verification failing
- Ensure you’re using the raw request body, not parsed JSON
- Use the secret as a plain string (not hex-decoded, no prefix)
- Sign
{timestamp}.{rawBody}using the X-Affonso-Timestamp header - Check that your signing secret is correct
- Verify the timestamp is within 5 minutes
Receiving duplicate events
Receiving duplicate events
- Implement idempotency using the event
idfield - Store processed event IDs and skip duplicates
