Docs
API · templates

Create a template

Save a reusable email with merge variables. Reference it later by id or slug from a send — the body is rendered server-side, so the markup never travels in your send call.

POST/v1/templates

Templates are scoped to a single project (sender). Use {{handlebars}} placeholders anywhere in the subject, HTML, or text — supply their values as data when you render or send.

01 Body parameters

namestringRequired
Human-readable name shown in the dashboard.
subjectstringRequired
Subject line. May contain merge variables.
htmlstringOptional
HTML body. Supports {{handlebars}} merge variables, {{#if}} / {{#each}} blocks, and filters such as {{name | default: "there"}}.
textstringOptional
Plain-text body. Recommended alongside html for clients that don't render HTML.
slugstringOptional
Stable handle used as templateId on a send. Lowercase [a-z0-9-], unique per project. Auto-derived from name when omitted.

02 Request

curl https://api.drin.run/v1/templates \
  -H "Authorization: Bearer $DRIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order Receipt",
    "subject": "Receipt {{orderId}}",
    "html": "<p>Hi {{firstName}}, thanks for your order.</p>"
  }'

03 Response

Returns 201 Created with the saved template. The variables array lists the merge fields the engine found — a quick way to confirm a placeholder didn't get mistyped.

201 Created
{
  "id": "tmpl_8XQ2k9",
  "slug": "order-receipt",
  "name": "Order Receipt",
  "subject": "Receipt {{orderId}}",
  "html": "<p>Hi {{firstName}}, thanks for your order.</p>",
  "text": null,
  "variables": ["firstName", "orderId"],
  "createdAt": "2026-06-02T10:00:00.000Z",
  "updatedAt": "2026-06-02T10:00:00.000Z"
}
Slug already in useA duplicate slug within the same project returns 409 conflict (template_slug_taken). Pick a different slug or update the existing template.