Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Response Cancelled Webhook

From Leeroopedia
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete type for representing a response cancelled webhook event provided by the openai-python SDK.

Description

ResponseCancelledWebhookEvent is a Pydantic model class that represents the webhook payload sent when a background response has been cancelled. It extends BaseModel and includes an event identifier, a Unix timestamp for when the cancellation occurred, a nested Data payload containing the model response ID, a literal type field fixed to "response.cancelled", and an optional object field fixed to "event".

Usage

Import this type when building a webhook handler that needs to process background response cancellation events from the OpenAI API. Use it to deserialize incoming webhook payloads and clean up resources or update status tracking for cancelled responses.

Code Reference

Source Location

Signature

class Data(BaseModel):
    """Event data payload."""
    id: str

class ResponseCancelledWebhookEvent(BaseModel):
    """Sent when a background response has been cancelled."""
    id: str
    created_at: int
    data: Data
    type: Literal["response.cancelled"]
    object: Optional[Literal["event"]] = None

Import

from openai.types.webhooks import ResponseCancelledWebhookEvent

I/O Contract

Fields

Name Type Required Description
id str Yes The unique ID of the event.
created_at int Yes Unix timestamp (in seconds) of when the model response was cancelled.
data Data Yes Event data payload containing the model response ID.
data.id str Yes The unique ID of the model response.
type Literal["response.cancelled"] Yes The type of the event. Always "response.cancelled".
object Optional[Literal["event"]] No The object of the event. Always "event" when present.

Usage Examples

from openai.types.webhooks import ResponseCancelledWebhookEvent

# Parse a webhook payload
event = ResponseCancelledWebhookEvent.model_validate(payload)
print(f"Response {event.data.id} was cancelled at {event.created_at}")
print(f"Event type: {event.type}")  # "response.cancelled"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment