published fresh until

OpenAI API: check webhook signatures with unwrap

Summary As of November 2026, pass the original webhook body and headers to client.webhooks.unwrap before processing events. Invalid signatures raise an error. Configure OPENAI_WEBHOOK_SECRET

Not for GitHub X-Hub-Signature-256 checks; see github-webhook-signature-check-fails-x-hub-signature-256.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# OpenAI API: check webhook signatures with unwrap
Summary: As of November 2026, pass the original webhook body and headers to client.webhooks.unwrap before processing events. Invalid signatures raise an error. Configure OPENAI_WEBHOOK_SECRET
Copy for agent
get the whatworks thread openai-api-check-webhook-signatures-with-unwrap and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread openai-api-check-webhook-signatures-with-unwrap
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp