Sende Rechnungsdaten per HTTP POST – erhalte ein druckfertiges PDF zurück.
Perfekt für ERP-Systeme, Webshops und eigene Software.
Einfache Authentifizierung per X-API-Key Header – kein OAuth, kein Token-Refresh.
Ein POST mit JSON-Body genügt. Antwort ist direkt das PDF-Binary – oder Base64 auf Wunsch.
Mit QR-IBAN im Request wird automatisch ein Schweizer Zahlungsabschnitt generiert.
Adresse, Logo und IBAN kommen aus deinem Autofactura-Konto – kein doppeltes Pflegen.
HEADERS
X-API-Key: <dein-api-key> Content-Type: application/json
BODY (JSON) – VOLLSTÄNDIGES BEISPIEL
{
// Rechnung
"invoice_number": "2026-042",
"invoice_date": "2026-07-15",
"due_date": "2026-08-14",
"project": "Website Relaunch", // optional
// Kunde
"customer_name": "Muster GmbH",
"customer_contact_person": "Max Muster", // optional
"customer_street": "Bahnhofstrasse",
"customer_building_nr": "12",
"customer_postcode": "8001",
"customer_city": "Zürich",
// Positionen
"items": [
{
"name": "Webentwicklung – Modul A", // oder "description"
"subtitle": "inkl. Testing", // optional, kleine Zeile
"quantity": 8,
"price": 150.00,
"total": 1200.00 // optional, sonst quantity × price
},
{ "name": "Support-Pauschale Mai", "quantity": 1, "price": 250.00 }
],
// Beträge (alle optional – werden aus items berechnet wenn 0)
"subtotal": 1450.00,
"discount": 0.00,
"vat_rate": "8.1",
"vat_amount": 117.45,
"total": 1567.45,
"notes": "Zahlbar innert 30 Tagen. Danke!", // optional
// QR-Rechnung – optional, sonst aus Konto
"qr_iban": "CH56 0483 5012 3456 7800 9",
"qr_reference": "210000000003139471430009017",
// QR-Kreditor-Adresse – optional, sonst aus Konto
"qr_creditor_name": "Muster GmbH",
"qr_creditor_street": "Bahnhofstrasse",
"qr_creditor_building_nr": "12",
"qr_creditor_postcode": "8001",
"qr_creditor_city": "Zürich",
// Firmendaten überschreiben – optional, sonst aus Konto
"company_name": "Muster GmbH",
"company_street": "Bahnhofstrasse",
"company_building_nr": "12",
"company_postcode": "8001",
"company_city": "Zürich",
"company_logo": "data:image/png;base64,iVBORw0KGgo..."
}OPTIONALER QUERY-PARAMETER
?format=base64
Gibt JSON mit {"success":true,"pdf":"<base64>"} zurück statt Binary-PDF.
FELDER: RECHNUNG
| Feld | Typ | Pflicht | Beschreibung |
|---|---|---|---|
invoice_number | string | ja | Rechnungsnummer |
invoice_date | date | ja | Rechnungsdatum (YYYY-MM-DD) |
due_date | date | ja | Fälligkeitsdatum (YYYY-MM-DD) |
project | string | – | Projektname, erscheint unter Rechnungsnummer |
notes | string | – | Bemerkungen / Zahlungshinweis (Fusszeile) |
FELDER: KUNDE
| Feld | Typ | Pflicht | Beschreibung |
|---|---|---|---|
customer_name | string | ja | Firmen- oder Kundenname |
customer_contact_person | string | – | Kontaktperson, erscheint unter Firmenname |
customer_street | string | ja* | Strasse (*Pflicht für QR-Rechnung) |
customer_building_nr | string | ja* | Hausnummer |
customer_postcode | string | ja* | PLZ |
customer_city | string | ja* | Ort |
FELDER: POSITIONEN
| Feld | Typ | Pflicht | Beschreibung |
|---|---|---|---|
items | array | ja | Array mit Positionen (siehe unten) |
items[].name | string | ja | Bezeichnung (alternativ: description) |
items[].subtitle | string | – | Zweite Zeile, kleinere Schrift |
items[].quantity | float | – | Menge (Standard: 1) |
items[].price | float | – | Einzelpreis in CHF |
items[].total | float | – | Zeilentotal (sonst quantity × price) |
items[].discount | float | – | Rabatt auf Position in CHF |
FELDER: BETRÄGE
| Feld | Typ | Pflicht | Beschreibung |
|---|---|---|---|
subtotal | float | – | Zwischensumme (wird aus items berechnet wenn 0) |
discount | float | – | Gesamtrabatt in CHF |
discount_label | string | – | Bezeichnung des Rabatts (Standard: "Rabatt") |
vat_rate | string | – | MwSt-Satz z.B. "8.1" oder "manual" |
vat_amount | float | – | MwSt-Betrag in CHF |
total | float | – | Gesamtbetrag (wird berechnet wenn 0) |
FELDER: QR-RECHNUNG (optional – sonst aus Konto)
| Feld | Typ | Beschreibung |
|---|---|---|
qr_iban | string | QR-IBAN (CH…). Kein QR-Abschnitt wenn leer. |
qr_reference | string | 27-stellige QR-Referenz (Pflicht bei QR-IBAN) |
qr_creditor_name | string | Name des Zahlungsempfängers |
qr_creditor_street | string | Strasse des Zahlungsempfängers |
qr_creditor_building_nr | string | Hausnummer |
qr_creditor_postcode | string | PLZ |
qr_creditor_city | string | Ort |
FELDER: FIRMENDATEN ÜBERSCHREIBEN (optional – sonst aus Konto)
| Feld | Typ | Beschreibung |
|---|---|---|
company_name | string | Firmenname |
company_street | string | Strasse |
company_building_nr | string | Hausnummer |
company_postcode | string | PLZ |
company_city | string | Ort |
company_logo | string | Logo als Data-URI: data:image/png;base64,… |
ERFOLG – PDF BINARY
HTTP/1.1 200 OK Content-Type: application/pdf Content-Disposition: attachment; filename="rechnung_2026-042.pdf" [binary PDF data]
ERFOLG – BASE64 (?format=base64)
{
"success": true,
"pdf": "JVBERi0xLj...",
"filename": "rechnung_2026-042.pdf"
}FEHLER
// 401 Unauthorized
{ "success": false, "error": "Ungültiger API Key" }
// 400 Bad Request
{ "success": false, "error": "Feld \"items\" ist erforderlich" }CURL
curl -X POST https://app.autofactura.ch/api/extern/invoice/pdf \
-H "X-API-Key: DEIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"invoice_number": "2026-042",
"customer_name": "Muster AG",
"customer_city": "Zürich",
"customer_postcode": "8001",
"items": [
{ "description": "Beratung", "quantity": 2, "price": 150 }
]
}' \
--output rechnung.pdfJAVASCRIPT / FETCH
const res = await fetch(
'https://app.autofactura.ch/api/extern/invoice/pdf?format=base64',
{
method: 'POST',
headers: {
'X-API-Key': 'DEIN_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
invoice_number: '2026-042',
customer_name: 'Muster AG',
customer_city: 'Zürich',
items: [{ description: 'Beratung', quantity: 2, price: 150 }],
}),
}
);
const { pdf } = await res.json();PHP
$data = [
'invoice_number' => '2026-042',
'customer_name' => 'Muster AG',
'customer_city' => 'Zürich',
'items' => [
['description' => 'Beratung', 'quantity' => 2, 'price' => 150],
],
];
$ch = curl_init('https://app.autofactura.ch/api/extern/invoice/pdf');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: DEIN_API_KEY',
'Content-Type: application/json',
],
]);
$pdf = curl_exec($ch);
file_put_contents('rechnung.pdf', $pdf);Im Autofactura Pro-Abo enthalten. Generiere deinen API Key unter Profil → Einstellungen → API Key – sofort verfügbar.