Markdown

Templates

Create reusable email templates with {{variable}} placeholders, then send with POST /emails using template: { id, variables }.

Updated Nov 16, 20265 min read

Base URL: https://api.groundmail.dev

Authentication

Requires a full-scope API key (or dashboard session). Sending-scoped keys cannot manage templates.

HTTP
Authorization: Bearer gm_…

Model

Field Notes
name Required; unique per account
alias Optional unique handle (not empty, not starting with gm_)
status draft (default) or published
format html (legacy) or blocks (visual builder document)
subject / html / text Support {{var}} placeholders
preheader Optional inbox preview text. Sent with both html and blocks templates, and may use {{var}} placeholders
design TemplateDocument JSON when format is blocks
variables Variable names (auto-extracted for blocks templates)
published_version_id Immutable version used for sends
unsubscribe_enabled When true, sends using this template inherit managed unsubscribe unless overridden per send
category Deprecated: Groundmail decides the category from the published content each time you publish (how). Accepted and stored, but it doesn't change how email is sent. newsletter is rejected (approved accounts send newsletters with category: "newsletter" on POST /emails)
sender_id The sender the template goes out as when a send sets neither from nor sender. Pass a sender id or handle on create or update; null clears it, so sends fall back to your default sender. It isn't part of a published version: a change applies to the next send. Dashboard: Sends as in the template editor
folder Dashboard folder name, or null. Set it on create or update; a folder that doesn't exist yet is created. null or "" on update takes the template out of any folder. CLI: --folder
warnings Non-blocking deliverability hints for html (e.g. SVG logos)

Placeholders in HTML bodies are HTML-escaped when interpolated. Subject and text are not.

Placeholders use the same syntax as automation emails: spaces inside the braces are fine, and | default:"…" gives a fallback when a variable is missing or empty: Hi {{name | default:"there"}}. A variable you don't pass renders as empty text, never as braces.

Publishing snapshots an immutable version. Sends always resolve published_version_id, so draft edits never break live aliases. See Templates on groundmail.dev for the visual builder.

Global CSS (blocks templates)

design.settings.globalCss accepts ordinary CSS that is compiled for the inbox on render:

  • Rules whose selector is a bare tag (body, p, h1, h2, h3, a, img, hr) become inline styles on those elements and override per-block styling. Inlining matters because Gmail drops <style> on clipped and forwarded messages, and Outlook renders through Word.
  • Everything else — class and id selectors, pseudo-classes, descendant selectors, media queries — is emitted into a <style> block, which most clients honour.

@import is stripped, and CSS cannot inject markup.

JSON
{
  "design": {
    "version": 1,
    "settings": {
      "globalCss": "p { color: rgb(63,63,70); }\n@media (max-width: 480px) { p { font-size: 14px; } }"
    }
  }
}

Your brand (blocks templates)

Set your logo, colors and footer once in Templates › Brand or with PUT /brand. Templates made in the dashboard, from a starter or for an automation follow it: every setting they don't set themselves comes from the brand, and they show your logo on top and your company footer. design.settings.brand records which settings the template overrides ({ "overrides": ["linkColor"], "headerFooter": true }). Templates made before the brand keep their own look. Details: Brand.

Images in HTML

Use PNG or JPG logos at public https:// URLs in <img src="…"> tags. Many inboxes (including Gmail) do not render SVG images. Groundmail returns advisory warnings on template create/get/list when HTML may not render reliably — sends are not blocked.

HTML
<img src="https://yourdomain.com/assets/logo.png" alt="Your product" width="36" height="36" />

List

GET/templates

Query: limit, cursor, optional status=draft|published.

JSON
{
  "data": [
    {
      "id": "…",
      "name": "Welcome",
      "alias": "welcome",
      "status": "published",
      "subject": "Hello {{name}}",
      "html": "<p>Hi {{name}}</p>",
      "text": "Hi {{name}}",
      "variables": ["name"],
      "published_at": "2026-07-26T12:00:00.000Z",
      "created_at": "2026-07-26T11:00:00.000Z",
      "updated_at": "2026-07-26T12:00:00.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}

Create

POST /templates → 201

Creates a draft. Publish before sending.

JSON
{
  "name": "Welcome",
  "alias": "welcome",
  "subject": "Hello {{name}}",
  "html": "<p>Hi {{name}}</p>",
  "text": "Hi {{name}}",
  "variables": ["name"]
}

Starter catalog

GET /templates/starters — list copyable starters (full-scope key).

POST /templates/from-starter — copy one into your account as published with a fixed alias.

Alias Variables
password-reset name, reset_url
email-verification name, verify_url, code
welcome name, dashboard_url
invoice name, amount, invoice_url, invoice_id
team-invite name, inviter_name, team_name, invite_url

Dashboard: Templates → Start from a template. Returns 409 if the name or alias already exists on the account.

Terminal
curl -X POST https://api.groundmail.dev/templates/from-starter \
  -H "Authorization: Bearer $GROUNDMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"alias":"password-reset"}'
TypeScript
await client.templates.fromStarter('password-reset')
await client.emails.send({
  from: 'noreply@yourdomain.com',
  to: 'user@example.com',
  template: {
    id: 'password-reset',
    variables: { name: 'Ada', reset_url: 'https://app.example.com/reset?token=…' },
  },
})

Retrieve / update / delete

  • GET /templates/{id} — UUID or alias
  • PATCH /templates/{id} — update fields
  • DELETE /templates/{id} — returns 409 conflict while an automation step still sends the template (by id or alias). error.details.automations lists each automation (id, name) and the steps that send it; point those steps at another template, then delete it.

Automations send templates by reference, so publishing a new version changes every automation step that uses the template, as well as your own sends by alias. The template editor lists them under Used by.

Publish / duplicate

POST/templates/{id}

Duplicate creates a new draft (alias cleared). name is optional (defaults to … (copy)).

JSON
{ "action": "publish" }
JSON
{ "action": "duplicate", "name": "Welcome (copy)" }

Send with a template

POST/emails

template is mutually exclusive with html / text. Subject comes from the template unless you pass subject to override. Only published templates can be used.

Give the template a sender and the send can leave out from: it goes out as the template's sender (else your default sender). A from or sender on the request still wins. See Who it's from.

JSON
{
  "from": "you@yourdomain.com",
  "to": "user@example.com",
  "template": {
    "id": "welcome",
    "variables": { "name": "Ada" }
  }
}
JSON
{
  "to": "user@example.com",
  "template": { "id": "receipt", "variables": { "amount": "$20.00" } }
}

SDK

TypeScript
import { Groundmail } from 'groundmail'

const client = new Groundmail(process.env.GROUNDMAIL_API_KEY!)

const { template } = await client.templates.create({
  name: 'Welcome',
  alias: 'welcome',
  subject: 'Hello {{name}}',
  html: '<p>Hi {{name}}</p>',
})
await client.templates.publish(template.id)

await client.emails.send({
  from: 'you@yourdomain.com',
  to: 'user@example.com',
  template: { id: 'welcome', variables: { name: 'Ada' } },
})

React Email (optional peer)

Install @react-email/render (and react) to pass a React element:

The SDK compiles react to HTML before POST /emails. Mutually exclusive with html / text / template.

Full guide: Send React Email.

Terminal
npm install @react-email/render react
TypeScript
await client.emails.send({
  from: 'you@yourdomain.com',
  to: 'user@example.com',
  subject: 'Hello',
  react: EmailComponent({ name: 'Ada' }),
})

CLI

Terminal
groundmail templates list
groundmail templates starters
groundmail templates from-starter password-reset
groundmail templates create --name Welcome --subject "Hi {{name}}" --html "<p>Hi {{name}}</p>" --alias welcome --unsubscribe-enabled
groundmail templates update --id welcome --unsubscribe-enabled

Push from your repo

templates push upserts a template from a local file, keyed by --alias, so your repo can be the source of truth:

Flag Notes
<file> .html, .txt, or a module (.js, .mjs, .cjs, .jsx, .ts, .tsx) with a React component as its default export
--alias Required. Creates the template on first push, updates it afterwards
--subject Required only when creating
--name Display name; defaults to the alias
--preheader Inbox preview text
--text <file> Attach a hand-written plain-text part
--props <json> Props passed to the component when rendering
--publish Cut a published version after pushing

Module files are imported in your process and rendered with @react-email/render — only the resulting HTML and text are uploaded. TypeScript and JSX need a loader: install tsx (npm install -D tsx) or pre-render to .html. See React Email guide.

Need a starting point? Free email templates has 12 ready-made templates (password reset, receipts, invites and more) that push with one command.

Terminal
# HTML file
groundmail templates push ./emails/welcome.html --alias welcome --subject "Welcome" --publish

# React Email component, rendered locally
groundmail templates push ./emails/WelcomeEmail.tsx --alias welcome --props '{"name":"Ada"}' --publish

OpenAPI

OpenAPI spec

Was this page helpful?