Implementation:Openai Openai python Batch Cancelled Webhook
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Python |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for representing a batch cancelled webhook event from the OpenAI Webhooks API, provided by the openai-python SDK.
Description
BatchCancelledWebhookEvent is a Pydantic BaseModel subclass that represents the webhook event sent when a batch API request has been cancelled. It contains the event id, created_at timestamp, a data payload (nested Data model with the batch request id), a type field (always "batch.cancelled"), and an optional object field (always "event" when present). This model is used to deserialize incoming webhook payloads for batch cancellation notifications.
Usage
Import this type when you need to type-annotate or deserialize incoming webhook payloads for batch cancellation events, typically in a webhook handler endpoint.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/webhooks/batch_cancelled_webhook_event.py
Signature
class Data(BaseModel):
"""Event data payload."""
id: str
class BatchCancelledWebhookEvent(BaseModel):
"""Sent when a batch API request has been cancelled."""
id: str
created_at: int
data: Data
type: Literal["batch.cancelled"]
object: Optional[Literal["event"]] = None
Import
from openai.types.webhooks import BatchCancelledWebhookEvent
I/O Contract
Fields (BatchCancelledWebhookEvent)
| Name | Type | Required | Description |
|---|---|---|---|
| id | str | Yes | The unique ID of the event. |
| created_at | int | Yes | The Unix timestamp (in seconds) of when the batch API request was cancelled. |
| data | Data | Yes | Event data payload containing the batch request ID. |
| type | Literal["batch.cancelled"] | Yes | The type of the event. Always "batch.cancelled". |
| object | Optional[Literal["event"]] | No | The object of the event. Always "event" when present. |
Fields (Data)
| Name | Type | Required | Description |
|---|---|---|---|
| id | str | Yes | The unique ID of the batch API request. |
Usage Examples
from openai.types.webhooks import BatchCancelledWebhookEvent
# In a webhook handler (e.g., Flask/FastAPI)
def handle_webhook(payload: dict):
event = BatchCancelledWebhookEvent.model_validate(payload)
print(f"Batch {event.data.id} was cancelled at {event.created_at}")
print(f"Event type: {event.type}") # "batch.cancelled"