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
- A Pro or Max plan.
- An API key.
- A domain that can already send with the API.
-
Write the template#
Templates use Mustache placeholders: when you send, Mailyoto replaces
{{customer}}with the value namedcustomer. Placeholders work in the subject and in both bodies.Field Use 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_bodyescapes 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.
-
Save it#
Post the template to the domain’s
templatesendpoint: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
201with the saved template. Itsdata_keyslists the values the template reads:codeandcustomer. -
Preview it#
Post the values a send would carry to the template’s
previewendpoint. 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_bodyandhtml_body. Itsmissing_data_keyslistscode, becausedatahas no value for it: a send would leave that placeholder empty.To try a change before saving it, add
subject,text_bodyorhtml_bodyto the preview request. The saved template stays as it is. -
Send with it#
Send to the
outboundendpoint withtemplatein place ofsubject,text_bodyandhtml_body.template.namepicks the template, and each key intemplate.datafills 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
subjectin the request wins over the template’s subject.
Manage templates#
All of them start with https://api.mailyoto.com/v1/domains/<domain>/templates:
| Request | What it does |
|---|---|
GET /templates | Lists 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>/preview | Renders 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.