NightmailDocs
Docs

List emails

get/v1/emails

Sent emails, newest first. from and to (or since and until) are ISO 8601 times that bound when an email was created, not addresses: filter by sender or recipient address with search. Pages are also bounded by response size and may return fewer than limit emails; follow nextCursor while non-null. Each statement stops after 5 seconds: a request that needs longer is refused with 422 READ_TOO_LARGE. Narrow the dates or filters.

Needs Sent mail: read for the sender domain.

Example

import { createClient } from '@nightmail/sdk/client';
import { listEmails } from '@nightmail/sdk';

const client = createClient({
  baseUrl: 'https://nightmail.dev',
  auth: scheme => scheme.scheme === 'bearer'
    ? process.env.NIGHTMAIL_API_KEY
    : undefined,
});

const result = await listEmails({
  client,
  throwOnError: true,
});

console.log(result.data);
curl --request GET \
  --url 'https://nightmail.dev/v1/emails' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY"

Parameters

cursorquery · string
limitquery · integer
campaignIdquery · string
statusquery · string

scheduled lists sends waiting for their time; queued includes them.

regionquery · string
kindquery · string
searchquery · string

Literal case-insensitive substring of sender, To/Cc/Bcc, subject or email/campaign/provider ID, at least 3 characters: a shorter term is refused with 422 VALIDATION_FAILED. This is how to filter by sender or recipient address.

fromquery · string

The start of the time range: emails created at or after this ISO 8601 date-time with Z or an offset, such as 2026-11-01T00:00:00Z. A time, not a sender: filter by sender address with search. since is the same filter by a clearer name; send one of them.

toquery · string

The end of the time range: emails created before this ISO 8601 date-time with Z or an offset. A time, not a recipient: filter by recipient address with search. until is the same filter by a clearer name; send one of them.

sincequery · string

The start of the time range, the same filter as from: emails created at or after this ISO 8601 date-time. Send since or from, not both.

untilquery · string

The end of the time range, the same filter as to: emails created before this ISO 8601 date-time. Send until or to, not both.

Responses

200Success
datarequiredobject[]
data[].untrustedContentrequiredboolean

True for replies and older non-campaign mail of unknown origin: the subject or body may contain received content.

data[].idrequiredstring
data[].regionrequiredstring
data[].campaignIdrequiredstring or null
data[].fromrequiredstring
data[].fromNamerequiredstring or null
data[].kindrequiredstring
data[].torequiredstring[]
data[].ccrequiredstring[]
data[].bccrequiredstring[]
data[].subjectrequiredstring
data[].statusrequiredstring

A scheduled email is queued, with scheduled true, until it is sent at scheduledAt.

data[].providerIdrequiredstring or null
data[].simulatedrequiredboolean
data[].attemptStartedAtrequiredstring or null
data[].errorCoderequiredstring or null
data[].suppressionReasonstring or null

Reason recorded when this send was suppressed. For a multi-recipient send blocked locally, this is the first blocked recipient in To, Cc, Bcc order.

data[].scheduledrequiredboolean

True while a scheduled send waits for scheduledAt: it has not started sending, and cancelEmail or rescheduleEmail still apply. At that time it is admitted like a send made then (limits and balance included) and follows the usual lifecycle, or is rejected with the refusal’s code.

data[].scheduledAtrequiredstring or null

When a scheduled send goes (UTC). Also set while queued mail waits to be retried.

data[].createdAtrequiredstring

When the email was submitted; a scheduled send’s moves to the moment it was released at its time.

data[].updatedAtrequiredstring
nextCursorrequiredstring or null
400, 401, 403, 404, 409, 413, 422, 429, 500, 503Request failed; use error.code and requestId to diagnose.
ApiError
errorrequiredobject
error.coderequiredstring
error.messagerequiredstring
error.requestIdrequiredstring
error.fieldstring
error.retryablerequiredboolean
error.resetAtstring

Next capacity change for a Hosted rolling send limit.

error.detailsobject[]

Every problem found, when there is more than one part, such as rule diagnostics with rule, line, column, message and hint, or a measurement, such as CONTENT_TOO_LARGE_TO_SCREEN with screenedBytes and limitBytes (and index in a batch).

error.requiredobject

On a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.