Through the REST API — just like through the web interface — you can create and read email templates for sending documents and for payroll updates. Templates are stored in the sablona-mail record.
⚠️ This record is available only for the Premium license.
Reading a template
You can retrieve a template with a standard query on the record; you can also use detail levels:
GET https://demo.flexibee.eu/c/demo/sablona-mail/{id}.json?detail=full
Creating a template
To create a template, send XML or JSON to the record's address:
PUT https://demo.flexibee.eu/c/demo/sablona-mail.xml
Property | Required | Meaning |
| yes | Template code. Must be unique — otherwise the import will fail with the error |
| yes | Template name. |
| yes | The template text itself. Without it, the import will fail with the error |
| yes | Usage locations — determines which documents the template is offered for, for example |
| no | Email subject. |
| no | Sender. |
| no | Description and note. |
| no | Name in other languages (SK, EN, RO). |
ℹ️ To update an existing template, identify it using the <id>code:ZKRATKA</id> element. If you instead send only the kod property again, ABRA Flexi will attempt to create a new record and will encounter a duplicate code.
Attaching a template to a document type
To attach a template to a document type — here specifically to the issued invoice type — send XML like the following to the relevant record. The sablonaMail element specifies the template identifier that you want to assign:
<?xml version="1.0"?>
<winstrom version="1.0">
<typ-faktury-vydane>
<kod>{kod}</kod>
<nazev>FAV se šablonou</nazev>
<modul>FAV</modul>
<radaPrijem>code:FAKTURA-STANDARD</radaPrijem>
<typDoklK>typDokladu.faktura</typDoklK>
<sablonaMail>{identifikátor šablony}</sablonaMail>
<poznam>Šablona pro faktury vydané</poznam>
</typ-faktury-vydane>
</winstrom>
Template example and Freemarker variables
The FreeMarker templating system is used. The following variables can be used in templates:
Variable | Value |
| Application name. |
| Localized phrase "Generated by the accounting system". |
| The user object, which can be worked with further — for example |
| Company settings — for example |
| First name of the logged-in user. |
| Last name of the logged-in user. |
| Full name including any titles earned. |
| Company name. |
| Generic access to the passed object. |
| The document to be sent — for example |
To find out which properties a particular document has available, check the property overview of the given record:
GET https://demo.flexibee.eu/c/demo/faktura-vydana/properties.json
💡 When accessing object properties, an exclamation mark is added at the end of the expression — ${doklad.firma!} — as a check for empty values. Without it, the template will fail on unfilled properties.
⚠️ To preserve paragraphs, use the HTML element <p>. Without it, the text will be merged into a single paragraph.
Example of using these variables in a template
Dobrý den, zasílám Vám doklad ${doklad}, jehož interní číslo je ${doklad.kod}. Jmenuji se ${uzivatelJmeno} ${uzivatelPrijmeni}, včetně mého titulu ${titulJmenoPrijmeni}, pracuji pro ${nazevFirmy}. Mé telefonní číslo je ${user.mobil}, DIČ firmy je ${company.dic}.Dobrý den, uživatel ${user} Vám zasílá ${doklad.nazev}. S pozdravem ${titulJmenoPrijmeni}, zasláno z aplikace ${application}.Dobrý den, společnost ${nazevFirmy} Vám fakturuje ${doklad.sumCelkem} za své služby. S pozdravem ${titulJmenoPrijmeni}, zasláno z aplikace ${application}.
Validation of the template when saving
Before saving a template, the program checks whether it contains any disallowed expressions — it directly attempts to compile and evaluate the template. A non-compliant template will not be saved, and the error will be returned for the textSablona property:
What the template contains | How ABRA Flexi responds |
An unclosed or otherwise incorrect FreeMarker expression | Rejects with the message |
A property the object does not have — for example | Rejects with the message No such bean property and a template stack trace. |
Creating class instances using the | Rejects with a message stating that the given class is not allowed. |
