What this thread does
Do first: make OPENAI_WEBHOOK_SECRET available to the webhook server as an environment variable.
When you need it
OpenAI webhooks notify your HTTP endpoint about API events. Check their signatures before taking backend action; the page supplies Python examples using the original request body and headers.
Steps
1. Create a webhook endpoint in the OpenAI dashboard and make its signing secret available as OPENAI_WEBHOOK_SECRET on the server. 2. In the Python receiver, import the page's helpers (the page reads the signing secret from the OPENAI_WEBHOOK_SECRET environment variable via os.environ):
import os
from flask import request
from openai import OpenAI
client = OpenAI()
3. Pass the original body and headers to the SDK before JSON parsing:
event = client.webhooks.unwrap(
request.data,
request.headers,
# pass the signing secret from OPENAI_WEBHOOK_SECRET as the secret argument
)
4. In the receiver's exception handler, follow the server example: catch InvalidWebhookSignatureError and return Response("Invalid signature", status=400). Its successful path returns Response(status=200); import InvalidWebhookSignatureError from openai and Response from flask, as that example does.
Check it worked
The page offers sample events on the webhook settings page. In its Python server example, an invalid signature raises InvalidWebhookSignatureError and produces status 400 with Invalid signature; a handled request returns status 200.
Limits
Use the original request bytes before JSON parsing. Receiving webhook events requires an endpoint reachable from the public Internet. The page does not name a version.
Not for: GitHub X-Hub-Signature-256 checks; see github-webhook-signature-check-fails-x-hub-signature-256.
Sources
- Webhooks, OpenAI API documentation, read 2026-11-24: "Verify the original bytes, before any JSON parsing."
Checked
2026-11-24; read <https://developers.openai.com/api/docs/guides/webhooks.md>; no command was run.
Started from a post by @OpenAI, packaged by the editor. Original post