DeckleDocs
Dashboard

Sending

Templates

Store a design once, then send it by id with per-send variables instead of shipping raw HTML on every call.

A template bundles a reusable subject and design into a single object you reference by id. Send with template instead of html, pass in the values that change, and Deckle renders and instruments the email for you.

What is a template#

A template is a stored, reusable email design — a subject and a body — that lives in your project and is identified by a tmpl_ id. Instead of building the same HTML in your code for every send, you author the design once (in the dashboard or the gallery) and reference it by id at send time.

The stored source uses {{variable}} placeholders, so a single template covers every recipient. You supply the values that differ per send, and Deckle renders the final HTML and a plain-text alternative before delivering through your verified domain.

Templates vs. raw HTML

Reach for a template when the same design is sent repeatedly (receipts, welcome emails, password resets). Send raw html for one-off or fully dynamic content you assemble in code.

Send with a template#

Pass the template id as template and a variables object with the values to fill in. You can override the stored subject per send with the subject field, or omit it to use the template's own subject.

import { Deckle } from "@deckle/sdk";

const deckle = new Deckle(process.env.DECKLE_API_KEY!);

await deckle.emails.send({
  from: "Acme <hello@acme.com>",
  to: "jane@example.com",
  template: "tmpl_welcome",
  variables: {
    first_name: "Jane",
    company: "Acme",
  },
});

Exactly one of html or template is required. Everything else about the send — cc, bcc, reply_to, and attachments — works the same as a raw HTTP or SDK send.

Variables#

Templates and subjects use {{variable}} placeholders, filled from the variables object on the send and from the contact's stored data. Missing values can fall back with {{first_name | "there"}}.

See Variables & personalization for the full syntax, fallbacks, and conditional blocks.

Automatic tracking#

Template sends are instrumented

When you send with a template, Deckle automatically injects an open-tracking pixel and rewrites links for click tracking, so opens and clicks flow into the contact timeline and your webhooks. Raw html sends are delivered as-is and are not instrumented.

If you need open and click analytics on content you build yourself, send it through a stored template rather than inline html. The tracked events surface on the contact timeline and as email.opened and email.clicked webhook events.

Managing templates#

Create, edit, and preview templates in the dashboard under Templates. The editor gives you desktop and mobile previews, light and dark inbox modes, sample variable data, and checks for spam score, broken links, and missing variables.

You can also manage templates programmatically. See the Templates API reference for creating and listing templates, or start from a ready-made design in the template gallery.

Next steps#