Skip to main content
Neural Defend

Webhooks and Idempotency for Deepfake Detection APIs

For deepfake detection API webhooks and idempotency, verify each webhook's signature, store its event ID before acknowledging, and make the business action idempotent so duplicate or out-of-order events cannot approve a user twice or reopen a closed case. On the request side, never retry blindly: Neural Defend documents its NeuroVerify API as not idempotent, so reconcile timeouts before resubmitting media.

Maintained byNeural Defend Editorial
Updated April 22, 2026
Siva Shankar, Co-founder and CTO of Neural Defend.
Siva ShankarCo-founder & CTO
Event tokens pass verification and durable acceptance while duplicates converge and reordered events meet a state guard.

Why webhooks and idempotency matter for deepfake detection

A deepfake detection result usually triggers something with consequences: an account opens, a payout is released, a claim goes to an investigator. If the same result is applied twice, or an old result overwrites a new one, the damage is real. Two approvals for one applicant, a case reopened after closure, or a second charge for one file are typical failures, and all come from the same root cause: networks retry, and senders cannot know whether a message arrived.

Two separate problems hide under this heading. Webhook reliability is about receiving results safely when a service pushes them to you. Request idempotency is about sending media safely when your own call fails halfway. They need different controls, and confusing them is a common source of bugs.

How to receive deepfake detection webhooks safely

Follow a strict order: authenticate, persist, acknowledge, process. Verify the signature using the exact raw body the sender signed, before parsing it, and reject stale timestamps to block replays. The Standard Webhooks project, an open specification for webhook senders, names spoofing and replay as threats every implementation must handle, and its scheme pairs each message with an ID, a timestamp and a signature.

Once the event is verified, write its ID, type, subject and payload hash to durable storage, then return a 2xx response. Do the real work, such as updating the onboarding case, from an internal queue. A handler that calls three downstream systems before responding will time out under load, the sender will retry, and you will receive the same event again while the first copy is still running.

  • Enforce a body size limit and reject unsigned or badly signed requests.
  • Keep the raw body for signature checks; re-serialised JSON will not match.
  • Reject events outside the timestamp tolerance the sender documents.
  • Rotate signing secrets through an approved process and support two active secrets during rotation.

Deduplicating events and preventing state regression

Put a unique constraint on the event ID so a redelivery cannot create a second work item. That handles exact duplicates. It does not handle two different events that describe the same outcome, so make the business action idempotent as well: approving an applicant who is already approved should be a no-op, not a second approval.

Events also arrive out of order. A 'completed' event can land before 'processing', and a retried old event can arrive hours later. Give each case a transition table that only moves forward, for example received, analysing, scored, decided, closed, and reject any event that would move it backwards. Where the sender provides a sequence number or resource version, use it to decide which event is newer.

FailureWhat happens without a controlControl
Duplicate deliverySame result applied twiceUnique event ID plus idempotent business action
Out-of-order deliveryOld status overwrites a final resultForward-only state transitions or sequence numbers
Missed eventCase stuck in 'analysing' foreverScheduled reconciliation against the API
Forged or replayed eventAttacker marks a deepfake as cleanSignature verification and timestamp tolerance
Slow consumerSender times out and redeliversPersist and acknowledge first, process from a queue
Webhook failure modes and the control that handles each.

Retrying detection requests when the API is not idempotent

RFC 9110 defines idempotent methods as those where repeating a request has the same effect as sending it once; POST, the method most detection APIs use for uploads, is not one of them. Some APIs accept an Idempotency-Key header so a retried POST returns the original outcome. The IETF draft that tried to standardise that header reached version 07 in October 2025 and has since expired, so support varies by vendor.

Neural Defend's documentation is explicit for NeuroVerify: requests are not idempotent, each attempt can receive a new transaction identifier, and a duplicate can create another billable transaction. Its official Python and TypeScript SDKs retry only selected 429, 500 and 503 responses and deliberately skip timeouts and network failures, because those uploads may already have succeeded.

Build your own guard around that. Create a submission record keyed by your case ID and a hash of the media before calling the API. On a timeout, mark the record unknown rather than failed, and decide by policy whether to resubmit, wait for reconciliation or send the case to review. Never wrap the SDK in a second automatic retry loop.

Reconciling gaps and testing every delivery boundary

Webhooks are a fast path, not a guarantee. Run a scheduled job that finds cases stuck in a non-terminal state past their deadline and checks them against the source of truth, whether that is the vendor API or your own job store. Without reconciliation, one dropped event leaves an applicant waiting indefinitely.

Test failure, not just success. Simulate invalid signatures, stale timestamps, duplicate and reordered events, a missing event, a slow consumer, a database outage during persistence, and a crash just before and just after acknowledgement. For requests, simulate a timeout after the server accepted the upload and confirm that your code does not create a second transaction or a second decision.

What webhook and idempotency controls cannot fix

These controls make delivery correct. They do not make a result more accurate, and they cannot tell you whether a score is right. A medium-risk result delivered exactly once is still inconclusive and still needs a review owner. Signature verification proves the message came from the holder of the signing key; it says nothing about the media itself.

Webhook payloads may also carry personal data such as transaction identifiers or filenames. Keep payloads minimal, store them under the same retention rules as the rest of the case, and avoid logging raw bodies.

Building reliable integrations with Neural Defend

NeuroVerify's public contract is a synchronous request and response, so most teams receive results in the HTTP response and publish their own internal events from there; your event bus then carries the webhook concerns above. Each response includes a unique_trx_id, an outcome status of success, rejected or error, and risk fields, which give you a natural key for deduplication and audit. One request runs six signals and returns one risk score with evidence, and Neural Defend reports under 200 ms p95 on eligible image requests under defined test conditions, which keeps most selfie checks inline and reduces the number of asynchronous paths you have to make reliable in the first place. For investigation cases, NeuroDetect keeps model and version context with each analysis, so a reconciled result can still be explained later.

Evidence boundary

Limitations

  • NeuroVerify behaviour described here reflects Neural Defend's public developer documentation as of August 2026; its public contract does not describe webhook delivery or an idempotency key.
  • The Idempotency-Key header draft has expired at the IETF, so vendor support and semantics differ.
  • Delivery controls do not improve detection accuracy or replace human review of inconclusive results.

Frequently asked questions

What does idempotency mean for a deepfake detection API?

An idempotent request has the same effect whether you send it once or several times. For detection APIs, that would mean a retried upload returns the original result instead of creating a new analysis and charge. Many detection uploads use POST, which is not idempotent by default. NeuroVerify documents its requests as not idempotent, so guard retries in your own code.

Why do I receive the same webhook event more than once?

Senders retry when they do not receive a timely 2xx response, and they cannot tell whether your server processed the first attempt. Slow handlers, network blips and deploys all trigger redelivery. Store the event ID with a unique constraint, acknowledge quickly, and make the downstream action idempotent so duplicates are harmless.

Should I retry a deepfake detection request after a timeout?

Not automatically. A timeout does not prove the request failed; the server may have scored the media. With a non-idempotent API such as NeuroVerify, a retry can create a second billable transaction and a second result. Mark the submission as unknown, then resubmit, wait or route to review according to policy.

How do I stop an attacker from faking a 'clean' detection webhook?

Verify the signature on every webhook using the raw request body and the sender's documented scheme, reject messages outside the allowed timestamp window, and keep signing secrets in a secret manager with planned rotation. Never accept a result from an unsigned request, and never let a webhook move a case backwards from a final state.

Source record

Sources and references

  1. IETFRFC 9110: HTTP SemanticsPublished June 1, 2022. Verified October 19, 2026.
  2. IETFThe Idempotency-Key HTTP Header Field (draft-ietf-httpapi-idempotency-key-header-07)Published October 15, 2025. Verified October 19, 2026.
  3. Standard WebhooksStandard Webhooks specification and toolsVerified October 19, 2026.
  4. Neural DefendNeuroVerify errors and retriesVerified October 19, 2026.
  5. National Institute of Standards and TechnologySecurity and Privacy Controls for Information Systems and Organizations (SP 800-53 Rev. 5)Verified August 7, 2026.

Integrate with confidence

Build a duplicate-safe NeuroVerify integration

Use the documented status, transaction ID and retry rules to wire NeuroVerify into onboarding without double charges or conflicting decisions.

Explore NeuroVerify