DocumentationCreate and edit templates

Create and edit templates

Dashboard editor — Monaco, Unlayer blocks, and draft versions.

Templates in MailingCore are versioned. Each template has one or more versions in DRAFT or PUBLISHED state.

Dashboard editor

The dashboard provides a dual editor (ADR-035):

ModeEditorBest for
CodeMonacoDevelopers, custom HTML, Handlebars variables
BlocksUnlayer (when licensed)Marketing drag-and-drop layouts
PreviewSandboxed iframeGmail/Outlook preview before publish

Create a template

  1. Dashboard → TemplatesNew template
  2. First version is created automatically as DRAFT
  3. Edit subject, HTML, and optional Unlayer design JSON
  4. Save — only draft versions are editable

Edit a draft version

PATCH /templates/:id/versions/:versionId
Authorization: Bearer <JWT>
X-Tenant-Id: clxxxxxxxx

Draft-only fields: htmlBody, subject, textBody, locale, localeGroupId.

Version lifecycle

DRAFT ──publish──▶ PUBLISHED ──unpublish──▶ (back to editable draft flow)
  • Draft — editable, cannot send
  • Published — inlined CSS, usable in templateVersionId sends
  • Publish inlines CSS for email client compatibility — see Publish workflow

API create

POST /templates
Content-Type: application/json

{
  "name": "Welcome email",
  "subject": "Welcome to {{appName}}",
  "htmlBody": "<h1>Hello {{name}}</h1>"
}

Creates template + initial draft version.

Related