Templates
API base URL: https://api.relayloft.com
A template holds an email's HTML (and optionally its text, subject, from and reply-to) with {{{KEY}}} where values go. Manage them under Templates in the portal, or with Resend's Templates API and a Full access key (resend.templates.*).
Variables
- Write
{{{KEY}}}in the HTML, text or subject. Keys are letters, digits and_, up to 50 characters, and each must be declared invariables(key,typestringornumber, optionalfallback_value). Up to 50. FIRST_NAME,LAST_NAME,EMAIL,UNSUBSCRIBE_URL,RESEND_UNSUBSCRIBE_URL,contactandthisare reserved.- Values are HTML-escaped in the HTML, so a value can't add markup or links; they go into the text as they are, and into the subject with line breaks removed. They're never put in other headers.
- Substitution only: no conditions, loops or includes, and nothing in a template runs. Anything else in triple braces (such as
{{{contact.first_name}}}) is refused when you save.
Drafts and publishing
A new template is a draft. POST /templates/:id/publish makes the current draft the version emails use. Edits after that stay a draft (has_unpublished_versions is true) until you publish again, so sends keep using the published version. Only published templates can be sent. Duplicating makes a new draft named "… (copy)", without the alias.
const { data } = await resend.templates
.create({
name: "Order confirmation",
alias: "order-confirmation",
from: "Acme <orders@mail.yourcompany.com>",
subject: "Order {{{ORDER}}}",
html: "<p>{{{PRODUCT}}} costs {{{PRICE}}}</p>",
variables: [
{ key: "ORDER", type: "string" },
{ key: "PRODUCT", type: "string", fallbackValue: "Your item" },
{ key: "PRICE", type: "number" },
],
})
.publish(); // POST /templates, then POST /templates/:id/publishAlso GET /templates (newest first; limit, after, before), GET /templates/:id, PATCH /templates/:id, DELETE /templates/:id and POST /templates/:id/duplicate. Anywhere an id goes, the alias works too. Changes return { "id", "object": "template" }, as Resend's do.
Sending with a template
curl -X POST https://api.relayloft.com/emails \
-H "Authorization: Bearer $RESEND_API_KEY" -H "Content-Type: application/json" \
-d '{"to":"user@example.com","template":{"id":"order-confirmation","variables":{"ORDER":"#42","PRICE":499}}}'- Leave out
htmlandtext: sending them withtemplate: { … }is a422. from,subjectandreply_toin the send win over the template's; without either, the send needs its own.- A variable used in the template with no value and no fallback is a
422that names every missing one. Values are strings up to 2,000 characters or numbers. Values for keys the template doesn't use are ignored. - Works in batches too. The result goes through every check any email does: verified domain, size, sandbox, limits.
Limits
- 100 templates per app, 256 KB of HTML and 128 KB of text each.
- 500 template changes a day per account (API and portal together).