NightmailDocs
Docs

List sent and received mail together

get/v1/logs

Sent and received mail in one list, newest first, with an opaque cursor bound to the filters. Sent mail is what listEmails returns (keys restricted to domains see their own domains); received mail is what listInboundMessages returns for the same credential: administrators see every received message, including unrouted mail, with delivery details; dashboard members see mail on receiving addresses; other credentials get sent mail only. kind, campaignId and a sent-mail status filter sent mail and leave received mail out; status=received or status=spam filter received mail and leave sent mail out. 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 { listLogs } from '@nightmail/sdk';

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

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

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

Parameters

cursorquery · string
limitquery · integer
directionquery · string
searchquery · string

At least 3 characters: a shorter term is refused with 422 VALIDATION_FAILED. Sent mail: a literal, case-insensitive substring of the sender, recipients, subject or IDs. Received mail: a full-text match on sender, recipients, subject and body.

statusquery · string

A sent-mail status lists sent mail only. received lists received mail that is not flagged as spam; spam lists received mail flagged as spam (spam is visible to administrators only, so dashboard members get none). Either leaves sent mail out, and is refused (403) to credentials that cannot read received mail, like direction=received.

kindquery · string

Sent mail only; received mail is left out when set.

campaignIdquery · string

Sent mail only; received mail is left out when set.

regionquery · string
fromquery · string

Mail created (sent) or received at or after this instant.

toquery · string

Mail created (sent) or received before this instant.

countsquery · string

true adds counts: how many emails match each status and kind for these filters between from and to (all retained mail without them), whatever the cursor and limit. Counts that take longer than 2 seconds are refused with 422 READ_TOO_LARGE: narrow from and to.

Responses

200Success
LogPage
datarequiredobject[]
data[].idrequiredstring

Email ID for sent mail (getEmail); message ID for received mail (getInboundMessage).

data[].directionrequiredstring
data[].untrustedContentrequiredboolean

Received mail and sent mailbox replies can contain external sender content.

data[].atrequiredstring

When the email was created (sent) or received.

data[].statusrequiredstring

Sent: the email status, or scheduled for a send waiting for its time (getEmail reads it as queued with scheduled true). Received: received, or spam when flagged (spam is shown to administrators only).

data[].fromrequiredobject
data[].torequiredstring[]

Sent: the To recipients (at most 20). Received: the addresses in the To header (at most 20).

data[].toCountrequiredinteger

Total To recipients (may exceed to.length when shortened).

data[].subjectrequiredstring
data[].streamrequiredstring or null

Sent mail only.

data[].campaignIdrequiredstring or null
data[].scheduledAtrequiredstring or null

Sent mail that is scheduled: when it goes (UTC). Null for received mail.

data[].simulatedrequiredboolean

Sent through the SES mailbox simulator. Always false for received mail.

data[].attachmentCountrequiredinteger or null

Received mail only.

data[].threadIdrequiredstring or null

The conversation (getInboundThread): every received email's, and a sent email's when it is a reply from a receiving address or inbox, or its In-Reply-To named a stored message its sender could read. Null when the caller can read none of the conversation's received or stored messages, and for credentials that cannot read received mail.

data[].threadCountrequiredinteger or null

Messages in that conversation the caller can read, this one included; null without threadId.

data[].addressesrequiredarray or null

Received mail only: the receiving addresses it was delivered to that the caller can read. Empty for unrouted mail.

data[].regionrequiredstring or null

Null for received mail unless the caller is an administrator.

data[].envelopeTorequiredarray or null

Received mail, administrators only: the SMTP envelope recipients (at most 20).

data[].envelopeToCountrequiredinteger or null

Received mail, administrators only: total SMTP envelope recipients.

nextCursorrequiredstring or null
receivedrequiredboolean

Whether received mail is included: false for direction=sent, with a sent-only filter, or when the credential cannot read inbound mail.

countsobject

With counts=true only.

counts.statusrequiredobject

Emails per status (sent statuses, received and spam) between from and to, with every filter but status. A status with none is left out.

counts.kindrequiredobject

Sent emails per kind between from and to, with every filter but kind.

counts.cappedrequiredobject

Always false: the counts are exact. Kept for compatibility from when each direction counted at most its 50,000 newest emails.

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.