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.
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" }
[ 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.
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.
Create one server-side client
Load the API key from server-only configuration and reuse the client across requests.
Send after the action succeeds
Queue the receipt, reset, or welcome message after your database transaction completes.
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
[ 04 / 04 ]Related
Use Node.js in context
Questions people ask us
Queue your first Node.js email.
Use the typed client or fetch, then follow the returned ID through delivery.