The short answer: a template stores the subject and the body (HTML, text or both) with variables such as {{name}}. When sending, your system only gives the template_id and the values in variables. You change the wording in the template and the code stays the same.
Creating a template
| 1 |
On the Transactional e-mail page in Meu Interweb, open Templates and create one, or use POST /v1/email/templates.
|
|
| 2 |
Give it a name of up to 100 characters, unique in the account, such as "Invoice ready".
|
|
| 3 |
Write the subject and the body, with variables in double curly braces: Invoice {{number}} is ready.
|
|
| 4 |
Save. The page shows the template number in the API: that is the template_id. The API answer also lists the variables it found.
|
|
Sending with the template
curl https://api.interweb.co.mz/v1/email/messages \
-H "Authorization: Bearer sandbox_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: fatura-2026-214" \
-d '{"from": "Your Company <invoices@asuaempresa.co.mz>",
"to": ["ana@example.com"],
"template_id": 12,
"variables": {"name": "Ana", "number": "FT 2026/214",
"amount": "1,250.00", "date": "30/11/2026"}}'
Any subject, html or text you leave out comes from the template. If you send one of them, what you sent wins for that e-mail.
Taking care with variables
| Rule |
Why |
| In HTML, values are escaped |
A name with < or & shows as text, so it neither breaks the e-mail nor lets odd code in. |
| variables is an object of names and values |
A list or a loose string gives a validation error. |
| Use the same names in the template and the send |
A variable with no value stays unfilled. Check with a Sandbox send. |
| Keep sensitive data out of the template text |
A password or a full card number never goes by e-mail. |
Changing or deleting
With PATCH /v1/email/templates/{id} only the fields you send change, for example just the subject. DELETE /v1/email/templates/{id} removes it. If the account already has the maximum number of templates, delete one you do not use before creating another.
|
Want to automate your invoices and confirmations with templates? See the API page.
See the API page
|
RECOMMENDED PRODUCT Professional e-mail on your domain Mailboxes in your company name, no adverts, with spam filtering. from $5.36/mo (3-year plan, with coupon) See plans |