NightmailDocs
Docs

List or wait for inbox messages

get/v1/inboxes/{id}/messages

Oldest first, in commit order. Without after, the page starts at the first message, so mail that arrived before the call is included. With wait, the call holds until a matching message arrives or the time runs out, and answers as soon as the message is stored; pass the returned cursor as after on the next call. Pages are also bounded by response size and may return fewer than limit messages while hasMore is true; to returns at most 20 addresses with the total in toCount. Junk, unverified and held mail never wake a waiter: list them with include=held. Each waited second counts as one request against the key’s per-minute budget. Filtered queries: Each statement stops after 5 seconds: a request that needs longer is refused with 422 READ_TOO_LARGE. Narrow the dates or filters.

Needs Received mail: read for the address or inbox.

Example

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

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

const result = await listInboxMessages({
  client,
  path: {
    "id": "resource_123"
  },
  throwOnError: true,
});

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

Parameters

idrequiredpath · string
afterquery · string

cursor from a previous response. Omit to start at the first message.

waitquery · integer or null

Seconds to wait for a message when none is available yet (0–30). The call returns as soon as one arrives.

limitquery · integer
folderquery · string or string

Select one folder. In a folder, after and cursor are UIDs, not delivery cursors.

flaggedquery · string
fromquery · string

Only messages from this sender address.

subjectContainsquery · string

Only messages whose subject contains this text, ignoring case.

unreadquery · string
includequery · string

Also list junk, unverified and held mail. Ignored with wait.

extractquery · string

Extract one-time codes, links or both into each message’s extract field.

Responses

200Success
InboxMessagePage
datarequiredobject[]
data[].idrequiredstring
data[].threadIdrequiredstring
data[].cursorrequiredstring

Pass as after to continue after this message.

data[].fromrequiredobject

The claimed sender. Check auth before trusting it.

data[].torequiredobject[]

Addresses in the To header (at most 20 on list pages, up to 100 on getInboxMessage).

data[].toCountrequiredinteger

Total addresses in the To header (may exceed to.length when shortened).

data[].subjectrequiredstring
data[].snippetrequiredstring
data[].receivedAtrequiredstring

When the sending server handed it over (SES received it).

data[].storedAtrequiredstring

When the write that stored it in Nightmail committed, on the clock servedAt uses.

data[].processingMsrequiredinteger or null

Milliseconds from the receipt reaching Nightmail to storedAt: fetching, parsing, routing and storing the message. Null for mail that came another way (simulated, sent, copied).

data[].readrequiredboolean
data[].flagsrequiredstring[]
data[].labelsrequiredstring[]
data[].foldersrequiredobject[]
data[].additionalFoldersrequiredobject[]
data[].modseqrequiredstring
data[].uidrequirednumber or null
data[].uidValidityrequirednumber or null
data[].junkrequiredboolean

SES judged this message spam.

data[].heldrequiredstring or null

null when delivered; quota or expired when stored but held.

data[].attachmentCountrequirednumber
data[].authrequiredobject

SES verdicts for the sender: PASS, FAIL, GRAY or NONE.

data[].simulatedrequiredboolean

Created by POST /v1/inboxes/{id}/simulate, not received over SMTP.

data[].hiddenContentrequiredboolean

Best-effort detection of hidden, styled or invisible content. False does not guarantee visibility.

data[].extractrequiredobject

Filled when requested with extract.

cursorrequiredstring

Pass as after on the next call; unchanged when data is empty.

hasMorerequiredboolean
servedAtrequiredstring

When this page was read, on the clock storedAt uses: servedAt minus a message’s storedAt is how long it took to reach you after it was stored.

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.