AgentRef automatically retries failed webhook deliveries with exponential backoff. Here’s how to build a reliable webhook consumer.
Retry Schedule
If your endpoint doesn’t respond with a 2xx status code within 30 seconds, AgentRef retries:
After all 8 retry attempts are exhausted (9 total including the first), the message is marked as failed.
What Counts as Failure
Handling Duplicates
Your endpoint may receive the same event more than once – either from retries or from concurrent deliveries. Use the id field in the webhook envelope for idempotency:
In production, store processed event IDs in your database with a unique constraint rather than an in-memory Set.
Best Practices
Respond Quickly
Return a 200 response as soon as you receive the webhook. Process the event asynchronously:
Use a Queue
For complex processing, push webhook events to a queue (Redis, SQS, etc.) and process them with a worker:
Monitor Endpoint Health
If your endpoint consistently fails, webhook deliveries will accumulate retries. Monitor your webhook endpoint’s response times and error rates.
After all retries are exhausted, failed messages are not automatically re-sent. Check your webhook logs in the AgentRef dashboard to identify and investigate persistent failures.