Carriers guarantee at-least-once webhook delivery. Handlers must deduplicate message SIDs to prevent duplicate user account creations or double credit charges.
Network hiccups between aggregators and your server will cause carrier gateways to retry webhooks up to 12 times. If your webhook handler is not strictly idempotent, duplicate events will create duplicate database records, duplicate credit deductions, or corrupted state machines.
1 Idempotency Architecture with Database Constraints
1. Extract Unique Message Identifier: Use carrier MessageSid or event UUID as an idempotency key.
2. Atomic Upsert or Unique Index: Enforce a unique database constraint on (provider, provider_message_id).
3. Distributed Mutex: For high-concurrency environments, acquire a 5-second distributed lock in Redis prior to processing side-effects.
Frequently Asked Questions • QA Automation & Testing
Carrier retry cycles typically complete within 24 hours. Retaining deduplication keys for 48 to 72 hours provides comprehensive protection against duplicate execution.