agents/apiTHE ENCYCLOPEDIA
Integration guides

Webhook verification, queues & deduplication

Turn signed session notifications into reliable background work and user-visible status updates.

Signed POST
Verify raw body
Durable inbox
Retrieve session
Process action

Notifications and streams have different jobs

Webhooks let a backend react without holding a stream open. Session notifications include created, action_required, in_progress, idle, and failed. For action_required, retrieve the session to obtain current required_actions; the notification does not contain all function arguments or connection details.

Verify before trusting the event

Create an endpoint in the OpenAI dashboard and store its signing secret server-side. Verify the original request body and headers with the OpenAI SDK before parsing or processing. JSON parsing and re-serialization can change signed bytes. The webhook signing secret is separate from the application API key and executor environment key.

Example
// Server-side verification boundary; call before accepting work.
// Install openai and set OPENAI_API_KEY + OPENAI_WEBHOOK_SECRET.
import OpenAI from "openai";
const client = new OpenAI({
  webhookSecret: process.env.OPENAI_WEBHOOK_SECRET,
});

export async function verifyNotification(rawBody, headers) {
  await client.webhooks.verifySignature(rawBody, headers);
  return JSON.parse(rawBody);
}

// Your HTTP handler must then durably store the verified event.
// Return success only after that write commits.
// Verification alone does not queue or execute the work.

Use a durable inbox

Application architecture: insert the verified event into a database inbox with a unique event ID. Acknowledge only after the insert commits. A worker can poll this inbox, avoiding a gap between saving an event and publishing to a separate queue. For an external queue, use a transactional outbox or equivalent durable delivery design. An in-memory Set does not survive restarts.

Make the worker safe to repeat

Retrieve current session state before acting: a notification may refer to an already-resolved action. Route environment_connection to the compute controller and function_call to an authorized tool handler. Deduplicate business effects using a stable operation key as well as deduplicating webhook delivery. A crash after a side effect but before marking completion must not charge a customer twice.

Test delivery failures

Exercise invalid signatures, duplicate delivery, unavailable storage, stale actions, and a worker crash. Return a non-success status if durable acceptance fails. Record event and session IDs for correlation without logging secrets or unrestricted tool payloads. Show pending, failed, and completed job states separately in the UI.

Read the official reference

Check the source for current API fields, account requirements, and service limits.

OpenAI: webhooks

38 matching topics

What is the OpenAI Agents API?FoundationsAgents API vs Agents SDK vs Responses APIComparisonsAgents API quickstartGetting startedSessions, turns & durable stateCore conceptsHosted vs self-hosted sandboxesInfrastructureConnect MCP servers to Agents APITools & integrationsFunction calling & application toolsTools & integrationsMulti-agent orchestrationCore conceptsStreaming, webhooks & event handlingIntegration guidesFiles, outputs & published artifactsCore conceptsVaults & MCP authenticationTools & integrationsAgent security & credential boundariesProductionTracing, usage & debuggingProductionAgents API pricing & cost planningProductionOpenAI Agents API with PythonGetting startedAgents API with TypeScript & Next.jsIntegration guidesWhat is the OpenAI Agents SDK?FoundationsResponses API in the agent stackFoundationsAgent Skills & SKILL.mdTools & integrationsProgrammatic Tool CallingTools & integrationsRAG, file search & vector storesTools & integrationsWeb search & source citationsTools & integrationsChatKit & Agent BuilderIntegration guidesAgent configuration & reusable definitionsCore conceptsPlugins: connect skills and MCP toolsTools & integrationsSandbox lifecycle & executor connectionsInfrastructureWebhook verification, queues & deduplicationIntegration guidesAgent retries, timeouts & failure recoveryProductionAgent evaluations & regression testingProductionWhich parts of the agent stack do you need?FoundationsAgents API contract quick referenceIntegration guidesOrder agent reference: approval, recovery & evaluationIntegration guidesBuild a Next.js order agent: server, tools & streamingIntegration guidesPython Agents API example with a real tool loopGetting startedHuman approval & prompt injection defensesProductionAgents API troubleshooting: symptoms, checks & recoveryProductionAgent tool support & runtime ownership matrixComparisonsAgent resources, relationships & task stateCore concepts
K to open Esc to close