List or wait for inbox messages
/v1/inboxes/{id}/messagesOldest 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 · stringafterquery · stringcursor from a previous response. Omit to start at the first message.
waitquery · integer or nullSeconds to wait for a message when none is available yet (0–30). The call returns as soon as one arrives.
limitquery · integerfolderquery · string or stringSelect one folder. In a folder, after and cursor are UIDs, not delivery cursors.
flaggedquery · stringfromquery · stringOnly messages from this sender address.
subjectContainsquery · stringOnly messages whose subject contains this text, ignoring case.
unreadquery · stringincludequery · stringAlso list junk, unverified and held mail. Ignored with wait.
extractquery · stringExtract one-time codes, links or both into each message’s extract field.
Responses
200Success
InboxMessagePagedatarequiredobject[]data[].idrequiredstringdata[].threadIdrequiredstringdata[].cursorrequiredstringPass as after to continue after this message.
data[].fromrequiredobjectThe 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[].toCountrequiredintegerTotal addresses in the To header (may exceed to.length when shortened).
data[].subjectrequiredstringdata[].snippetrequiredstringdata[].receivedAtrequiredstringWhen the sending server handed it over (SES received it).
data[].storedAtrequiredstringWhen the write that stored it in Nightmail committed, on the clock servedAt uses.
data[].processingMsrequiredinteger or nullMilliseconds 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[].readrequiredbooleandata[].flagsrequiredstring[]data[].labelsrequiredstring[]data[].foldersrequiredobject[]data[].additionalFoldersrequiredobject[]data[].modseqrequiredstringdata[].uidrequirednumber or nulldata[].uidValidityrequirednumber or nulldata[].junkrequiredbooleanSES judged this message spam.
data[].heldrequiredstring or nullnull when delivered; quota or expired when stored but held.
data[].attachmentCountrequirednumberdata[].authrequiredobjectSES verdicts for the sender: PASS, FAIL, GRAY or NONE.
data[].simulatedrequiredbooleanCreated by POST /v1/inboxes/{id}/simulate, not received over SMTP.
data[].hiddenContentrequiredbooleanBest-effort detection of hidden, styled or invisible content. False does not guarantee visibility.
data[].extractrequiredobjectFilled when requested with extract.
cursorrequiredstringPass as after on the next call; unchanged when data is empty.
hasMorerequiredbooleanservedAtrequiredstringWhen 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.
ApiErrorerrorrequiredobjecterror.coderequiredstringerror.messagerequiredstringerror.requestIdrequiredstringerror.fieldstringerror.retryablerequiredbooleanerror.resetAtstringNext 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.requiredobjectOn a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.