Send documents to customers with PDF attachments and customizable templates.
Send
// title: Send invoice email
await sdk.email.send(invoice.id, {
to: "customer@example.com",
subject: "Invoice #{document_number}",
body: "Please find your invoice attached.",
});Uses the entity’s default email template for the document type and locale.
Custom Template
// title: Custom email template
await sdk.email.send(invoice.id, {
to: "billing@acme.com",
cc: "accounts@acme.com",
subject: "Invoice {document_number} from {entity_name}",
body: `Hi {customer_name},
Please find invoice **{document_number}** attached.
**Amount due:** {total_with_tax} {currency_code}
**Due date:** {due_date}
View online: {invoice_link}
Thank you for your business!`,
});Use template variables to personalize the subject and body.
Template Variables
Variables are wrapped in curly braces and replaced automatically when the email is sent.
Entity Variables
| Variable | Description |
|---|---|
{entity_name} | Your company/organization name |
{entity_email} | Entity email address |
{entity_address} | Street address |
{entity_city} | City |
{entity_post_code} | Postal/ZIP code |
{entity_country} | Country |
{entity_tax_number} | Tax/VAT number |
{entity_company_number} | Company registration number |
Document Variables
| Variable | Description |
|---|---|
{document_number} | Invoice or estimate number |
{document_date} | Issue date (localized) |
{document_due_date} | Payment due date (localized) |
{document_valid_until} | Estimate validity date (localized) |
{document_total} | Total amount with tax (2 decimal places) |
{document_currency} | Currency code (e.g., EUR, USD) |
Customer Variables
| Variable | Description |
|---|---|
{customer_name} | Customer’s name |
{customer_email} | Customer’s email |
Bank Account Variables
| Variable | Description |
|---|---|
{bank_account} | Full bank account details (multiline) |
{bank_account.iban} | IBAN |
{bank_account.account_number} | Account number |
{bank_account.bank_name} | Bank name |
{bank_account.bic} | BIC/SWIFT code |
{bank_account.name} | Account holder name |
{bank_account.routing_number} | Routing number (US) |
{bank_account.sort_code} | Sort code (UK) |
Date Variables
| Variable | Description |
|---|---|
{current_date} | Today’s date (localized) |
{current_year} | Current year |
Markdown Formatting
The body_text field supports Markdown formatting. Bold, italic, links, and lists all render correctly in the email. HTML tags and images are stripped for security.
PDF Attachment
Control what gets attached to the email:
| Option | Type | Default | Description |
|---|---|---|---|
attach_pdf | boolean | false | Attach the document as a PDF file |
attach_eslog | boolean | false | Attach e-SLOG 2.0 XML (Slovenian format) |
language | string | entity locale | Override the PDF and shareable link language |
Both attach_pdf and attach_eslog can be combined in a single email.
Default Templates & Multi-Language
When you create an entity, default email templates are automatically generated for each document type. Templates use the entity’s locale by default.
18 locales are supported: en-US, de-DE, it-IT, fr-FR, es-ES, sl-SI, pt-PT, nl-NL, pl-PL, hr-HR, sv-SE, fi-FI, et-EE, bg-BG, cs-CZ, sk-SK, nb-NO, is-IS.
Override the language per-email by passing the language option.
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| Variable shows as empty | Document or customer field is null | Ensure the referenced field is set before sending |
| Email not received | Recipient address invalid or blocked | Check the to address; review bounce logs in dashboard |
| Rate limited (429) | Too many emails sent | Sandbox: 60/min, Live: 850/min. Space out sends |
| PDF not attached | attach_pdf not set | Pass attach_pdf: true in the send options |
| Wrong language on PDF | Entity locale differs from customer | Pass language option to override |