You send the same shapes of email over and over: welcome notes, receipts, reminders. Coding that HTML into your app means a code change every time marketing tweaks the wording, and per-recipient personalization scattered through your send logic.
Nylas templates pull that content out of your code. You store a template with placeholders once, then render it with each recipient’s data and send the result, so the copy lives in one place and the personalization is a clean merge.
How do I create an email template?
Section titled “How do I create an email template?”Send a POST /v3/templates request with a name, a subject, a body, and an engine of mustache. Use {{variable}} placeholders in the 2 fields, the subject and body, and Mustache fills them at render time. The example below stores a template with a {{user}} placeholder in both fields.
curl --request POST \ --url "https://api.us.nylas.com/v3/templates" \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <NYLAS_API_KEY>' \ --header 'Content-Type: application/json' \ --data '{ "body": "<p>Hello from {{user}}</p>", "name": "Nylas Alias", "subject": "New notification for {{user}}", "engine": "mustache" }'Templates come in 2 scopes: application-level templates at /v3/templates and grant-level templates at /v3/grants/{grant_id}/templates, so you can share copy across your app or scope it to one account.
Use templates from the terminal
Section titled “Use templates from the terminal”Separately from the API’s hosted templates, the Nylas CLI keeps its own local templates on your machine for composing from the terminal. nylas email templates list shows them, and email templates use fills in variables and sends the result, so repeated emails don’t mean retyping the same body each time.
# List your local templatesnylas email templates list
# Render a template with variables and send it
# Preview the rendered template without sendingCLI templates live in ~/.config/nylas/templates.json and aren’t synced with Nylas, so they’re a terminal convenience, not the API’s hosted templates. Pass each variable as --var key=value, and --to is required even with --preview. The composed message itself sends across all 6 providers. See the email templates list and email templates use command reference.
How do I render and send a template?
Section titled “How do I render and send a template?”Render a stored template by calling POST /v3/templates/{template_id}/render with the values for its placeholders. Nylas returns 2 fields, the subject and body, with every {{variable}} replaced by your data. You then pass that rendered subject and body to the normal send endpoint, so the recipient gets a fully personalized message from the user’s own mailbox.
This split keeps templating and sending separate: render to preview or merge, then send when the content is ready.
Things to know about templates
Section titled “Things to know about templates”A couple of details shape how you use templates. The engine is Mustache, so {{variable}} substitution works throughout the subject and body. By default rendering is strict, so a missing variable returns an error; set strict to false to render it empty instead. Both scopes render the same 2 fields, so keep the 2 scopes in mind: application-level templates are reused across grants, while grant-level ones belong to a single account.
Because rendering and sending are separate steps, you can render a template for a preview in your UI without sending anything, then send only when the user approves. See templates and workflows for the full reference.
What’s next
Section titled “What’s next”- Send email to send the rendered subject and body
- Templates and workflows for the full template reference
- Create and send email drafts to save a rendered template as a draft
- Schedule an email to send later to send a rendered template at a future time