Szybki start
Zwaliduj swoją pierwszą e-fakturę przez API w około pięć minut.
1. Załóż bezpłatne konto i klucz testowy
Zaloguj się na https://einvoiceengine.com/login swoim adresem e-mail. Otwórz Klucze API i utwórz klucz testowy. Zaczyna się od einv_test_ i jest pokazywany tylko raz — zapisz go w swoim menedżerze sekretów.
Klucze testowe uruchamiają prawdziwy silnik walidacji. Są bezpłatne, nigdy nie są rozliczane i są ograniczone do limitu sandbox Twojego planu.
export EINV_BASE=https://einvoiceengine.com
export EINV_KEY=einv_test_...
2. Zwaliduj fakturę
Wyślij XML jako treść żądania. Działa każdy dokument XRechnung 3.0 lub EN 16931 w UBL lub CII, a także PDF ZUGFeRD / Factur-X (Content-Type: application/pdf).
validate.sh
#!/usr/bin/env bash
# Validate an invoice with curl.
# EINV_BASE: API base URL (e.g. https://einvoicing.example.com); EINV_KEY: your API key.
set -euo pipefail
curl -sS --fail-with-body "$EINV_BASE/v1/invoices/validate" \
-H "Authorization: Bearer $EINV_KEY" \
-H "Content-Type: application/xml" \
--data-binary @"${1:-invoice.xml}"
Nie masz faktury pod ręką? Pobierz oficjalny przykład lub przykład z błędami.
Możesz też pozwolić, aby API przygotowało faktury testowe za Ciebie. POST /v1/testdata zwraca syntetyczne faktury we wskazanym formacie, poprawne oraz z typowymi błędami, każdą już sprawdzoną według oficjalnych reguł. Nie jest to rozliczane i nic nie jest zapisywane.
curl -X POST $EINV_BASE/v1/testdata \
-H "Authorization: Bearer $EINV_KEY" -H "Content-Type: application/json" \
-d '{ "target": "xrechnung-ubl" }'
Każdy przypadek ma name, filename, document, expected i actual. GET /v1/testdata/cases wyświetla listę przypadków i formatów docelowych.
3. Odczytaj wynik
{
"status": "invalid",
"valid": false,
"detected": { "format": "xrechnung-ubl", "syntax": "ubl", "profile": "XRechnung", "version": "3.0" },
"summary": { "errors": 2, "warnings": 0, "infos": 1 },
"findings": [
{
"severity": "error",
"ruleId": "BR-DE-15",
"message": "[BR-DE-15] Das Element \"Buyer reference\" (BT-10) muss übermittelt werden.",
"explanation": "XRechnung requires the buyer reference (BT-10). For German public buyers this is the Leitweg-ID.",
"suggestion": "Set cbc:BuyerReference (UBL) or ram:BuyerReference (CII) to the Leitweg-ID or reference supplied by the buyer.",
"location": { "path": "/Invoice", "line": 2, "column": 1 }
}
]
}
statusma wartośćvalid,invalidlubunsupported. Decydują o nim wyłącznie oficjalne zestawy reguł.messageto oficjalny tekst reguły, dosłownie.explanationisuggestionprzedstawiają go prostym językiem.- Wyniki są dostępne po angielsku, niemiecku, francusku, hiszpańsku, włosku, polsku, niderlandzku lub portugalsku: dodaj
?lang=de(luben,fr,es,it,pl,nl,pt) albo wyślijAccept-Language. Oficjalny tekst reguły pozostaje wmessage;messageTranslationdodaje nieoficjalne tłumaczenie, jeśli jest znane. coveragewymienia dokładnie, które zestawy reguł zostały uruchomione i czego nie sprawdzono.
4. To samo w TypeScript i Pythonie
validate.ts
// Validate an invoice with TypeScript (Node 20+, no dependencies).
// Run: EINV_BASE=… EINV_KEY=… npx tsx validate.ts invoice.xml
import { readFile } from "node:fs/promises";
const base = process.env.EINV_BASE!;
const key = process.env.EINV_KEY!;
const xml = await readFile(process.argv[2] ?? "invoice.xml");
const res = await fetch(`${base}/v1/invoices/validate`, {
method: "POST",
headers: { authorization: `Bearer ${key}`, "content-type": "application/xml" },
body: xml,
});
if (!res.ok) {
const { error } = await res.json();
throw new Error(`${error.code}: ${error.message} (request ${error.requestId})`);
}
const result = await res.json();
console.log(result.status, `${result.summary.errors} errors`);
for (const f of result.findings.filter((f: { severity: string }) => f.severity === "error")) {
console.log(`- ${f.ruleId}: ${f.explanation} (line ${f.location?.line ?? "?"})`);
}
validate.py
"""Validate an invoice with Python (standard library only).
Run: EINV_BASE=... EINV_KEY=... python3 validate.py invoice.xml
"""
import json
import os
import sys
import urllib.error
import urllib.request
base = os.environ["EINV_BASE"]
key = os.environ["EINV_KEY"]
path = sys.argv[1] if len(sys.argv) > 1 else "invoice.xml"
with open(path, "rb") as f:
body = f.read()
req = urllib.request.Request(
f"{base}/v1/invoices/validate",
data=body,
method="POST",
headers={"Authorization": f"Bearer {key}", "Content-Type": "application/xml"},
)
try:
with urllib.request.urlopen(req, timeout=60) as resp:
result = json.load(resp)
except urllib.error.HTTPError as e:
err = json.load(e)["error"]
sys.exit(f"{err['code']}: {err['message']} (request {err['requestId']})")
print(result["status"], f"{result['summary']['errors']} errors")
for f in result["findings"]:
if f["severity"] == "error":
line = (f.get("location") or {}).get("line", "?")
print(f"- {f['ruleId']}: {f['explanation']} (line {line})")
E-Invoicing API