Skip to content
Email SDK
Esc
↑↓navigate↵open⌘Jpreview
On this page

Nightmail

Send through Nightmail's email API on Amazon SES with native idempotency, scheduling, attachments, and signed inbound webhooks.

Capabilities

Repeated headers Idempotency Scheduling Personalized
No native Yes expanded

These values come from the adapter’s exported capabilities declaration. The field support matrix covers normalized message fields.

The Nightmail adapter calls POST /v1/emails/send with plain fetch and Bearer authentication. Nightmail is an email API on Amazon SES that sends, receives, and replies on your own domains. A 202 response means Nightmail queued the message, not that it was delivered.

Nightmail logo
Nightmail@opencoredev/email-sdk/nightmail
Provider docs

Configure

Verify a sending domain in Nightmail, then create an API key. A Send only key restricted to that domain is enough to send.

PropType
apiKeystring

Nightmail API key.

Typestring
baseUrl?string

Override the API base URL. Self-hosted installations pass their own public URL.

Typestring
Default"https://nightmail.dev"
headers?Record<string, string>

Extra request headers sent with every call.

TypeRecord<string, string>
fetch?typeof fetch

Custom fetch implementation for tests or special runtimes.

Typetypeof fetch

Send

The adapter maps cc, bcc, replyTo, custom headers, attachments, and sendAt. The sender’s display name goes out as Nightmail’s fromName; sendAt goes out as scheduledAt in UTC.

Nightmail’s send takes attachment IDs, so the adapter uploads each attachment to POST /v1/attachments first, one request per file, and sends the returned IDs. An attachment is uploaded as inline when it has a contentId or disposition: "inline". If an upload fails, the email is never submitted and the error reports delivery: "not_sent".

Nightmail has no tags or metadata fields, so a message with tags or metadata throws an EmailValidationError before any request is made.

Idempotency

The client’s idempotency key goes out as the Idempotency-Key header. Nightmail accepts keys of 1 to 200 printable ASCII characters; any other key, such as a long per-recipient key from sendPersonalized, is hashed to a SHA-256 digest, so the same client key always maps to the same Nightmail key.

Each attachment upload gets its own key derived from the send’s key. A retried send therefore replays the same uploads, gets the same attachment IDs, and sends the same body, so Nightmail replays the first result instead of answering 409 IDEMPOTENCY_CONFLICT.

Failed sends

Nightmail checks validation, suppression, balance, sending limits, and content screening before it queues a message, so a 4xx response, including a 429 for a rate, ramp, or built-in domain limit, reports delivery: "not_sent". A 408, a 409 (a request with the same key still in flight, or a key reused with a different body), and 5xx responses report delivery: "unknown". The error message includes Nightmail’s error.code and requestId, and retryable follows the retryable flag in Nightmail’s error body.

Receive

Nightmail signs every webhook delivery in the Standard Webhooks format (webhook-id, webhook-timestamp, webhook-signature). Create the inbound webhook with format: "inbound", whose body is an email.received event carrying the parsed message and, when the whole body fits Nightmail’s 512 KiB webhook limit, the original MIME.

The parser reads the inlined MIME when it is present. A larger message falls back to Nightmail’s parsed text, HTML, headers, and attachment metadata. Nightmail caps text and HTML at 256 KiB together and drops them and the headers when the event still does not fit, so check email.truncated before treating the message as complete; email.messageUrl is Nightmail’s API URL for the full message. The attachments carry Nightmail’s downloadUrl in url, which needs a key that can read the message, such as an inbound key scoped to the receiving address. Nightmail’s default thin nightmail format carries only IDs, so the parser rejects it. See Receive email for the full flow.

Verify from the CLI

The live check reads GET /v1/me, which describes the calling key. Nothing is sent. It probes hosted Nightmail only; a self-hosted baseUrl works for sends but not for doctor --live or bun run live:nightmail.

Drop --dry-run to send for real. The CLI also reads NIGHTMAIL_BASE_URL from the environment.

Frequently asked questions

Does Email SDK support Nightmail?

Yes. Email SDK ships a Nightmail adapter imported from @opencoredev/email-sdk/nightmail. You keep your Nightmail account and credentials; the SDK adds message validation, typed errors, and no-network test adapters around the same send() call used for every other provider.

Which message fields does the Nightmail adapter support?

Nightmail supports CC recipients, BCC recipients, Reply-To address, Custom headers, Attachments, and Scheduled sending (sendAt). It does not support Tags and Metadata; Email SDK rejects a message that uses those fields before any request is made.

Can Nightmail schedule email for later with Email SDK?

Yes. Set sendAt on the message and the Nightmail adapter passes the scheduled time to the provider.

Does the Nightmail adapter support idempotent sends?

Yes. The Nightmail adapter passes an idempotency key to the provider, so Nightmail deduplicates repeated sends on its side.

Last updated on