AI Help

How do I avoid processing the same AI completion webhook twice?

Verify the webhook, atomically claim its event ID and persist processing state so repeated deliveries do not repeat the business action.

Steps to follow

  1. Validate the signature using the provider's documented method before trusting event fields.
  2. Store a unique event ID with processing status in durable storage. An atomic insert or equivalent claim prevents concurrent duplicate handling.
  3. Make downstream operations idempotent and reconcile interrupted processing before retrying. Return the provider's expected acknowledgment promptly.

Example in practice

Illustrative example. Two deliveries of one completion event create one report-delivery job and one tracked completion outcome.

Related AI help

Official guidance

OpenAI documentation