Skip to Content

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.

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

It calls GET /accounts/{accountId}/events: Query account delivery event log in the API reference.

Example

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

Arguments

ArgumentTypeDescription
accountIdstringAccount ULID identifier. The path's {accountId}.

Options

The last argument, options, a AccountsListEventsOptions, takes:

OptionTypeSent asDescription
range('1h' | '6h' | '24h' | '7d' | '30d')query rangeTime window range ('1h', '6h', '24h', '7d', '30d')
outcome(typeof ACCOUNTS_LIST_EVENTS_OUTCOMES)[number]query outcomeFilter by delivery outcome ('delivered', 'bounced', 'deferred', 'relayed', 'filtered')
source(typeof ACCOUNTS_LIST_EVENTS_SOURCES)[number]query sourceFilter 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.
deliveryIdstringquery deliveryIdFilter by exact delivery ID
mailboxIdstringquery mailboxIdFilter by mailbox ULID identifier
envelopeFromstringquery envelopeFromFilter by envelope sender email address
detailstringquery detailFilter by the row's detail marker — e.g. 'junk' for messages the platform filed into Junk, or a failure reason like 'sender_blocked'.
templatestringquery templateFilter 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.
limitnumberquery limitMaximum events per page
cursorstringquery cursorPagination cursor

Every call also takes signal, timeout, retry and headers, which say how that one call is sent (call options).

Answer

It is a listing, a PagePromise. Awaited, it is one page as the API answers it, AccountEvents. Iterated with for await, it is every AccountTrafficEvent of every page, each page fetched as the loop reaches it.

Errors

StatusWhat it means
400validation_failed or invalid_cursor
401unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a WWW-Authenticate: Bearer challenge
404Account not found or not accessible to this principal
502analytics_query_failed
503analytics_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: its status, and its code, the API's error. Decide on the code: one status covers several.

Types

ACCOUNTS_LIST_EVENTS_OUTCOMES

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

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, AccountTrafficEvent.