AI + Paid Media
The Webhook Signature Passed. The Same Paid-Media Action Still Arrived Twice.

Updated: November 22, 2026
A webhook body is untrusted until its signature is verified. Parsing it first and passing fields into logs, queues or agent prompts creates a path where unauthenticated content can influence the paid-media workflow. Verify the raw request body and headers with the project webhook secret before parsing or dispatch. Reject invalid signatures without creating jobs, approvals or account mutations.
Verify before the payload can influence work
A webhook body is untrusted until its signature is verified. Parsing it first and passing fields into logs, queues or agent prompts creates a path where unauthenticated content can influence the paid-media workflow.
Verify the raw request body and headers with the project webhook secret before parsing or dispatch. Reject invalid signatures without creating jobs, approvals or account mutations.
Treat a valid signature and a unique delivery as different checks
Signature verification proves that OpenAI sent the request; it does not guarantee exactly-once delivery. OpenAI documents that duplicate copies can occur, and the same signed delivery can pass verification more than once.
Read the authenticated webhook-id header and use it as a delivery key scoped to the endpoint. A repeated ID should receive a successful acknowledgement without reapplying any side effect.
Operating control table
| Control | Evidence | Failure prevented |
|---|---|---|
| Owner | Named reviewer and decision | Unclaimed change |
| Configuration | Saved source state | Cannot reproduce |
| Validation | End-to-end fixture | Partial success accepted |
| Threshold | Success and rollback rule | Result reinterpreted |
| Evidence | Public or reporting read-back | Configured mistaken for delivered |
Claim the ID atomically with the business effect
A check-then-insert sequence can fail under concurrency: two workers both see no record, both enqueue a budget review and both send the same action for approval.
Use a database unique constraint and claim the delivery ID in the same transaction that creates the downstream work record. Only the worker that wins the claim may continue.
Acknowledge quickly and move long work to a queue
OpenAI retries deliveries that do not return a successful response within a few seconds and can keep retrying for up to seventy-two hours with exponential backoff. Performing an account crawl inside the request handler increases duplicate pressure.
After verification and the atomic claim, enqueue the task and return a 2xx response. Let a background worker retrieve the response, evaluate the current account and record completion.
Model every terminal event explicitly
A completed response, a failed response and a canceled response are not interchangeable. A handler that only recognizes success can leave approvals open or repeatedly poll a request that will never finish.
Subscribe to the terminal events the workflow needs and map each one to a durable state. Make failure and cancellation close or quarantine related actions instead of falling through to a generic retry.
Re-read the ad account before any mutation
Deduplicating the webhook prevents the same delivery from running twice, but the completed analysis may still describe a stale account snapshot. Budgets, status and approvals can change while the response is processing.
Compare the live object with the source version captured when the job began. Require renewed approval when the target, value or risk level has changed, and store the verified webhook ID with the final audit record.
Connect the control to the wider system
Use this process alongside the background-job and terminal-state reconciliation framework. The platform setting, creative promise, measurement rule and downstream experience should describe the same decision.
Pre-launch checklist
- Write the decision and owner in plain language.
- Capture the source configuration and evidence.
- Test one realistic customer or reporting path end to end.
- Verify mobile presentation, links and accessibility.
- Record the success threshold and rollback trigger.
- Schedule the next review before material spend accumulates.
Run a cross-functional release review
Ask the channel owner, creative lead, analyst and conversion owner to inspect the same case. Each reviewer should state what was configured, what the customer sees, which event proves the outcome and which limitation changes the interpretation.
Repeat the test on mobile and with one adverse condition. Resolve differences in the campaign brief and measurement plan before launch.
Set the review cadence before launch
Assign a monitoring owner, review frequency and evidence threshold before the change is released. Preserve the pre-change baseline and avoid silently editing the definition after results arrive. This turns the launch into a measurable operating decision instead of a one-time interpretation of platform guidance.
At the first review, reconcile the source platform, public experience and one downstream business system. Close the change only when all three support the same conclusion, and record any limitation that future analysts must preserve.
Frequently asked questions
Should this be automated?
Automate repeatable validation and monitoring, but keep material policy, claim and budget decisions inside named approval limits.
What evidence should be preserved?
Keep the source configuration, decision owner, expected outcome, observed result and any exception that changes interpretation.
When should the team roll back?
Rollback when the control is inactive, the customer experience breaks, totals do not reconcile or the agreed threshold is breached.
