Skip to content

Template

Definition

A template is the content of an email kept apart from the code that sends it: a subject, a body, and named holes for the values that change. Copy can then be edited without a deploy, and every message of a kind looks the same. Versions matter, because sooner or later you will need to know which wording actually went out.

At a glance

Category
Sending
Holds
A subject, a body and declared variables
Versioned
Yes — only a published version is ever sent
Referenced by
An identifier or an alias, from your code
Recorded
Each message stores the exact version it used

How it works

A template declares the variables it expects, each with a type, so a send that omits one or passes the wrong shape is refused rather than producing a message with a blank where a name should be. Editing produces a new draft; publishing makes that draft the version sends will use. A send names the template by identifier or alias and supplies the variables, and the message records which version rendered it, so the copy can be recovered exactly later.

Why it matters

Separating copy from code lets the people who write the words change them without a deployment, which is worth having on its own. Versioning is what makes it safe: without it, a question about what a customer was told six weeks ago has no answer, because the template has been edited twice since. Declared variables add the other half, turning a rendering mistake into a refused request instead of an email that says hello to nobody.

Example

A password reset template declares a name and a link, both required strings. Marketing rewrites the subject line and publishes version four. Sends made afterwards render from version four and record that fact. A support question three months later about the wording somebody received is answered by opening version three, which is still there, rather than by guessing from the current draft.

Common mistakes

  1. 01Sending from a draft rather than a published version, so the copy under review is not the copy going out.
  2. 02Leaving variables undeclared, which turns a missing value into a message with a gap where a name should be.
  3. 03Editing a live template to fix a typo mid-campaign, so two halves of the same audience received different wording with no record of it.
  4. 04Putting conditional logic in the template that belongs in the code, which makes the copy unreadable to the people who own it.

In Rasket

Templates are versioned, only a published version is ever sent, variables are declared with types, and each email records the exact version it used. Templates

Frequently asked questions

Why does a template need versions?

So that the exact wording a customer received can be recovered later. Without versions, every edit silently rewrites the history of what you told people.

Should transactional mail use templates?

Usually yes. Receipts and notices are exactly the mail that benefits from consistent wording and from letting a non-engineer correct a sentence without a release.

What happens if a variable is missing at send time?

The send is refused, because the variable was declared as required. That is deliberate: a refused request is easier to notice and fix than a message with a visible gap in it.

Last updated 16 September 2026.

Start sending this morning

Verify a domain and send your first email in minutes.