Templates

Saved transactional emails with declared variables. Edit a draft, publish a version, and send it by slug from the Emails API.

Draft and published

A template has a slug (1 to 63 lowercase letters, digits or dashes, unique per workspace), a name, a subject, an email document and a list of variables. It keeps a draft you edit and a published version that sends use. Publishing validates the draft: it needs a subject, every {{VARIABLE}} it uses must be declared, and a dry render must succeed. Sends always use the published version, so editing the draft never changes live mail. The detail answer includes draft, published and has_unpublished_changes.

Variable keyTypeDescription
namestringUppercase letters, digits and underscores, starting with a letter, at most 40 characters.
typestringstring (default), number or boolean. Values must match.
requiredbooleanA send without it fails with missing_variable unless there is a default.
defaultanyUsed when the send omits the variable.
descriptionstringFor people and agents.
# Start from a built in starter, then edit the draft and publish.
curl -X POST https://api.runearc.com/v1/templates \
  -H "Authorization: Bearer $RUNEARC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "from_starter": "password-reset" }'

curl -X POST https://api.runearc.com/v1/templates/$TEMPLATE_ID/publish \
  -H "Authorization: Bearer $RUNEARC_API_KEY"

Starter gallery

Eighteen starters ship with real copy and declared variables. GET /v1/template-starters returns each with slug, name, description, category, subject, variables, document and a rendered preview. Create one with { "from_starter": "<slug>" }.

CategoryStarters
Accountpassword-reset, magic-link, email-verification, verification-code, team-invite, account-deleted
Securitylogin-alert
Onboardingwelcome, trial-ending, feedback-request, waitlist-confirmation
Billingreceipt, invoice, subscription-renewal, payment-failed, refund-issued
Commerceorder-confirmation, shipping-notification

Send with a template

Add template to POST /v1/emails: a slug, or { "id": "<slug>", "variables": {...} }. Do not also send html or text (template_conflict). The subject comes from the template unless you send one. The email is tagged template with the slug. A sending key may send with a template but cannot create or edit them. The rest of the send, including idempotency, limits and statuses, is on Emails API and Sending.

curl -X POST https://api.runearc.com/v1/emails \
  -H "Authorization: Bearer $RUNEARC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "from": "Acme <noreply@acme.com>", "to": ["ada@example.com"],
        "template": { "id": "password-reset",
                      "variables": { "RESET_URL": "https://acme.com/reset/abc" } } }'

API

RequestBodyReturns
GET /v1/template-startersnoneThe 18 starters with previews.
GET /v1/templatesnoneTemplates.
POST /v1/templatesfrom_starter, or name, slug, description, subject, document, variables201 and the template. Empty body makes a blank one.
GET /v1/templates/{id}noneDetail with draft and published versions.
PATCH /v1/templates/{id}name, description, subject, document, variables, preview_variablesThe detail. Edits the draft.
DELETE /v1/templates/{id}none204. Archives it.
POST /v1/templates/{id}/publishnoneThe detail with the new published version.
POST /v1/templates/{id}/copyslug, name (both optional)201 and the copy, slug suffixed -copy by default.
POST /v1/templates/{id}/previewversion (draft or published), variablessubject, html, text.

CLI and MCP

runearc template starters
runearc template create --starter password-reset
runearc template publish tpl_...
runearc template send tpl_... --from "Acme <noreply@acme.com>" --to ada@example.com --var RESET_URL=https://acme.com/reset/abc

MCP tools: list_templates, create_template and send_template.

Errors

CodeStatusMeaning and fix
template_not_found404List templates with GET /v1/templates, or send a slug.
template_not_published409Publish the template before sending it.
template_slug_taken409Pick another slug, or copy the template.
invalid_template_slug400Use 1 to 63 lowercase letters, digits or dashes.
unknown_starter400Use a slug from GET /v1/template-starters.
invalid_subject, undeclared_variable, invalid_variables_schema400Fix the draft before publishing: set a subject, declare every variable it uses, use valid unique variable names.
missing_variable, invalid_variable400Send the required variables, as the declared type.
template_conflict400A send with a template cannot carry html or text.
invalid_template_ref400template is a slug or an object with id and variables.
insufficient_scope403A sending key cannot manage templates. Use a full key.

Something unclear or wrong? The API answers every error with a fix, and so should these docs. Back to runearc.com