# accounts.listEvents

Query account delivery event log.

Returns paginated delivery events and attempt history across every domain owned by an account, with filtering by time range, outcome, source, mailbox, or the prepared email that sent it.

```ts
openemail.accounts.listEvents(
  accountId: string,
  options?: AccountsListEventsOptions,
): PagePromise<AccountEvents, AccountTrafficEvent>
```

It calls `GET /accounts/{accountId}/events`: [Query account delivery event log](/docs/api/accounts/get_AccountEvents) in the API reference.

## Example

```ts
for await (const accountTrafficEvent of openemail.accounts.listEvents(accountId)) {
  // every item of every page (await the call instead for one page)
}
```

## Arguments

| Argument | Type | Description |
| --- | --- | --- |
| `accountId` | `string` | Account ULID identifier. The path's `{accountId}`. |

## Options

The last argument, `options`, a `AccountsListEventsOptions`, 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', 'relayed', 'filtered') |
| `source` | `(typeof ACCOUNTS_LIST_EVENTS_SOURCES)[number]` | query `source` | Filter by traffic source ('inbound', 'outbound', 'relay', 'append', 'pickup') |
| `kind` | `('mail' \| 'all')` | query `kind` | 'mail' shows only rows where a message moved; 'all' (the default) also includes the rows where the platform describes itself — IMAP uploads, Sent copies, report ingestion, event-webhook batches and the per-RCPT gate. See the per-domain log for the full note. |
| `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, [`AccountEvents`](/docs/sdks/typescript/types/account-events). Iterated with `for await`, it is every [`AccountTrafficEvent`](/docs/sdks/typescript/types/account-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` | Account 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: [`AccountEvents`](/docs/sdks/typescript/types/account-events), [`AccountTrafficEvent`](/docs/sdks/typescript/types/account-traffic-event).
