Writing one
{{ KEY }}is replaced by the value, HTML-escaped inhtml;{{{ KEY }}}places it as is, inhtmlonly. Keys are letters, digits and_, starting with a letter or_. There are no sections, loops, conditions or partials. Values are placed once: a value holding{{ OTHER }}is sent as that text.- A template has a draft and numbered published versions. Sends use the published version;
POST /v1/email/templates/{id}/publishmakes the draft the next one, and a restore copies an older version into the draft. - Send by template with
template: {"id": "<id or alias>", "variables": {…}}onPOST /v1/email/messagesand on each item of a batch.htmlandtextare then refused;subjectoverrides the template’s;fromandreply_tocome from the request, else the version, else the domain’s defaults. A missing variable takes its fallback, else422 template_variable_missing; an undeclared one answers422 template_variable_unknown. - The message is rendered when it is accepted: the size check, the idempotency fingerprint and the kept copy see the rendered message, and the message records the template and the version it used. A retry with the same Idempotency-Key after a new version was published answers what the first call answered.
- Over SMTP, the headers
X-Tawked-Template: <id or alias>andX-Tawked-Template-Variables: <a JSON object>send by template; a variables header that is not a JSON object (or is over 16 KiB) is refused with550 5.7.1 template_variables_invalid. "version": "draft"sends the draft: test keys only.
A template’s
from is written as a send’s is: {"name", "address"}, "orders@acme.sa" or "Acme <orders@acme.sa>"; null leaves it to the request and the domain’s defaults.
Publishing refuses with 422 template_invalid and its problems while one is an error: a placeholder the variables do not declare, no subject, no content, HTML over 512 KiB, or a from address off the application’s domains.
Sending by template
422 template_variable_missing; an undeclared one answers 422 template_variable_unknown; a template that was never published answers 422 template_not_published. Sending email has every code.