Source: https://cli.nylas.com/guides/email-templates-cli

# Email Templates from the CLI

Outbound email at scale means writing the same message structure over and over. Email templates let you define a subject, body, and variable placeholders once, then reuse them across sends. The Nylas CLI stores templates locally or on the server, renders variables at send time, and supports both plain text and HTML.

Written by [Prem Keshari](https://cli.nylas.com/authors/prem-keshari) Senior SRE

Updated May 23, 2026

> **TL;DR:** `nylas email templates create` saves a reusable message with `{{variable}}` placeholders. `nylas email templates use` renders it with real values and sends in one step.

> **Disclosure:** Nylas CLI is built by Nylas, Inc. This comparison reflects our testing and product understanding as of May 23, 2026.

Command references used in this guide: [`nylas email templates create`](https://cli.nylas.com/docs/commands/email-templates-create), [`nylas email templates list`](https://cli.nylas.com/docs/commands/email-templates-list), [`nylas email templates use`](https://cli.nylas.com/docs/commands/email-templates-use), and [`nylas email send`](https://cli.nylas.com/docs/commands/email-send).

## Why use email templates from the CLI?

An email template is a reusable message with a fixed structure and variable slots that get filled at send time. Sales teams send dozens of outbound emails per rep per day. Writing each one from scratch wastes 3-5 minutes per message. Templates cut that to seconds: define the body once, swap in the recipient's name and company, and send.

Most template solutions live inside email clients or marketing platforms. The CLI approach is different: templates are files or server-side records you can version-control in Git, render in shell scripts, and chain into automated pipelines. A cron job can pull a list of leads from a CSV, render a template for each, and send 200 personalized emails in under 4 minutes without opening a browser.

## How do you create and manage templates?

Creating a template requires a name, subject line, and body. The `nylas email templates create` command stores the template and returns an ID you'll use for rendering and sending later. Template names must be unique within your account. The body supports both plain text and HTML, and you can include `{{variable}}` placeholders (using [Mustache](https://mustache.github.io/) syntax) that get replaced at render time.

Managing templates is straightforward: `list` shows all saved templates, `show` displays one template's full content, `update` modifies fields in place, and `delete` removes a template permanently. Templates persist across sessions. Once created, a template is available from any machine where you're authenticated with the same account.

```bash
# Create a plain-text template with variables
nylas email templates create \
  --name "sales-intro" \
  --subject "Quick question about {{company}}" \
  --body "Hi {{first_name}},

I noticed {{company}} is scaling its engineering team.
We help teams like yours automate email workflows
and cut integration time from 3 weeks to 2 days.

Worth a 15-minute call this week?

Best,
{{sender_name}}"

# List all saved templates
nylas email templates list

# Show a specific template
nylas email templates show TEMPLATE_ID

# Update the subject line
nylas email templates update TEMPLATE_ID \
  --subject "{{first_name}}, quick question about {{company}}"

# Delete a template
nylas email templates delete TEMPLATE_ID
```

Template IDs are stable strings that don't change after creation. Store them in environment variables or a config file so your scripts can reference templates by name. A typical outbound workflow uses 3-5 templates: initial outreach, follow-up, meeting request, demo recap, and close. Each has its own ID and variable set.

## What is the difference between local and hosted templates?

The CLI supports two template storage modes. Local templates live as files on your machine, typically in `~/.config/nylas/templates/`. Hosted templates are stored server-side through the Nylas API and sync across devices. Local templates load in under 10ms since there's no network call. Hosted templates add 200-400ms of latency but are accessible from any authenticated machine.

Local templates work well for personal workflows and scripts that run on a single machine. Hosted templates suit team environments where multiple people need the same templates. The `nylas email templates create` command creates local templates; `nylas template create` creates hosted ones. Both support the same variable syntax and rendering pipeline.

| Feature | Local templates | Hosted templates |
| --- | --- | --- |
| Storage | ~/.config/nylas/templates/ | Nylas API (server-side) |
| Latency | <10ms | 200-400ms |
| Cross-device sync | No (manual copy) | Yes (any authed machine) |
| Version control | Git-friendly (plain files) | API versioning only |
| Command prefix | `nylas email templates` | `nylas template` |

For CI/CD pipelines and automated sends, local templates are simpler. Commit them to your repo alongside the send script, and the entire workflow is reproducible. For sales teams with 5+ reps sharing the same template library, hosted templates avoid the “which version is latest?” problem.

## How do you render and send a template?

Rendering a template replaces `{{variable}}` placeholders with actual values and produces the final email body. The `nylas email templates use` command combines rendering and sending into one step: it takes a template ID, variable values, and a recipient, then sends the rendered message. The round-trip from render to delivered takes 1-3 seconds on Gmail and Outlook.

You can also render without sending to preview the output. The `nylas template render` command outputs the rendered body to stdout so you can inspect it before committing to a send. For HTML templates, `nylas template render-html` renders the HTML and prints it, which you can pipe into a browser or save to a file for visual review.

```bash
# Render and send a local template in one step
nylas email templates use TEMPLATE_ID \
  --to alice@example.com \
  --data '{"first_name":"Alice","company":"Acme Corp","sender_name":"Bob"}'

# Preview a hosted template without sending
nylas template render TEMPLATE_ID \
  --data '{"first_name":"Alice","company":"Acme Corp"}'

# Render HTML template for visual preview
nylas template render-html --body "<h1>Hello {{name}}</h1>" \
  --data '{"name":"Alice"}'

# Create and list a hosted template
nylas template create --name "follow-up" \
  --subject "Following up, {{first_name}}" \
  --body "Hi {{first_name}}, just checking in on our conversation about {{topic}}."

nylas template list
```

Variable names are case-sensitive, following [Handlebars](https://handlebarsjs.com/)/[Mustache](https://mustache.github.io/) conventions. If a template contains `{{First_Name}}` and you pass `--data '{"first_name":"Alice"}'`, the placeholder won't be replaced. Stick to lowercase with underscores for consistency. Unresolved variables appear as literal `{{variable}}` text in the sent message, so always preview first.

## How do you use templates for bulk outbound?

Bulk outbound combines a template with a recipient list, typically a CSV file. A shell script reads each row, maps columns to template variables, and calls the send command for each recipient. Sending 100 personalized emails this way takes about 2-3 minutes with a 1-second delay between calls to stay under provider rate limits. Gmail allows 500 sends per day for consumer accounts and 2,000 for Workspace accounts.

The script below reads a 3-column CSV (email, first name, company) and sends a personalized version of the “sales-intro” template to each recipient. It logs successes and failures to separate files, sleeps 1 second between sends to avoid rate limiting, and prints a summary at the end. For lists over 500 recipients, split into batches and run across multiple days.

```bash
#!/bin/bash
# bulk-send.sh — Send a template to a CSV list
TEMPLATE_ID="your-template-id"
SUCCESS=0
FAIL=0

# Skip CSV header, read each row
tail -n +2 leads.csv | while IFS=',' read -r email first_name company; do
  if nylas email templates use "$TEMPLATE_ID" \
    --to "$email" \
    --data "{\"first_name\":\"$first_name\",\"company\":\"$company\",\"sender_name\":\"Your Name\"}" 2>/dev/null; then
    echo "Sent to $email" >> send-log.txt
    ((SUCCESS++))
  else
    echo "Failed: $email" >> send-errors.txt
    ((FAIL++))
  fi
  sleep 1  # Rate limit: 1 send/second
done

echo "Done. Sent: $SUCCESS, Failed: $FAIL"
```

For HTML templates used in bulk sends, keep the HTML under 100KB per message. Gmail clips messages larger than 102KB, hiding the rest behind a “View entire message” link. Inline CSS rather than linking external stylesheets, since most email clients strip `<link>` tags. Test rendering with `nylas template render-html` before committing to a full send.

## Next steps

- [Personalize outbound email](https://cli.nylas.com/guides/personalize-outbound-email-cli) — advanced variable substitution and dynamic content blocks
- [Auto-create email drafts](https://cli.nylas.com/guides/auto-create-email-drafts) — generate draft messages from templates without sending
- [Send email from terminal](https://cli.nylas.com/guides/send-email-from-terminal) — one-off sends, attachments, and CC/BCC from the CLI
- [Full command reference](https://cli.nylas.com/docs/commands) — every flag and subcommand documented
