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:
const processedEvents = new Set() // Use a database in productionapp.post('/webhooks/agentref', (req, res) => { const event = req.body // Skip if already processed if (processedEvents.has(event.id)) { return res.status(200).send('Already processed') } // Process the event handleEvent(event) processedEvents.add(event.id) res.status(200).send('OK')})
In production, store processed event IDs in your database with a unique constraint rather than an in-memory Set.
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.