Get started
Send your first email
A hands-on walkthrough: send raw HTML, then a branded template with variables, and inspect what happened.
If you followed the Quickstart, you already have a key. Here we go a little deeper — the same send call powers everything from a password reset to a receipt.
Prerequisites#
- An API key (create one) exported as
DECKLE_API_KEY. - A verified sending domain for live sends — or use test mode against the SES simulator.
Send a raw HTML email#
The only required fields are from, to, subject, and one of html or template. The from address must be on a domain you’ve verified.
import { Deckle } from "@deckle/sdk";
const deckle = new Deckle(process.env.DECKLE_API_KEY!);
const result = await deckle.emails.send({
from: "Acme <hello@acme.com>",
to: "jane@example.com",
reply_to: "support@acme.com",
subject: "Welcome to Acme 👋",
html: `
<h1>Welcome, Jane</h1>
<p>Thanks for signing up. Your account is ready.</p>
`,
text: "Welcome, Jane. Thanks for signing up.",
});
console.log(result.id, result.status);Always include plain text
Pass atext alternative alongside html. Multipart emails look trustworthy to spam filters and render everywhere. When you send a stored template, Deckle generates the text part for you.Send a template with variables#
Instead of inline HTML, reference a stored template by id and pass variables. Deckle renders the template, fills {{placeholders}}, and injects open + click tracking automatically.
await deckle.emails.send({
from: "Acme <hello@acme.com>",
to: "jane@example.com",
subject: "Welcome, {{first_name}}",
template: "tmpl_welcome_01",
variables: { first_name: "Jane", plan: "Pro" },
});See Templates and Variables & personalization for the full syntax, including fallbacks like {{first_name | "there"}}.
Inspect the result#
Every send returns an id. Use it to fetch the current status and engagement counts, or list recent sends.
const email = await deckle.emails.get(result.id);
// { id, to, subject, status: "delivered", opens: 1, clicks: 0, ... }
const recent = await deckle.emails.list({ status: "sent", limit: 20 });You’ll also see every send in the dashboard under Developers → Email logs, with delivery, open, click, bounce, and complaint status as it arrives.