Back to feed
Dev.to
Dev.to
7/17/2026
Make your email agent idempotent against duplicate webhooks

Make your email agent idempotent against duplicate webhooks

Short summary

A deep dive into making AI email agents idempotent against duplicate webhook deliveries, which Nylas retries up to three times. Explains the critical distinction between notification id (delivery dedup key) and message id (email identity), how to persist processed ids atomically, why you ack before working, and where per-thread locks catch race conditions that dedup alone can't. Includes concrete webhook payload examples and CLI commands.

  • Nylas webhooks are at-least-once: same event can arrive up to 3 times, causing duplicate agent replies
  • Notification id is the dedup key, not message id — they answer different questions
  • Covers atomic persistence, ack-before-work pattern, and per-thread locks for race conditions

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more