Akaunting API – Anbindungsmöglichkeiten
Akaunting bringt eine REST-API mit, über die Beleg-Drafts, Kontakte und Banking-Daten programmatisch verwaltet werden können. Diese Seite zeigt die wichtigsten Endpunkte und die Anbindungs-Patterns für n8n + KI.
1. Basis-Setup
| Eigenschaft | Wert |
|---|---|
| Base URL (intern) | http://192.168.0.16:8888 |
| Base URL (extern) | https://buchhaltung.kistudent.local |
| API-Prefix | /api |
| Auth | Basic Auth (Email + Passwort) oder Personal Access Token |
| Format | JSON, JSON:API-konform (data-Wrapper) |
2. Authentifizierung
2.1 Basic Auth (einfach)
curl -u "admin@kistudent.local:passwort" \
https://buchhaltung.kistudent.local/api/companies
2.2 Personal Access Token (empfohlen)
Akaunting basiert auf Laravel Sanctum. Token im UI unter Profile → API Tokens generieren und verwenden:
curl -H "Authorization: Bearer <token>" \
https://buchhaltung.kistudent.local/api/companies
Token in Vaultwarden hinterlegen, niemals in Git.
3. Wichtige Endpunkte
| Endpunkt | Zweck |
|---|---|
| GET /api/companies | Liste der Firmen (Multi-Mandanten-fähig) |
| GET /api/contacts | Kunden & Lieferanten |
| POST /api/contacts | Neuen Kontakt anlegen |
| GET /api/documents | Rechnungen, Belege, Angebote |
| POST /api/documents | Neuen Beleg anlegen (Rechnung oder Eingangsrechnung) |
| GET /api/documents/{id} | Einzeldokument |
| PATCH /api/documents/{id} | Beleg-Status ändern (Draft → Approved) |
| GET /api/categories | Buchungskategorien |
| GET /api/taxes | MWST-Sätze (z.B. 8.1 %) |
| GET /api/items | Artikel |
| POST /api/items | Neuen Artikel anlegen |
| POST /api/transactions | Zahlung erfassen |
4. Beispiel-Calls
4.1 Eingangsrechnung als Draft anlegen
curl -X POST https://buchhaltung.kistudent.local/api/documents?company_id=1 \
-H "Authorization: Bearer $AKAUNTING_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "bill",
"document_number": "ACME-2026-0145",
"issued_at": "2026-05-20",
"due_at": "2026-06-19",
"contact_id": 42,
"currency_code": "CHF",
"items": [
{
"name": "Lieferung Kondensatoren EEU-FR1V",
"quantity": 100,
"price": 12.50,
"tax_ids": [3]
}
],
"status": "draft"
}'
Wichtig: tax_ids referenziert die MWST-Definition in Akaunting (z.B. ID 3 = "MWST 8.1 %"). IDs vorher aus /api/taxes abrufen.
4.2 Kontakt anlegen
curl -X POST https://buchhaltung.kistudent.local/api/contacts?company_id=1 \
-H "Authorization: Bearer $AKAUNTING_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "vendor",
"name": "ACME Ltd.",
"email": "rechnung@acme.com",
"currency_code": "CHF",
"country": "CH"
}'
4.3 Beleg von Draft auf Approved setzen
curl -X PATCH https://buchhaltung.kistudent.local/api/documents/789?company_id=1 \
-H "Authorization: Bearer $AKAUNTING_TOKEN" \
-H "Content-Type: application/json" \
-d '{"status": "received"}'
4.4 Zahlung erfassen
curl -X POST https://buchhaltung.kistudent.local/api/transactions?company_id=1 \
-H "Authorization: Bearer $AKAUNTING_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "expense",
"paid_at": "2026-05-25",
"amount": 1252.50,
"currency_code": "CHF",
"document_id": 789,
"account_id": 1,
"contact_id": 42,
"category_id": 7,
"payment_method": "offline-payments.bank_transfer.1"
}'
5. Pattern: Paperless → KI-Extraktion → Akaunting-Draft
- Paperless erkennt neue Rechnung
- n8n-Workflow holt Volltext
- LLM extrahiert strukturiertes JSON (Lieferant, Datum, Beträge)
- Falls Lieferant unbekannt:
/api/contactsPOST - Beleg anlegen via
/api/documentsals Draft - Slack-Notification "Neue Rechnung zur Freigabe"
- Manuelle Prüfung im Akaunting-UI → "Approved" setzen
6. Schweizer Spezifika
| Thema | Hinweis |
|---|---|
| MWST-Sätze | 8.1 % / 2.6 % / 3.8 % / 0 % – als Tax in Akaunting anlegen (siehe Block 2) |
| Währung | CHF mit Apostroph-Tausender; Akaunting-Format anpassen |
| Buchungsbeleg-Format | OR-konform; Aufbewahrung 10 Jahre |
| QR-Rechnung | Out-of-the-Box nicht enthalten; via Modul oder n8n + swiss-qr-bill nachrüsten |
7. Häufige Fehler
| HTTP/Symptom | Ursache | Lösung |
|---|---|---|
| 401 | Token fehlt / falsch | Im Profile-Bereich neuen Token erzeugen |
| 422 | Validierungsfehler (z.B. tax_ids leer) | Response-Body lesen – Akaunting nennt das fehlende Feld |
| 404 trotz richtiger ID | ?company_id=1 vergessen |
Bei Multi-Mandanten-Setup immer setzen |
| 500 | Backend-Fehler | docker logs akaunting ansehen |
| MWST-Wert in PDF falsch | Tax-Type Inclusive/Exclusive | Im Beleg / Settings prüfen |
8. Daten-Synchronisation Akaunting ↔ KI-CRM
Wenn Akaunting nicht das Master-System ist (das ist im Exista-Setup das ERP), genügt eine Read-only-Spiegelung:
- n8n-Workflow zieht 1× täglich neue Akaunting-Belege via API
- Schreibt sie als Read-only-Records ins KI-CRM (Tabelle "akaunting_belege")
- KI-CRM zeigt sie in der Firma-Detail-Ansicht an, ohne Schreibrechte
9. Sicherheit
- Token nur mit minimalem Scope verteilen
- Backup verschlüsselt – Buchhaltungsdaten sind besonders sensibel
- Audit-Trail in Akaunting aktivieren
- Pro Workflow eigenen Token (revocable bei Bedarf)
10. Checkliste
- ☐ Personal Access Token erzeugt, in Vaultwarden
- ☐ Test-Calls (GET companies, GET taxes) erfolgreich
- ☐ Tax-IDs für CH-MWST aus API geholt & dokumentiert
- ☐ n8n-Workflow für Paperless-Draft-Erzeugung läuft
- ☐ Read-only-Spiegelung ins KI-CRM (falls gewünscht) eingerichtet
- ☐ Fehler-Handling & Slack-Notifications aktiv
- ☐ Audit-Trail aktiviert
Querverweise: Akaunting (Block 2) | Paperless ↔ n8n
No comments to display
No comments to display