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