Back to Blog
🧩
/5 min read/By SMTPfast Team

Hosted email templates: write once, send by id

SMTPfast now stores your email templates. Write one with variables, preview it on desktop, mobile and dark mode, publish it, and send it by id or alias. The API matches Resend's Templates API.

templatesproductapiresend
Share:𝕏in

Until now, every email you sent through SMTPfast carried its own HTML. The receipt, the password reset and the welcome email lived in your codebase, so changing a sentence meant a pull request and a deploy, and nobody outside engineering could touch them.

That was the biggest gap in the product. Today it is closed: SMTPfast stores your templates. You write a template once, with variables, and your code sends it by id or alias with the values for that one recipient.

Draft and published

A template has two versions: a draft and a published version. Creating or editing a template only changes the draft. Publishing copies the draft into the published version, and every send that names the template renders the published version.

So you can open a template that is live in your app, change the copy, send yourself a test, and publish when it is right. Your production sends keep using the old version until you do.

A template can also set a default from, subject and reply_to. A send can override each of them.

Variables

Write a variable as {{{KEY}}} in the subject, the preview text or the body, and declare it with a type (string or number) and an optional fallback value. You can also write a fallback where you use it:

<p>Hi {{{NAME|there}}},</p>
<p>Your order of {{{PRODUCT}}} comes to {{{PRICE}}}.</p>
<p><a href="{{{RESEND_UNSUBSCRIBE_URL}}}">Unsubscribe</a></p>

A variable takes the value passed in the send, then its inline fallback, then its declared fallback. Values are escaped in the HTML body, so a value can never add markup to your email.

If a variable has no fallback and the send leaves it out, the API refuses the send with a 422 and lists the keys in missing_variables. It checks this before anything is charged or queued, so a half-filled receipt never reaches a customer.

Send it from your code

Pass a template object to POST /v1/emails, with the template id or alias and the variables:

curl -X POST https://smtpfa.st/api/v1/emails \
  -H "Authorization: Bearer $SMTPFAST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "[email protected]",
    "template": {
      "id": "order-confirmation",
      "variables": { "PRODUCT": "Desk lamp", "PRICE": 49 }
    }
  }'

The same object works on each item of POST /v1/emails/batch. After rendering, it is an ordinary send: the sender domain must be verified, suppressed recipients are dropped, and an Idempotency-Key works as usual. A retry with the same key gives back the first email, even if you published a new version in between.

The Templates API follows Resend's Templates API: create, update, publish, duplicate, list and delete, with the same field names. If your code already uses Resend templates, point it at https://smtpfa.st/api/v1 and it keeps working.

The editor

The Templates page in the dashboard has an editor with a live preview. You can switch the preview between desktop and mobile width and between light and dark mode, and fill in test values for each variable. A test send goes to your own address with the draft, before you publish anything.

The body can be HTML for full control, or Markdown, which SMTPfast turns into a clean layout made for mail clients. You can also write the plain-text part yourself, or let SMTPfast make one from the body.

If two people edit the same template, the second save does not overwrite the first. The editor shows that the template changed and offers to load the latest version.

Ten starters

Most teams need the same dozen emails, so the gallery has ten starters you can copy in one click:

  • Welcome
  • Email verification
  • Password reset
  • Receipt
  • Product update
  • Weekly digest
  • Event invitation
  • Re-engagement
  • Team invitation
  • Usage alert

They use table layout and inline styles, fit a 600px column, adapt to dark mode in the clients that support it, and load no external fonts or images. Copy one, change the words, the colors and the variables, and publish.

Broadcasts from a template

A template is not only for transactional email. In the broadcast editor, choose Start from a template, or pass template_id when you create a broadcast through the API. The template's content is copied into the new broadcast, and its fallbacks go with it, so the broadcast renders the same way.

For AI agents

The hosted MCP server has tools for templates too. An agent connected to your account can list templates, draft and publish them, and send an email with a template and its values, with the same scopes and checks as the API.

Get started

Open Templates in the sidebar, copy a starter, and send yourself a test. The Templates docs have every field, limit and error code.

If something is missing for your use case, reply to any of our emails. We want to get the details right.

Ready to get started?

Start sending transactional email today. Free to start, no credit card required.

Get Started for Free