> For the complete documentation index, see [llms.txt](https://docs-lunar.earthly.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-lunar.earthly.dev/sql-api/views/webhooks.md).

# event\_subscriptions, event\_deliveries

Schema reference for the outbound webhook SQL views. Subscriptions, every delivery the Hub made or deliberately skipped, and every HTTP attempt.

```
event_subscriptions
event_deliveries
event_delivery_attempts
```

These views report on [outbound webhooks](https://docs-lunar.earthly.dev/configuration/hub-configuration/webhooks.md): which endpoints are subscribed to which events, every event the Hub delivered or deliberately did not, and every HTTP attempt. They leave out what is not safe to show: a subscription URL, which for many receivers is a credential, appears only as its scheme and host; signing secrets and the receivers' answers do not appear at all. `lunar webhooks ls` and `lunar webhooks delivery <id>` show those to [`hub.operate`](https://docs-lunar.earthly.dev/docs/authorization.md#hub-operate) holders.

## `event_subscriptions`

One row per subscription, deleted ones included, so their deliveries keep a subscription to point at.

| Column                 | Type          | Description                                                                          |
| ---------------------- | ------------- | ------------------------------------------------------------------------------------ |
| `id`                   | `UUID`        | The subscription, as `lunar webhooks` names it                                       |
| `url_host`             | `TEXT`        | The endpoint's scheme and host, e.g. `https://hooks.example.com`                     |
| `events`               | `TEXT[]`      | The events it receives. Always includes `ping`                                       |
| `filter`               | `TEXT`        | Its SQL/JSON path filter, in normalized form; `NULL` when it receives every event    |
| `description`          | `TEXT`        | What it is for                                                                       |
| `created_by`           | `TEXT`        | The login of the person who created it, or `service`                                 |
| `created_at`           | `TIMESTAMPTZ` | When it was created                                                                  |
| `consecutive_failures` | `INT`         | Failed deliveries since the last successful one                                      |
| `paused_at`            | `TIMESTAMPTZ` | When it was paused after consecutive failed deliveries; `NULL` when it is not paused |
| `deleted_at`           | `TIMESTAMPTZ` | When it was unsubscribed; `NULL` while it is live                                    |
| `state`                | `TEXT`        | `active`, `paused` or `deleted`                                                      |

## `event_deliveries`

One row per event per subscription.

| Column             | Type          | Description                                                                                                                                                                       |
| ------------------ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`               | `UUID`        | The delivery, as sent in `X-Lunar-Delivery`                                                                                                                                       |
| `subscription_id`  | `UUID`        | The subscription it is for                                                                                                                                                        |
| `event`            | `TEXT`        | The event name                                                                                                                                                                    |
| `payload`          | `JSONB`       | The envelope sent, or that would have been sent                                                                                                                                   |
| `status`           | `TEXT`        | `queued` (sending or retrying), `delivered`, `failed` (every attempt failed), `filtered` (the subscription's filter rejected the event) or `paused` (the subscription was paused) |
| `attempts`         | `INT`         | HTTP attempts made. `filtered` and `paused` deliveries have none                                                                                                                  |
| `last_http_status` | `INT`         | The status of the last attempt's answer; `NULL` when there was none                                                                                                               |
| `last_error`       | `TEXT`        | Why the last attempt failed, as the Hub saw it, never quoting the URL; `NULL` after a success                                                                                     |
| `created_at`       | `TIMESTAMPTZ` | When the event was emitted                                                                                                                                                        |
| `completed_at`     | `TIMESTAMPTZ` | When the delivery reached its final status; `NULL` while `queued`                                                                                                                 |

## `event_delivery_attempts`

One row per HTTP attempt.

| Column        | Type          | Description                                                                                     |
| ------------- | ------------- | ----------------------------------------------------------------------------------------------- |
| `delivery_id` | `UUID`        | The delivery                                                                                    |
| `attempt`     | `INT`         | 1 for the first attempt. A redelivery continues the count                                       |
| `started_at`  | `TIMESTAMPTZ` | When the attempt started                                                                        |
| `duration_ms` | `INT`         | How long it took                                                                                |
| `http_status` | `INT`         | The status the receiver answered with; `NULL` when no answer arrived                            |
| `error`       | `TEXT`        | Why the attempt failed, e.g. `HTTP 503` or a timeout, never quoting the URL; `NULL` for a `2xx` |

## Usage examples

Deliveries that did not go out in the last day, and why:

```sql
SELECT d.created_at, s.url_host, d.event, d.status, d.last_http_status, d.last_error
FROM event_deliveries d
JOIN event_subscriptions s ON s.id = d.subscription_id
WHERE d.status <> 'delivered'
  AND d.created_at > now() - interval '1 day'
ORDER BY d.created_at DESC;
```

Endpoints that are failing:

```sql
SELECT id, url_host, state, consecutive_failures
FROM event_subscriptions
WHERE state <> 'deleted'
  AND consecutive_failures > 0
ORDER BY consecutive_failures DESC;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs-lunar.earthly.dev/sql-api/views/webhooks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
