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