curl https://api.dynamicdocumentapi.com/v1/pdf/from-template \
-H "Authorization: Bearer $DYNAMIC_DOCUMENT_API_KEY" \
-H "Idempotency-Key: R-2026-0042" \
-H "Content-Type: application/json" \
-d '{
"template_id": "tpl_einvoice",
"data": {
"invoice": {
"number": "R-2026-0042",
"issue_date": "2026-09-23",
"due_date": "2026-10-23",
"currency": "EUR",
"buyer_reference": "PO-4711",
"delivery": { "date": "2026-09-22" },
"seller": {
"name": "Example GmbH", "vat_id": "DE123456789",
"electronic_address": { "id": "invoices@example.com", "scheme": "EM" },
"address": { "line1": "Beispielstraße 1", "city": "Berlin", "postcode": "10115", "country": "DE" }
},
"buyer": {
"name": "Customer AG", "vat_id": "DE987654321",
"electronic_address": { "id": "ap@customer.example", "scheme": "EM" },
"address": { "line1": "Marktplatz 5", "city": "München", "postcode": "80331", "country": "DE" }
},
"payment": { "means_code": "58", "credit_transfers": [{ "account_id": "DE02120300000000202051" }] },
"lines": [
{ "quantity": "10", "unit": "HUR", "price": { "net": "100.00" },
"tax": { "category": "S", "rate": "19" }, "item": { "name": "Consulting" } }
]
}
},
"einvoice": { "profile": "EN16931", "invoice_path": "invoice" },
"filename": "{{ data.invoice.number }}.pdf",
"delivery": "binary"
}' \
--output R-2026-0042.pdf
// Node.js 18+: render the invoice as a Factur-X / ZUGFeRD PDF
export async function renderEInvoice(invoice) {
const res = await fetch("https://api.dynamicdocumentapi.com/v1/pdf/from-template", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DYNAMIC_DOCUMENT_API_KEY}`,
"Idempotency-Key": invoice.number, // safe to retry
"Content-Type": "application/json",
},
body: JSON.stringify({
template_id: "tpl_einvoice",
data: { invoice },
einvoice: { profile: "EN16931", invoice_path: "invoice" },
filename: `${invoice.number}.pdf`,
delivery: "binary",
}),
});
if (!res.ok) throw new Error(await res.text());
return Buffer.from(await res.arrayBuffer());
}
import os
import requests
def render_einvoice(invoice: dict) -> bytes:
res = requests.post(
"https://api.dynamicdocumentapi.com/v1/pdf/from-template",
headers={
"Authorization": f"Bearer {os.environ['DYNAMIC_DOCUMENT_API_KEY']}",
"Idempotency-Key": invoice["number"], # safe to retry
},
json={
"template_id": "tpl_einvoice",
"data": {"invoice": invoice},
"einvoice": {"profile": "EN16931", "invoice_path": "invoice"},
"filename": f"{invoice['number']}.pdf",
"delivery": "binary",
},
timeout=130,
)
res.raise_for_status()
return res.content
<?php
function renderEInvoice(array $invoice): string
{
$ch = curl_init('https://api.dynamicdocumentapi.com/v1/pdf/from-template');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('DYNAMIC_DOCUMENT_API_KEY'),
'Idempotency-Key: ' . $invoice['number'], // safe to retry
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'template_id' => 'tpl_einvoice',
'data' => ['invoice' => $invoice],
'einvoice' => ['profile' => 'EN16931', 'invoice_path' => 'invoice'],
'filename' => $invoice['number'] . '.pdf',
'delivery' => 'binary',
]),
]);
return curl_exec($ch); // PDF/A-3b with the XML embedded
}