Skip to main content
mailyoto

Send email from a template

Save a subject and body with placeholders once, then send it through the API with different values each time.

Pro or Max plan Updated 29 October 2026

When you finish, lunavera.com has a saved booking-confirmed template, and each send fills in the customer’s name and booking code.

You manage templates through the API only. The dashboard has no screen for them.

Before you start

  1. Write the template#

    Templates use Mustache placeholders: when you send, Mailyoto replaces {{customer}} with the value named customer. Placeholders work in the subject and in both bodies.

    FieldUse
    nameRequired. Up to 64 characters: lowercase letters and digits, joined by single dots, hyphens or underscores, starting with a letter. Unique on the domain.
    subjectOptional, up to 200 characters. The send request can supply the subject instead.
    html_body, text_bodyThe HTML and plain-text versions of the body. A template needs at least one. Most carry both.
    noteOptional, up to 250 characters. A note for yourself.

    Only html_body escapes HTML in the values it fills in. Write {{{customer}}} to keep a value as it is.

    A domain holds up to 250 templates. One template, its subject and both bodies together, can be up to 256 KB.

  2. Save it#

    Post the template to the domain’s templates endpoint:

    curl -X POST https://api.mailyoto.com/v1/domains/lunavera.com/templates \
      -H "Authorization: Bearer $MYO_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "booking-confirmed",
        "subject": "Booking {{code}} is confirmed",
        "text_body": "Hello {{customer}},\n\nYour booking {{code}} is confirmed.",
        "html_body": "<p>Hello {{customer}},</p><p>Your booking <strong>{{code}}</strong> is confirmed.</p>"
      }'

    The response is 201 with the saved template. Its data_keys lists the values the template reads: code and customer.

  3. Preview it#

    Post the values a send would carry to the template’s preview endpoint. The preview saves and sends nothing.

    curl -X POST https://api.mailyoto.com/v1/domains/lunavera.com/templates/booking-confirmed/preview \
      -H "Authorization: Bearer $MYO_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{ "data": { "customer": "Amina" } }'

    The response holds the rendered subject, text_body and html_body. Its missing_data_keys lists code, because data has no value for it: a send would leave that placeholder empty.

    To try a change before saving it, add subject, text_body or html_body to the preview request. The saved template stays as it is.

  4. Send with it#

    Send to the outbound endpoint with template in place of subject, text_body and html_body. template.name picks the template, and each key in template.data fills the placeholder of the same name.

    curl -X POST https://api.mailyoto.com/v1/domains/lunavera.com/outbound \
      -H "Authorization: Bearer $MYO_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "from": { "email": "bookings@lunavera.com", "name": "Luna Vera bookings" },
        "to": [{ "email": "amina.kone@gmail.com", "name": "Amina Koné" }],
        "template": {
          "name": "booking-confirmed",
          "data": { "customer": "Amina", "code": "LV-2207" }
        }
      }'

    A subject in the request wins over the template’s subject.

Manage templates#

All of them start with https://api.mailyoto.com/v1/domains/<domain>/templates:

RequestWhat it does
GET /templatesLists the domain’s templates without their bodies, a page at a time. Add ?order=updated for the last changed first.
GET /templates/<name>Returns one template with its bodies.
PATCH /templates/<name>Changes the fields you send, including name. Fields you leave out stay as they are. null clears one.
POST /templates/<name>/previewRenders the template with your data.
DELETE /templates/<name>Deletes the template. Sends that use its name afterwards return 404.

Each domain has its own templates. To use the same template on 2 domains, save it on both.

Name the template with lowercase letters and digits, joined by single dots, hyphens or underscores…

Start the name with a letter, and put a single ., - or _ between words. Booking Confirmed and booking- fail. booking-confirmed and booking.confirmed work.

The template has a Mustache syntax error

A placeholder isn’t closed, or a section opened with {{#name}} has no matching {{/name}}. Fix the part the message points to, then save again.

This domain already has a template named booking-confirmed

The response is 409. A domain can hold 1 template per name. Change the existing one with PATCH /templates/booking-confirmed, or choose another name.

Give the template a body

Send text_body, html_body, or both. Mailyoto doesn’t save a template without a body, because it can’t send one.

Your account saves templates of up to 256 KB

The response is 402. The subject and both bodies of one template can be up to 256 KB together. Move large images out of the HTML and link to them.

A send returns 404 for the template

The template name doesn’t match a template on the domain in the URL. Check the spelling with GET /templates, and check that you saved it on that domain.