Guides

Templates and variables

Design an email once in the dashboard, then fill in names, codes and links per send with merge tags.

A template holds an email's subject, HTML body and optional plain-text body. You design it once in Templates, with the drag-and-drop builder or your own HTML, and every send fills in the parts that change.

Merge tags

Write a merge tag where a value should go: the variable name between double braces, for example {{name}}. Names use letters, digits and underscores, and spaces inside the braces are allowed, so {{ name }} works too.

<p>Hi {{name}},</p>
<p>Your sign-in code is <strong>{{code}}</strong>. It expires in 10 minutes.</p>

Merge tags work in the subject, the HTML body and the text body. The template editor lists the variables it finds under Variables, and Send test asks for a sample value for each.

Escaping

In the HTML body, a value inserted with {{name}} is HTML-escaped: <, >, & and quotes become entities, so a value such as Ada <script> shows up as text and cannot change your markup. This is what you want for anything a user typed.

When a value is HTML you built yourself and trust, insert it unescaped with triple braces: {{{name}}}.

<p>Hi {{name}},</p>
<div>{{{orderSummaryHtml}}}</div>

The subject and the text body are plain text, so values go into them as they are.

Never pass user input through {{{triple braces}}}. It reaches the recipient's mail client as HTML.

{{unsubscribe_url}} is filled in by SendHawk.Online itself with a signed link for the recipient, see Unsubscribe links.

Missing values

A merge tag without a matching variable stays in the email as written: a forgotten name arrives as the literal text {{name}}. Send every variable the template uses, and use Send test in the template editor after changing it. The test sends the last saved version.

Send with a template

Pass the template's templateId and its variables to Send email. The template supplies the subject and the bodies, so leave out subject, html and text; sending both kinds of content answers 400.

The template id is the UUID at the end of the template editor's address, /templates/<id>.

curl https://sendhawk.online/api/emails \
  -H "Authorization: Bearer $SENDHAWK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "Acme <hello@yourdomain.com>",
    "to": "ada@example.com",
    "templateId": "0193a4f2-5c1e-7b8d-9e0f-1a2b3c4d5e6f",
    "variables": { "name": "Ada", "code": "428913" }
  }'

Pass every value as a string. Format numbers, prices and dates the way the recipient should read them before you send, for example "EUR 49.00" rather than 49.

A templateId that does not belong to your workspace answers 404 Template not found.

Content without a template

Merge tags are filled in only for templates. When you send subject, html and text yourself, they go out exactly as you wrote them, and any {{name}} in them stays as text. Fill in your own values before sending, and HTML-escape anything a user typed.

Styling

Many mail clients drop or limit <style> blocks, so the template editor inlines your CSS into style attributes when you save. Keep layouts simple: tables for columns, a single column on small screens, and system fonts or a font stack that falls back cleanly.