Your AI job finishes, a webhook arrives, and a worker updates a customer record. Then the same notification arrives again. Without a clear receiver design, one completed response can create repeated notes, repeated messages or an unexplained second change. Start the rollout with a receiver that distinguishes event receipt from business execution.
OpenAI webhooks notify an HTTP endpoint you control about subscribed API events. The documented response.completed example retrieves the response using event.data.id. That notification is a useful signal for a worker. It is not evidence that your customer action is approved, valid or already complete.
Define what the receiver accepts
Project webhook setup asks for an endpoint name, a public server URL and one or more event types. Creating the endpoint provides a signing secret for verification. Save it securely when issued because the guide says it cannot be viewed again. Keep development and production receiver configuration explicit in your own deployment records.
Write down which event types the receiver handles and what each can initiate. For a completed response, the next operation might be retrieving a result for validation. Avoid a generic handler that treats any recognized notification as permission to run a customer write.
| Boundary | Evidence to require | What it does not prove |
|---|---|---|
| Incoming request | Valid signature over original body and headers | Permission to update a customer system |
| Accepted delivery | Durable record of work to process | The worker has completed that work |
| Retrieved result | Known response matched to an internal job | The output meets business rules |
| External action | Current authorization and confirmed destination state | A retry can repeat the action safely |
Verify before parsing or branching
OpenAI recommends verifying webhook signatures before backend actions. The official SDK offers unwrap to verify and parse an event, and verifySignature when the application wants to parse it separately. The current Node SDK documentation says verification is asynchronous. Await completion before trusting the event or entering a processing branch.
Read the request as its original text and preserve the original headers. JSON middleware can consume the body, while parsing and reserializing can change the bytes that were signed. Configure the webhook route to retain the unmodified request body rather than reconstructing it from a parsed object.
The Node SDK checks the webhook-id, webhook-timestamp and webhook-signature headers. Its timestamp checks reject requests too far in the past or future, so keep the receiver clock synchronized. If verification fails, reject the event and record a redacted diagnostic. Do not log the signing secret or paste request contents into an unrestricted support channel.
Acknowledge durable receipt, then process
The webhook guide asks receivers to respond quickly with a successful status and recommends moving nontrivial processing to a background worker. It also documents retries for unsuccessful responses or timeouts. Redirect responses are not followed and count as failures. Point the configuration at the final endpoint URL.
As an application design recommendation, write the verified event into durable storage or a durable queue before returning success. If that handoff fails, do not claim that work was safely accepted. Returning success after only starting an in-memory task creates a recovery gap if the process exits.
Keep the endpoint's receipt record distinct from the worker's processing state. Accepted, processing, waiting for review, failed and confirmed are useful application states. They are suggested operating labels, not OpenAI webhook status fields. This distinction lets an operator answer whether delivery failed or a later business step failed.
Use two levels of duplicate protection
OpenAI documents that duplicate webhook deliveries can occur and recommends webhook-id as an idempotency key. Store that identifier in your receipt journal and use a database uniqueness rule or equivalent atomic operation so simultaneous deliveries cannot both create new work.
Delivery deduplication is only the first boundary. Define a separate business action key from trusted application data, such as customer job, approved operation and destination record. Multiple processing paths may try to act on the same job, including a polling fallback or an operator retry. They should converge on one action record.
A worker should claim work atomically and inspect the latest job state before acting. If the action is already confirmed, return its recorded outcome rather than performing it again. If an external write times out after submission, mark the outcome uncertain and reconcile the destination before retrying. Do not assume a transport error proves that the destination rejected the write.
Retrieve the result inside the correct job boundary
Match the verified response identifier to an internal job created by your application. Resolve customer identity, destination and expected operation from that record. Do not accept an unknown response as a new customer task simply because the notification passed signature verification.
Retrieve and validate the result before changing customer data. The documented completed-response example shows retrieval, not automatic business validation. Your own checks should confirm required fields, permitted destination records and any reviewer decision. A generated recommendation can be syntactically valid and still be wrong for the customer workflow.
For a multitenant application, apply the same trusted customer boundary used elsewhere in the service. Our tenant isolation guide covers the broader routing problem. A webhook worker needs that boundary too, especially when queue consumers use pooled credentials or support several destinations.
Test receiver failures and recovery paths
OpenAI provides test events through webhook settings. Use those to verify connectivity and your receiver's accepted event path. Then add application-level fixtures for damaged signatures, changed body text, duplicate deliveries, simultaneous workers and a queue failure before acknowledgement.
- Deliver the same verified notification repeatedly and confirm one receipt becomes actionable.
- Run the webhook and fallback processing paths together and confirm one business action.
- Stop a worker after acceptance and verify another worker can recover the job.
- Simulate an uncertain destination write and require reconciliation before replay.
- Change the job's approval or customer access before execution and confirm the worker rechecks it.
These are recommended acceptance tests, not guarantees supplied by the webhook service. Keep test payloads out of production customer actions. Check both the receipt journal and final destination state so a clean queue dashboard cannot hide duplicate business writes.
Give operators an actionable handoff
Keep redacted event identifiers, internal job references, processing attempts and confirmed outcomes in an access-controlled journal. Assign an owner for failed verification, stuck work and uncertain writes. Document secret rotation through the normal settings route and verify the receiver after a configuration change.
Connect this receiver design to your background job workflow rather than creating a second source of truth. The application job remains the place to decide whether work is pending, approved or completed. Notifications should advance that state through controlled transitions.
How Remqa helps with webhook rollouts
Remqa provides forward deployed engineering capacity for customer-facing AI integrations. The work can include verified receivers, durable handoffs, reviewed actions and failure-path testing around an existing product. Bring one real customer workflow and the action it must never repeat. Define that boundary before expanding the rollout.