NightmailDocs
Docs

Check email sendability without sending

post/v1/emails/check

Read-only 0–100 advisory score, not an inbox-placement probability or admission decision. Supply one draft (HTML or text), outbound email ID, or campaign ID. Uses visible retained content, cached From-domain facts, and workspace reputation for unrestricted readers. No DNS/asset fetches or paid screen. Scores use current evidence, not a historical delivery verdict. HTML has the preview lint’s 256 KiB UTF-8 and tree budgets. Marketing drafts are checked as supplied; Nightmail adds the unsubscribe headers, the link and the workspace’s postal address to campaigns and to marketing mail it sent, so those are checked as sent. Each finding’s fix is one plain sentence and fixIn says where it is made. MIME bytes are estimated.

Needs Sent mail: read for the sender domain.

Example

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

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

const result = await checkEmail({
  client,
  body: {
    "from": "sender@example.com",
    "subject": "Hello from Nightmail",
    "stream": "transactional"
  },
  throwOnError: true,
});

console.log(result.data);
curl --request POST \
  --url 'https://nightmail.dev/v1/emails/check' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "from": "sender@example.com",
  "subject": "Hello from Nightmail",
  "stream": "transactional"
}'

Request body

EmailCheckInput

One of 3:

Variant 1: SendabilityDraftfrom, fromName, to, subject, html, text, stream, headers, attachments
fromrequiredstring
fromNamestring
tostring or string[]
subjectrequiredstring
htmlstring
textstring
streamrequiredstring
headersobject

Header name to value. May include observed or planned transport headers; not trusted as authentication evidence.

attachmentsobject[]

Optional metadata only: decoded byte size, never attachment bytes or fetch URLs.

attachments[].filenamerequiredstring
attachments[].contentTyperequiredstring
attachments[].sizerequiredinteger
Variant 2emailId
emailIdrequiredstring
Variant 3campaignId
campaignIdrequiredstring

Responses

200Success
EmailCheckResult
scorerequiredinteger
graderequiredstring
domainIdrequiredstring or null

The From domain’s ID (getDomain) when it is one of this workspace’s domains: where a finding with fixIn domain is fixed.

categoriesrequiredobject[]
categories[].idrequiredstring
categories[].scorerequiredinteger
categories[].weightrequiredinteger
findingsrequiredobject[]
findings[].ruleIdrequiredstring
findings[].categoryrequiredstring
findings[].severityrequiredstring
findings[].titlerequiredstring
findings[].detailrequiredstring
findings[].fixrequiredstring

What to do, in one short sentence of everyday words. The title and the detail name the header, record or standard.

findings[].fixInrequiredstring

Where the fix is made: the From domain’s DNS records and setup (domain), the workspace’s settings (workspace), how much and to whom you send (sending), or the message itself (message).

findings[].evidenceobject
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.