HandlebarsPDF
German payment reminder (Mahnung) with GiroCode
A dunning letter in Handlebars: the wording changes with the final notice, open invoices are summed with interest and the reminder fee through nested helpers, and a GiroCode carries the total and the payment reference. The dunning run for all customers is one batch.
Free plan, no card. You get your own copy in the editor, published and ready for the API.
Rendered result
What this example shows
{{#if reminder.final}}switches between the friendly reminder and the final notice; both share the new deadline fromdateAdd reminder.date reminder.days_to_pay "days".- Handlebars nests helpers in brackets:
(add (add (sum invoices "amount") reminder.interest) reminder.fee)is the4.676,54 €to pay. - The same expression feeds
epcQr, so the GiroCode carries exactly the amount printed above it, with the payment reference from the data. - The days overdue come from your system as data. A template formats and adds up; it should not decide what is overdue.
- A dunning run is one batch: an item per customer,
zip: true, and one job to wait for.
Helpers used
Template folder
<p class="sender">{{company.name}} · {{company.street}} · {{company.city}}</p>
<address class="recipient">
<strong>{{customer.name}}</strong><br>
Buchhaltung<br>
{{customer.street}}<br>
{{customer.city}}
</address>
<table class="facts">
<tr><td>Datum</td><td>{{date reminder.date "dd.MM.yyyy"}}</td></tr>
<tr><td>Kundennummer</td><td>{{customer.number}}</td></tr>
</table>
<h1>{{reminder.level}}. Mahnung</h1>
<p>Sehr geehrte Damen und Herren,</p>
{{#if reminder.final}}
<p>trotz unserer Zahlungserinnerung sind die folgenden Rechnungen weiterhin offen. Bitte überweisen Sie den Gesamtbetrag bis zum <strong>{{date (dateAdd reminder.date reminder.days_to_pay "days") "dd.MM.yyyy"}}</strong>. Danach geben wir die Forderung ohne weitere Ankündigung an ein Inkassounternehmen ab.</p>
{{else}}
<p>sicher ist es Ihrer Aufmerksamkeit entgangen: Die folgenden Rechnungen sind noch offen. Bitte überweisen Sie den Gesamtbetrag bis zum <strong>{{date (dateAdd reminder.date reminder.days_to_pay "days") "dd.MM.yyyy"}}</strong>.</p>
{{/if}}
<table class="lines">
<thead>
<tr><th>Rechnung</th><th>Rechnungsdatum</th><th>Fällig seit</th><th class="num">Tage überfällig</th><th class="num">Offener Betrag</th></tr>
</thead>
<tbody>
{{#each invoices}}
<tr>
<td>{{number}}</td>
<td>{{date date "dd.MM.yyyy"}}</td>
<td>{{date due "dd.MM.yyyy"}}</td>
<td class="num">{{days_overdue}}</td>
<td class="num">{{money amount}}</td>
</tr>
{{/each}}
</tbody>
</table>
<table class="totals">
<tr><td>Offene Rechnungen</td><td class="num">{{money (sum invoices "amount")}}</td></tr>
<tr><td>Verzugszinsen</td><td class="num">{{money reminder.interest}}</td></tr>
<tr><td>Mahngebühr</td><td class="num">{{money reminder.fee}}</td></tr>
<tr class="grand"><td>Zu zahlen</td><td class="num">{{money (add (add (sum invoices "amount") reminder.interest) reminder.fee)}}</td></tr>
</table>
<figure class="pay">
<img src="{{epcQr name=company.name iban=company.iban bic=company.bic amount=(add (add (sum invoices "amount") reminder.interest) reminder.fee) text=reminder.reference size=110}}" alt="GiroCode">
<figcaption>Mit der Banking-App scannen: Betrag und Verwendungszweck <strong>{{reminder.reference}}</strong> sind eingetragen.</figcaption>
</figure>
<p class="muted">Sollten Sie inzwischen gezahlt haben, betrachten Sie dieses Schreiben bitte als gegenstandslos.</p>body { font-family: 'Inter', sans-serif; font-size: 9.5pt; line-height: 1.45; color: #1e293b; }
.sender {
display: inline-block;
margin: 10mm 0 3mm;
padding-bottom: 1mm;
border-bottom: 1px solid #cbd5e1;
font-size: 7pt;
color: #64748b;
}
.recipient { min-height: 27mm; font-style: normal; line-height: 1.5; }
.facts { float: right; margin-top: -27mm; font-size: 8.5pt; color: #475569; }
.facts td { padding: 0.4mm 0 0.4mm 5mm; }
.facts td:last-child { text-align: right; color: #1e293b; }
h1 { clear: both; margin: 14mm 0 4mm; font-size: 16pt; color: #312e81; }
table.lines { width: 100%; margin-top: 6mm; border-collapse: collapse; }
.lines th {
padding: 2mm 1.5mm;
border-bottom: 1.5px solid #1e293b;
text-align: left;
font-size: 7.5pt;
letter-spacing: 0.05em;
text-transform: uppercase;
color: #64748b;
}
.lines td { padding: 2.3mm 1.5mm; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.lines tr { break-inside: avoid; }
.num { text-align: right !important; white-space: nowrap; }
.totals { width: 78mm; margin: 5mm 0 0 auto; border-collapse: collapse; }
.totals td { padding: 1.2mm 1.5mm; }
.totals .grand td { border-top: 1.5px solid #1e293b; font-weight: 700; font-size: 11pt; }
.muted { color: #64748b; }
.pay { display: flex; align-items: center; gap: 4mm; margin: 10mm 0 6mm; break-inside: avoid; }
.pay figcaption { max-width: 70mm; font-size: 8pt; color: #475569; }<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap"><div style="box-sizing:border-box;width:100%;display:flex;justify-content:space-between;gap:6mm;padding:0 18mm;font-size:7px;line-height:1.5;color:#555">
<span>{{ company.name }} · {{ company.street }} · {{ company.city }}<br>{{ company.register }} · Geschäftsführung: {{ company.director }}</span>
<span>USt-IdNr. {{ company.vat_id }}<br>IBAN {{ company.iban }} · BIC {{ company.bic }}</span>
<span style="white-space:nowrap">Seite <span class="pageNumber"></span> von <span class="totalPages"></span></span>
</div>{
"paper": {
"format": "A4"
},
"margin": {
"top": "20mm",
"right": "18mm",
"bottom": "26mm",
"left": "22mm"
},
"locale": "de-DE",
"timezone": "Europe/Berlin",
"currency": "EUR",
"pdf": {
"metadata": {
"title": "{{reminder.level}}. Mahnung"
}
},
"footer": {
"height": "16mm"
}
}{
"company": {
"name": "Fennlor Studio GmbH",
"street": "Musterstraße 1",
"city": "12345 Musterstadt",
"phone": "+49 000 0000000",
"email": "hallo@fennlor.example",
"iban": "DE36000000000000000000",
"bic": "XXXXDEXXXXX",
"vat_id": "DE000000000",
"register": "Amtsgericht Musterstadt, HRB 00000",
"director": "Erika Mustermann"
},
"customer": {
"name": "Olvarest GmbH",
"contact": "Max Mustermann",
"street": "Beispielweg 2",
"city": "54321 Beispielstadt",
"number": "K-10482"
},
"reminder": {
"level": 2,
"final": true,
"date": "2026-10-20",
"days_to_pay": 7,
"interest": 18.64,
"fee": 5,
"reference": "K-10482 Mahnung 2"
},
"invoices": [
{
"number": "2026-0042",
"date": "2026-09-10",
"due": "2026-09-24",
"days_overdue": 26,
"amount": 3760.4
},
{
"number": "2026-0047",
"date": "2026-09-17",
"due": "2026-10-01",
"days_overdue": 19,
"amount": 892.5
}
]
}Render it through the API
Save the sample data as data.json and send it with the template’s name. TypeScript and Python use the SDKs; every other language posts the same JSON to the REST API with its standard library. Renders with a key that starts with ff_test_ are not metered; on the Free plan they carry a small watermark.
jq '{template: "mahnung", data: ., filename: "mahnung-K-10482.pdf"}' data.json \
| curl https://api-eu.formfeed.dev/v1/renders \
-H "Authorization: Bearer ff_test_..." \
-H "Content-Type: application/json" \
--data-binary @-import { Formfeed } from '@formfeed/sdk';
import data from './data.json' with { type: 'json' };
const formfeed = new Formfeed({ apiKey: process.env.FORMFEED_API_KEY! });
const render = await formfeed.renders.create({
template: 'mahnung',
data,
filename: 'mahnung-K-10482.pdf',
});
console.log(render.status, render.download_url);import json
import os
from formfeed import Formfeed
formfeed = Formfeed(api_key=os.environ["FORMFEED_API_KEY"])
with open("data.json", encoding="utf-8") as file:
data = json.load(file)
render = formfeed.renders.create(
template="mahnung",
data=data,
filename="mahnung-K-10482.pdf",
)
print(render.status, render.download_url)<?php
$body = [
'template' => 'mahnung',
'data' => json_decode(file_get_contents('data.json'), true),
'filename' => 'mahnung-K-10482.pdf',
];
$curl = curl_init('https://api-eu.formfeed.dev/v1/renders');
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('FORMFEED_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($body),
]);
$render = json_decode(curl_exec($curl), true);
echo $render['status'], ' ', $render['download_url'], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
data, err := os.ReadFile("data.json")
if err != nil {
panic(err)
}
body, _ := json.Marshal(map[string]any{
"template": "mahnung",
"data": json.RawMessage(data),
"filename": "mahnung-K-10482.pdf",
})
request, _ := http.NewRequest("POST", "https://api-eu.formfeed.dev/v1/renders", bytes.NewReader(body))
request.Header.Set("Authorization", "Bearer "+os.Getenv("FORMFEED_API_KEY"))
request.Header.Set("Content-Type", "application/json")
response, err := http.DefaultClient.Do(request)
if err != nil {
panic(err)
}
defer response.Body.Close()
var render struct {
Status string `json:"status"`
DownloadURL string `json:"download_url"`
}
json.NewDecoder(response.Body).Decode(&render)
fmt.Println(render.Status, render.DownloadURL)
}using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
var body = new
{
template = "mahnung",
data = JsonDocument.Parse(File.ReadAllText("data.json")).RootElement,
filename = "mahnung-K-10482.pdf",
};
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("FORMFEED_API_KEY"));
var response = await http.PostAsJsonAsync("https://api-eu.formfeed.dev/v1/renders", body);
var render = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine($"{render.GetProperty("status")} {render.GetProperty("download_url")}");import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
public class Render {
public static void main(String[] args) throws Exception {
String data = Files.readString(Path.of("data.json"));
String body = """
{
"template": "mahnung",
"filename": "mahnung-K-10482.pdf",
"data": %s
}
""".formatted(data);
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api-eu.formfeed.dev/v1/renders"))
.header("Authorization", "Bearer " + System.getenv("FORMFEED_API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body()); // status, download_url, page_count, units …
}
}require "json"
require "net/http"
body = {
template: "mahnung",
data: JSON.parse(File.read("data.json")),
filename: "mahnung-K-10482.pdf",
}
response = Net::HTTP.post(
URI("https://api-eu.formfeed.dev/v1/renders"),
JSON.generate(body),
"Authorization" => "Bearer #{ENV.fetch("FORMFEED_API_KEY")}",
"Content-Type" => "application/json"
)
render = JSON.parse(response.body)
puts render["status"], render["download_url"]More ways to call it
// the dunning run: one reminder per customer with overdue invoices, as one job
const job = await formfeed.renders.batch({
template: 'mahnung',
zip: true,
items: overdue.map(({ customer, invoices, reminder }) => ({
data: { company, customer, invoices, reminder },
filename: `mahnung-${customer.number}.pdf`,
})),
});Start rendering today
The free plan includes 100 units a month and free test renders. Change plans when you need more.
