# domains.listEvents

Query domain delivery event log.

Returns paginated detailed delivery events and attempt history for a domain with filtering by time range, outcome, source, mailbox, or the prepared email that sent it.

```ts
openemail.domains.listEvents(
  domain: string,
  options?: DomainsListEventsOptions,
): PagePromise<DomainEvents, TrafficEvent>
```

It calls `GET /domains/{domain}/events`: [Query domain delivery event log](/docs/api/domains/get_DomainEvents) in the API reference.

## Example

```ts
for await (const trafficEvent of openemail.domains.listEvents(domain)) {
  // every item of every page (await the call instead for one page)
}
```

## Arguments

| Argument | Type | Description |
| --- | --- | --- |
| `domain` | `string` | Domain name (e.g. 'example.com'). The path's `{domain}`. |

## Options

The last argument, `options`, a `DomainsListEventsOptions`, takes:

| Option | Type | Sent as | Description |
| --- | --- | --- | --- |
| `range` | `('1h' \| '6h' \| '24h' \| '7d' \| '30d')` | query `range` | Time window range ('1h', '6h', '24h', '7d', '30d') |
| `outcome` | `(typeof ACCOUNTS_LIST_EVENTS_OUTCOMES)[number]` | query `outcome` | Filter by delivery outcome ('delivered', 'bounced', 'deferred', 'rejected', 'suppressed', 'dropped') |
| `source` | `(typeof ACCOUNTS_LIST_EVENTS_SOURCES)[number]` | query `source` | Filter by traffic source ('smtp_in', 'submission', 'forward', 'webhook', 'scheduled', 'pop3') |
| `kind` | `('mail' \| 'all')` | query `kind` | 'mail' shows only rows where a message moved — arrived, left, reached a member or a webhook route, was collected from another provider, or its sender was told it failed. 'all' (the default, so no client changes behaviour) adds the rows where the platform describes itself: IMAP uploads, Sent copies, report ingestion, event-webhook batches and the per-RCPT gate. A customer-facing delivery log wants 'mail' — one inbound message writes a gate row AND a delivery row, so 'all' counts it twice. |
| `deliveryId` | `string` | query `deliveryId` | Filter by exact delivery ID |
| `mailboxId` | `string` | query `mailboxId` | Filter by mailbox ULID identifier |
| `envelopeFrom` | `string` | query `envelopeFrom` | Filter by envelope sender email address |
| `detail` | `string` | query `detail` | Filter by the row's detail marker — e.g. 'junk' for messages the platform filed into Junk, or a failure reason like 'sender_blocked'. |
| `template` | `string` | query `template` | Filter to the rows a prepared email (tenant template) wrote, by its slug: the admission of each recipient, every relay attempt after it, and a dead letter if the attempts ran out. Each row names its template and language in `template`. |
| `limit` | `number` | query `limit` | Maximum events per page |
| `cursor` | `string` | query `cursor` | Pagination cursor |

Every call also takes `signal`, `timeout`, `retry` and `headers`, which say how that one call is sent ([call options](/docs/sdks/typescript/calling-methods#call-options)).

## Answer

It is a listing, a [`PagePromise`](/docs/sdks/typescript/listings). Awaited, it is one page as the API answers it, [`DomainEvents`](/docs/sdks/typescript/types/domain-events). Iterated with `for await`, it is every [`TrafficEvent`](/docs/sdks/typescript/types/traffic-event) of every page, each page fetched as the loop reaches it.

## Errors

| Status | What it means |
| --- | --- |
| `400` | validation_failed or invalid_cursor |
| `401` | unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a `WWW-Authenticate: Bearer` challenge |
| `404` | Domain not found or not accessible to this principal |
| `502` | analytics_query_failed |
| `503` | analytics_unavailable. Or temporary_failure: the platform's storage could not answer just now; retry after the Retry-After window. Any operation can answer this. A write that got it may have been applied, so retry it with the same idempotency key where it takes one, or read the state back first (see Transient failures in the API description) |

A failed call rejects with a [`RequestError`](/docs/sdks/typescript/errors): its `status`, and its `code`, the API's `error`. Decide on the code: one status covers several.

## Types

### ACCOUNTS_LIST_EVENTS_OUTCOMES

```ts
const ACCOUNTS_LIST_EVENTS_OUTCOMES = [
  'delivered',
  'duplicate',
  'queued',
  'filtered',
  'rejected',
  'bounced',
  'deferred',
  'relayed',
  'relay_rejected',
  'relay_suppressed',
  'relay_indeterminate',
  'relay_content_lost',
  'webhook_delivered',
  'webhook_route_gone',
  'event_delivered',
  'event_hook_disabled',
  'event_hook_gone',
  'member_skipped',
  'member_failed',
  'fbl_recorded',
  'fbl_content_lost',
  'dmarc_recorded',
  'dmarc_content_lost',
  'dmarc_unreadable',
  'dmarc_unparseable',
  'dmarc_rejected',
  'dead_lettered',
  'internal_error',
  'check_refused',
  'check_accepted',
  'blob_missing',
  'rate_limited',
  'limiter_unavailable',
  'auth_failed',
  'storage_warning',
  'mail_refused',
  'mail_accepted',
] as const
```

Its 37 values; the package exports it: `import { ACCOUNTS_LIST_EVENTS_OUTCOMES } from '@openemail/sdk'`.

### ACCOUNTS_LIST_EVENTS_SOURCES

```ts
const ACCOUNTS_LIST_EVENTS_SOURCES = [
  'inbound',
  'outbound',
  'sent_copy',
  'append',
  'expansion',
  'relay',
  'webhook',
  'pickup',
  'edge',
  'fbl',
  'dmarc',
  'bounce',
  'events',
  'api',
  'check',
  'read',
  'auth',
  'store',
  'platform_mail',
] as const
```

Its 19 values; the package exports it: `import { ACCOUNTS_LIST_EVENTS_SOURCES } from '@openemail/sdk'`.

It names these types of the API, each on a page of its own: [`DomainEvents`](/docs/sdks/typescript/types/domain-events), [`TrafficEvent`](/docs/sdks/typescript/types/traffic-event).
