Simplifyd Cloud

Templates

Store reusable email content and render it at send time.

Templates let you store reusable HTML/text content with variables, publish it, and send with a template id or alias.

Create and publish

curl https://api.smail.dev/api/v1/templates \
  -H "Authorization: Bearer $SMAIL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order confirmation",
    "alias": "order-confirmation",
    "from": "orders@yourdomain.com",
    "subject": "Order {{{ORDER_ID}}} confirmed",
    "html": "<p>Hi {{{USER|there}}}, your order total is {{{TOTAL}}}.</p>",
    "text": "Hi {{{USER|there}}}, your order total is {{{TOTAL}}}.",
    "variables": [
      { "key": "ORDER_ID", "type": "string" },
      { "key": "USER", "type": "string", "fallback_value": "there" },
      { "key": "TOTAL", "type": "number" }
    ]
  }'

Publish before sending:

curl -X POST https://api.smail.dev/api/v1/templates/{template_id}/publish \
  -H "Authorization: Bearer $SMAIL_TOKEN"

Send with a template

await smail.emails.send({
  to: ["customer@example.com"],
  template: {
    alias: "order-confirmation",
    variables: {
      ORDER_ID: "1234",
      USER: "Ada",
      TOTAL: "$49.00",
    },
  },
});

Template variables use triple braces: {{{KEY}}}. A fallback can be provided inline: {{{USER|there}}}.