# List webhook events

> Source: https://truto.one/docs/api-reference/admin/webhook-events/list/

`GET /webhook-event`

Resource: **Webhook events**

Lists the events Truto sent, is sending or failed to send to the webhooks of one environment, newest first, each with the body that was or will be sent. Use it to see what your endpoint missed, or to export events: page with `next_cursor` until it is `null`.

An event is kept for 30 days after it is delivered or fails. An environment keeps about its newest 100,000 delivered events, up to 1 GB of their payloads, and about its newest 25,000 failed events. Past those, the oldest go first, so a busy environment keeps less than 30 days of delivered events. A delivered event is kept even though your endpoint accepted it, because a 2xx does not prove you processed it. Deactivating or deleting a webhook deletes its events.

Not listed:
- a delivered `sync_job_run:record` event (a failed one is listed and
  can be resent);

- events a sync job run sends to its own webhook (the run's
  `webhook_id`), which the run delivers itself, and file pages;

- an event sent while a sync job run waits on it that your endpoint
  answers with 400, 404 or 413;

- test events from `POST /webhook/test`;
- events delivered before this endpoint existed.

A page holds at most `limit` events and about 4 MB of payloads, so a page of large events can hold fewer.

## Query parameters

- **`environment_id`** _(string)_
  The environment whose events to list. Required when you call with a dashboard session; an API token uses its own environment.
- **`webhook_id`** _(string)_
  Only events for this webhook.
- **`integrated_account_id`** _(string)_
  Only events about this integrated account.
- **`event`** _(string)_
  Only events of this type.
- **`status`** _(string)_
  Only events in this state.
  Allowed: `pending`, `failed`, `delivered`
- **`created_at`** _(object)_
  A window on when the events were created, `created_at[gt]` and `created_at[lt]`.
- **`limit`** _(integer)_
  The most events to return.
- **`next_cursor`** _(string)_
  The `next_cursor` from the previous page.

## Response body

- **`result`** _(array<object>)_
  - **`id`** _(string)_
    The event's ID, the same `id` your endpoint receives in the payload. A resend keeps it, so you can deduplicate on it.
  - **`webhook_id`** _(string)_
    The webhook the event is for.
  - **`event`** _(string)_
    The event type.
  - **`status`** _(string)_
    `pending`: waiting for its first attempt, a retry, or a resend. `failed`: it was not delivered: every attempt failed, its five-minute retry window ran out, or your endpoint answered 400, 404 or 413, which are not retried. You can resend it. `delivered`: your endpoint answered with a 2xx.
    Allowed: `pending`, `failed`, `delivered`
  - **`integrated_account_id`** _(string)_
    The integrated account the event is about, when it is about one. Null for events stored before this field existed.
  - **`attempts`** _(integer)_
    Delivery attempts since the event was created or last resent.
  - **`last_error`** _(string)_
    Why the last attempt failed. Null once the event is delivered.
  - **`endpoint_status`** _(integer)_
    The HTTP status your endpoint answered on the last attempt. Null when it did not answer (a timeout or a connection error) or no attempt has been made.
  - **`created_at`** _(string)_
    When Truto stored the event, to the second.
  - **`delivered_at`** _(string)_
    When your endpoint accepted the event.
  - **`failed_at`** _(string)_
    When the event was marked failed.
  - **`payload`** _(object)_
    The event as it was or will be sent: the JSON body your endpoint receives. An event that carries a file, such as a sync job run's file page, reaches your endpoint as `multipart/form-data` with these values as form fields. `X-Truto-Signature` signs the body with the webhook's secret at the time it is sent.
- **`next_cursor`** _(string)_
  Pass this as `next_cursor` for the next page; `null` on the last page.
- **`limit`** _(number)_

## Errors

| Status | Description |
| :----- | :---------- |
| `400` | An invalid or unknown filter, an invalid `next_cursor`, or no `environment_id` from a dashboard session. The `message` says which. |
| `403` | The caller cannot reach `environment_id`. |
| `503` | The environment's events are not ready to list yet: Truto prepares them once, usually within a minute of the first request, or its event storage is full. Try again after `Retry-After` seconds. |

## Code examples

### curl

```bash
curl -X GET 'https://api.truto.one/webhook-event' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json'
```

### JavaScript

```javascript
const response = await fetch('https://api.truto.one/webhook-event', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/webhook-event"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}

response = requests.get(url, headers=headers, params=params)
print(response.json())
```
