Get started

Quickstart

Send your first email with the API.

Send a transactional email in four steps. You'll need a connected provider and a verified sending domain — see Connect a provider if you haven't done that yet.

Create an API key

In the dashboard, open Settings → API keys and create a key. Copy it now — it's shown once. Keys are prefixed aem_.

Author and publish a template

Create a template (e.g. slug welcome) and publish it. Only published templates can be sent. Templates use your company's brand and can reference variables like {firstName}. See Create a template.

Send it

npm install @sendandretain/sdk
import { SendAndRetain } from "@sendandretain/sdk";

const sendandretain = new SendAndRetain(); // reads SENDANDRETAIN_API_KEY

const { data, error } = await sendandretain.emails.send(
  { to: "[email protected]", template: "welcome", props: { firstName: "Jane" } },
  { idempotencyKey: "welcome-jane-1" },
);

Server-side only. Methods return { data, error } and never throw on an API error.

Check delivery

The send returns a message id. Look up its status and event timeline with a write-scope key:

curl https://sendandretain.com/api/v1/emails/msg_3aF9c1 \
  -H "Authorization: Bearer $AEM_KEY"

Next steps

On this page