Sending

How to create and send stored email templates

Short answer

A Mailcandor template is a stored email with variables written as {{{NAME}}} or {{{NAME|fallback}}} in its subject, html and text. Create one under Marketing > Templates with Add template, or with POST /v1/templates. Send it with template: {id, variables} on POST /v1/emails. Every variable without a fallback must be given. Values are HTML-escaped in the html.

Last checked 16 November 2026

Templates keep your email designs in one place, so your code only sends an id and a few values.

To create a template in the dashboard

You need the admin or developer role.

  1. Open Marketing > Templates and choose Add template.
  2. Fill in:
    • Name: for you, for example Password reset.
    • From (optional): such as Acme <hello@acme.com>. A send can set its own.
    • Subject: such as Reset your password, {{{NAME|there}}}.
    • HTML: the body, with variables.
    • Plain text (optional).
  3. Under Variables, add each key with a type (Text or Number) and an optional Fallback. Leave Fallback empty to make the variable required.
  4. Save. Copy the template ID from the list.

To create a template with the API

curl https://api.mailcandor.com/v1/templates \
  -H "Authorization: Bearer $MAILCANDOR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Password reset",
    "from": "Acme <hello@acme.com>",
    "subject": "Reset your password, {{{NAME|there}}}",
    "html": "<p>Hi {{{NAME|there}}},</p><p><a href=\"{{{RESET_URL}}}\">Reset your password</a></p>",
    "variables": [
      { "key": "NAME", "type": "string", "fallback_value": "there" },
      { "key": "RESET_URL", "type": "string" }
    ]
  }'

The answer is 201 with the template id. Manage templates with GET, PATCH and DELETE /v1/templates/{id} (full-access key).

Variable syntax

  • {{{NAME}}} puts in the value of NAME.
  • {{{NAME|there}}} puts in the value, or there if none is given.

A template needs html, text or both. Values are HTML-escaped when placed in html, so user input cannot break your layout.

To send a template

curl https://api.mailcandor.com/v1/emails \
  -H "Authorization: Bearer $MAILCANDOR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "sam@example.com",
    "template": {
      "id": "TEMPLATE_ID",
      "variables": { "NAME": "Sam", "RESET_URL": "https://acme.com/reset?t=abc" }
    }
  }'
  • from and subject come from the template if you leave them out. If the template has no from, add one to the send.
  • from, subject and reply_to on the send win over the template’s.
  • You cannot add html or text alongside template.
  • Templates work in batch sends too, one template per email.

If it does not work

Error Fix
422 “No template with this id on your team.” Check the id. Templates belong to one team.
422 missing_required_field “Template … needs the variable RESET_URL.” Give that variable, or add a fallback to the template.
422 “Template … has no variable …” You sent a variable the template does not declare. Add it to the template or remove it from the send.
422 “Send template or html/text, not both.” Remove html and text.
422 “template.variables is an object of names to values.” Send {"NAME": "Sam"}, not a list.
422 missing_required_field on from The template has no from; add one to the send.

Full reference: docs.mailcandor.com.

Questions

Can I send a template and my own html in one request?

No. Send either template or html/text. from, subject and reply_to on the send override the template's.

How many variables can a template have?

Up to 20. Each key is 1 to 50 letters, digits or underscores.

Can I use my SendGrid or Postmark templates?

No. Templates from other providers are not supported. Recreate them as Mailcandor templates or send rendered HTML.

Does Mailcandor render React Email?

No. Render React Email to HTML in your app, then send the HTML or store it as a template.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.