Every dashboard action is an MCP tool your agent can call.Read the docs
Node.js email API

Send product email from Node.js. Keep every delivery traceable.

Send transactional email and publish lifecycle events from TypeScript and JavaScript with the Send & Retain API.

Use the typed Node.js SDK or the fetch client already in your runtime.

Server quickstart
Node.js

One request, complete trace

Request

POST /api/v1/emails

Authorization: Bearer aem_…

Idempotency-Key: welcome-8f21

{ "to": "[email protected]", "template": "welcome" }

202 Accepted

{ "id": "msg_7ca31", "status": "queued" }

RuntimeServer process
RequestPOST /api/v1/emails
Result202 · queued
Credentials stay server-side

[ 01 / 04 ]Client contract

Add email without building a second backend.

Use the official Node.js client

Install with npm, pnpm, or yarn for typed requests, or call the same HTTP API with fetch.

Send typed payloads

Fully typed request and response shapes, so a malformed payload fails at compile time.

Handle delivery events

Verify the signature over the raw body before any JSON parsing touches it.

[ 02 / 04 ]Server quickstart

Queue one email from Node.js.

Server-side only, idempotent by key, and it returns an ID you can trace.

Reuse the same idempotency key when retrying the same logical message.

send-welcome.mjs
const response = await fetch("https://sendandretain.com/api/v1/emails", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.AEM_KEY}`,
    "Content-Type": "application/json", "Idempotency-Key": `welcome-${user.id}` },
  body: JSON.stringify({ to: user.email, template: "welcome" }),
});
if (!response.ok) throw new Error(await response.text());

Accepted response

{ "id": "msg_7ca31", "status": "queued" }

[ 03 / 04 ]Quickstart

Put the send at the product event boundary.

01

Create one server-side client

Load the API key from server-only configuration and reuse the client across requests.

02

Send after the action succeeds

Queue the receipt, reset, or welcome message after your database transaction completes.

03

Correlate the outcome

Store the accepted message ID beside the user or order event that caused the send.

Production checklist

  • Secrets stay server-side
  • Timeout and retry policy
  • Idempotent webhook handler
  • Structured error logging

Questions people ask us

Queue your first Node.js email.

Use the typed client or fetch, then follow the returned ID through delivery.