> ## 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.

# Managing Webhooks

> List, create, update, and delete webhook endpoints with the Lettr Rust SDK to receive real-time email event notifications.

Webhooks deliver real-time notifications when emails are delivered, opened, clicked, bounced, or marked as spam. The `client.webhooks` service manages your endpoints.

For the event payload format and signature verification, see [Webhooks](https://docs.lettr.com/learn/webhooks/introduction.md).

```rust theme={null}
use lettr::Lettr;
use lettr::webhooks::{CreateWebhookOptions, UpdateWebhookOptions, WebhookAuthType, WebhookEventsMode};

let client = Lettr::new("your-api-key");
```

## List Webhooks

```rust theme={null}
let webhooks = client.webhooks.list().await?;
for webhook in &webhooks {
    println!("{}: {} (enabled: {})", webhook.id, webhook.url, webhook.enabled);
}
```

> [card] [API Reference](https://docs.lettr.com/api-reference/webhooks/list-webhooks.md)
>
> GET /webhooks

## Create a Webhook

```rust theme={null}
let options = CreateWebhookOptions::new(
    "Order Notifications",
    "https://example.com/webhook",
    WebhookAuthType::Basic,
    WebhookEventsMode::Selected,
)
.with_events(vec!["message.delivery".into(), "message.bounce".into()])
.with_basic_auth("user", "secret");

let webhook = client.webhooks.create(options).await?;
println!("Created webhook: {}", webhook.id);
```

Use `WebhookEventsMode::All` to receive every event, or `WebhookEventsMode::Selected` with `.with_events(...)`. `WebhookAuthType` is `None`, `Basic`, or `Oauth2`.

> [card] [API Reference](https://docs.lettr.com/api-reference/webhooks/create-webhook.md)
>
> POST /webhooks

## Get a Webhook

```rust theme={null}
let webhook = client.webhooks.get(&webhook_id).await?;
```

> [card] [API Reference](https://docs.lettr.com/api-reference/webhooks/get-webhook.md)
>
> GET /webhooks/{webhook}

## Update a Webhook

```rust theme={null}
let options = UpdateWebhookOptions::new()
    .with_name("Updated Webhook")
    .with_active(false);
client.webhooks.update(&webhook_id, options).await?;
```

> [card] [API Reference](https://docs.lettr.com/api-reference/webhooks/update-webhook.md)
>
> PATCH /webhooks/{webhook}

## Delete a Webhook

```rust theme={null}
client.webhooks.delete(&webhook_id).await?;
```

> [card] [API Reference](https://docs.lettr.com/api-reference/webhooks/delete-webhook.md)
>
> DELETE /webhooks/{webhook}

## What's Next

> [card] [Webhook Events](https://docs.lettr.com/learn/webhooks/introduction.md)
>
> Event types and payload format

> [card] [Webhook Authorization](https://docs.lettr.com/learn/webhooks/authorization.md)
>
> Verify webhook authenticity


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.