Skip to main content

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:
Your endpoint must use HTTPS. HTTP endpoints are not supported for security reasons.
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
Start with specific events you need. You can always add more later.
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.
Store this secret securely. It’s only shown once!

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 generated
  • X-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 a 2xx 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:
  1. Acknowledge the webhook immediately
  2. Process the event asynchronously
  3. 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

  • 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
  • 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
  • Implement idempotency using the event id field
  • Store processed event IDs and skip duplicates