Skip to content

Deduplicate duplicate webhook runs with idempotency keys

Prevent double token billing and duplicate database updates when third-party senders retry slow or flaky webhook deliveries.

Copy the prompt and paste it into the AI assistant you already use.

Steps to enforce idempotent AI webhooks

  1. 01

    Pick an immutable sender key

    Bind idempotency to the provider delivery ID or payload event_id rather than volatile timestamps.

  2. 02

    Handle concurrent in-flight duplicates

    Lock identical simultaneous deliveries so the second request waits for the first run rather than duplicating work.

  3. 03

    Set matching retention TTLs

    Ensure idempotency window length exceeds the maximum retry duration of your webhook sender.

  4. 04

    Log deduplicated cache hits

    Track duplicate-blocked counters in analytics to spot noisy upstream retry configurations.

Common questions

What response does a duplicate webhook receive?

APIkit returns HTTP 200 with the previously stored JSON response and a deduplicated flag, keeping callers happy with zero extra model spend.

What if two identical webhooks arrive at the exact same millisecond?

In-flight locking holds the concurrent duplicate briefly and shares the single model run's outcome rather than racing.

Can I extract the key from the JSON body instead of an HTTP header?

Yes. Point the idempotency rule at any JSONPath expression such as $.event.id or a standard Idempotency-Key header.