Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.lettr.com/llms.txt

Use this file to discover all available pages before exploring further.

Webhooks deliver real-time notifications when emails are delivered, opened, clicked, bounced, or marked as spam. The client.webhooks resource manages your endpoints. For the event payload format and signature verification, see Webhooks.
import lettr

client = lettr.Lettr("lttr_your_api_key")

List Webhooks

webhooks = client.webhooks.list()
for webhook in webhooks:
    print(f"{webhook.name}: {webhook.url} (enabled: {webhook.enabled})")
    print(webhook.auth_type, webhook.last_status)

    # event_types is None when subscribed to all events
    if webhook.event_types is None:
        print("all events")
    else:
        print(webhook.event_types)  # ["message.delivery", "engagement.click", ...]

API Reference

GET /webhooks

Create a Webhook

webhook = client.webhooks.create(
    name="Production events",
    url="https://example.com/webhooks/lettr",
    auth_type="none",
    events_mode="selected",
    events=["message.delivery", "message.bounce", "engagement.click"],
)
Use events_mode="all" to receive every event type (no events needed), or events_mode="selected" with an explicit events list. For authenticated endpoints:
webhook = client.webhooks.create(
    name="Secure Webhook",
    url="https://example.com/webhooks/lettr",
    auth_type="basic",
    events_mode="all",
    auth_username="user",
    auth_password="secret",
)

API Reference

POST /webhooks

Get a Webhook

webhook = client.webhooks.get("webhook-abc123")
print(webhook.last_successful_at, webhook.last_failure_at)

API Reference

GET /webhooks/

Update a Webhook

Pass only the fields you want to change:
client.webhooks.update(
    "webhook-abc123",
    name="Renamed Webhook",
    active=False,
)

API Reference

PATCH /webhooks/

Delete a Webhook

client.webhooks.delete("webhook-abc123")

API Reference

DELETE /webhooks/

What’s Next

Webhook Events

Event types and payload format

Webhook Authorization

Verify webhook authenticity