Skip to main content

Overview

Templates let you define reusable email layouts with {{variable}} placeholders. When sending, pass the template ID and variable values — Sendi renders the final email for you.

How It Works

  1. Create a template in the dashboard or via API with HTML, text, and subject containing {{variables}}
  2. Send an email with template_id and template_variables instead of raw HTML/text
  3. Sendi replaces all {{variable}} placeholders with your values and sends

Variable Syntax

Use double curly braces for variables:
<h1>Welcome, {{name}}!</h1>
<p>Thanks for joining {{company_name}}.</p>
<a href="{{dashboard_url}}">Get Started</a>
Variables work in the subject line, HTML content, and text content.

Sending with a Template

const { id } = await sendi.emails.send({
  from: 'you@yourdomain.com',
  to: 'user@example.com',
  templateId: 'template_uuid',
  templateVariables: {
    name: 'John',
    company_name: 'Acme Inc',
    dashboard_url: 'https://app.example.com',
  },
});

Overriding Template Fields

If you pass subject, html, or text alongside a template_id, the explicit values take precedence over the template’s values.

Variable Auto-Detection

When you create or update a template, Sendi automatically detects all {{variable}} names and stores them in the variables field. This makes it easy to see which variables a template expects.

Dashboard Editor

The dashboard includes a visual template editor with:
  • Starter templates — Welcome, Password Reset, Invoice, or start blank
  • Live preview — See rendered HTML with sample data
  • Variable insertion — Click to insert common variables at cursor position
  • HTML / Text / Preview tabs — Switch between code and rendered view

Managing Templates via API

See the Templates API reference for full CRUD operations.