Events

The `Event` object and its typed accessors.

Your handler receives one Event per delivery. Branch on event.type, read data via the typed accessor.

@client.on_event()
async def handle(event):
    if event.type == "webhook.received":
        handle_webhook(event.webhook)       # WebhookData | None
    elif event.type == "email.received":
        handle_email(event.email)           # EmailData | None

Fields

AttributeTypeNotes
idstrULID. Stable across live + replay.
typestrwebhook.received or email.received.
originstrlive or replay. Use for idempotency.
created_atdatetimeTimezone-aware UTC.
channelChannel.id, .label, .type.
datadict[str, Any]Raw source payload.
prompt_readystrLLM-ready text rendering.
prompt_ready_versionintRenderer version stamp.
webhookWebhookData | NonePopulated when type == "webhook.received".
emailEmailData | NonePopulated when type == "email.received".

WebhookData

event.webhook.method          # "POST"
event.webhook.path            # "/v1/webhook/…"
event.webhook.headers         # dict[str, str]
event.webhook.body_encoding   # "json" | "text" | "base64"
event.webhook.body            # Any | None — JSON-decoded when encoding is "json"
event.webhook.body_raw_b64    # str — raw bytes base64-encoded, when "base64"
event.webhook.body_size_bytes # int

EmailData

event.email.from_             # str — (note the trailing underscore; `from` is a Python keyword)
event.email.to                # list[str]
event.email.cc                # list[str]
event.email.bcc               # list[str]
event.email.subject           # str
event.email.text              # str
event.email.html              # str
event.email.message_id        # str — RFC 5322 Message-ID; used for threading replies
event.email.attachments       # list[Attachment]
event.email.received_at       # datetime | None

Attachment

attachment.filename           # str
attachment.content_type       # str
attachment.size_bytes         # int
attachment.url                # str | None — signed, short-lived (future)

Immutability

Event is a frozen dataclass. Safe to share across tasks, safe to cache, safe to hash.

Prompt-ready

A small convenience: event.prompt_ready is a pre-rendered text string useful when a model is the next hop. Ignore it if you don’t need it. See Prompt-ready.