INTEGRATION / V1
Deine erste PDF-Anfrage.
Ein Template, ein API key und JSON. Diese Anleitung nutzt dieselben fiktiven Daten wie die Vorschau der Startseite.
01 / Template erstellen
Öffne die Console, speichere das Beispiel-HTML als Template und kopiere die template_id. Erstelle einen API key für dasselbe Konto. Bewahre ihn auf deinem Server in SYSINVOICE_API_KEY auf, niemals im Browser-Code.
ConsoleDas Beispiel-Template
Dieses minimale A4-Beispiel unterstützt eine Position mit Menge 1. Berechne Summen für komplexere Rechnungen in deiner Anwendung. Das CSS ist eingebettet; externe Ressourcen und Skripte sind nicht nötig.
HTML-Template herunterladenDas Beispiel-Template
<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<style>
@page { size: A4; margin: 0; }
* { box-sizing: border-box; }
body { margin: 0; padding: 64px; color: #15223b; font: 15px Arial, sans-serif; }
header { display: flex; justify-content: space-between; border-bottom: 3px solid #0891b2; padding-bottom: 32px; }
h1 { font-size: 38px; margin: 0 0 10px; letter-spacing: -1px; }
h2 { font-size: 16px; margin: 0 0 8px; }
p { line-height: 1.7; }
.muted { color: #526078; font-size: 12px; }
.meta { margin: 38px 0; display: flex; justify-content: space-between; }
table { width: 100%; border-collapse: collapse; margin-top: 42px; }
th { padding: 14px 8px; text-align: left; background: #f1f5f9; color: #526078; font-size: 11px; }
td { padding: 22px 8px; border-bottom: 1px solid #dbe2eb; }
.right { text-align: right; }
.total { display: flex; justify-content: space-between; margin-top: 30px; padding: 24px 8px; background: #ecfeff; font-weight: bold; font-size: 20px; }
footer { margin-top: 180px; padding-top: 20px; border-top: 1px solid #dbe2eb; }
</style></head><body>
<header><div><h2>NORTHSTAR / STUDIO</h2><span class="muted">Digital products & engineering</span></div><span class="muted">INVOICE</span></header>
<div class="meta"><div><h1>{{ .invoice_number }}</h1><span class="muted">Issued {{ .issued_at }}</span></div><div><span class="muted">BILL TO</span><p>Acme Labs<br>Sample account</p></div></div>
<table><thead><tr><th>DESCRIPTION</th><th class="right">QTY</th><th class="right">AMOUNT</th></tr></thead><tbody>
{{ range .line_items }}<tr><td>{{ .description }}</td><td class="right">{{ .qty }}</td><td class="right">{{ .amount }} {{ $.currency }}</td></tr>{{ end }}
</tbody></table>
<div class="total"><span>Total</span><span>{{ .total }} {{ .currency }}</span></div>
<p class="muted">Thank you for building with us.</p>
<footer class="muted">SysInvoice / Fictional example / One line item, quantity 1 / 01</footer>
</body></html>02 / Anfrage senden
Ersetze tpl_your_invoice_template durch die ID aus der Console. Der JSON-Body akzeptiert template_id und document_data bis maximal 2 MiB. Das Beispiel ruft von dieser Website aus keine API auf.
curl --fail-with-body --request POST \ https://api.sysinvoice.com/v1/invoices/generate \ --header "Authorization: Bearer $SYSINVOICE_API_KEY" \ --header 'Content-Type: application/json' \ --header 'Accept: application/pdf' \ --data '{ "template_id": "tpl_your_invoice_template", "document_data": { "invoice_number": "INV-2026-001", "issued_at": "2026-11-10", "currency": "EUR", "line_items": [ { "description": "API integration", "qty": 1, "price": 240, "amount": "240.00" } ], "total": "240.00" }}' \ --output invoice.pdf03 / Antwort verarbeiten
Eine erfolgreiche Anfrage liefert HTTP 200 und application/pdf-Bytes mit Cache-Control: no-store und X-Request-Id zur Diagnose. Speichere oder streame die Antwort in deiner Anwendung.
Beispiel-PDF öffnenFehler ausdrücklich behandeln
Fehlerhaftes JSON liefert 400; ungültige Zugangsdaten 401; unbekanntes Template 404; ungültige Daten 422. Beachte bei 429 den Header Retry-After. Mit --fail-with-body endet cURL bei HTTP-Fehlern erfolglos: Prüfe die Antwort, bevor du die Datei als PDF behandelst.