REST API for developers
Webhooks for invoice events
Events, data, signature and delivery of the account webhooks.
Contents
Setup and messages
Instead of polling the API, your system can be notified of invoice events. Set up to 5 HTTPS endpoints in your account under Webhooks and choose the events for each endpoint. Webhooks are included from the Pro plan.
invoice.exported: Invoice created (ZUGFeRD PDF or XRechnung exported)invoice.paid: Invoice paidinvoice.overdue: Invoice overdueincoming_invoice.imported: Incoming invoice imported and checked
Each message is a POST request with a JSON body. It contains only IDs, the event, the status and a timestamp, no invoice contents. managed_invoice_id is the ID used by /api/v1/managed-invoices/.
{
"id": "5f0c6c1e-3c1b-4c7e-9a43-0d6c2b7f1a2e",
"event": "invoice.paid",
"created_at": "2026-11-25T10:15:00.123456+00:00",
"data": {
"managed_invoice_id": 1234,
"invoice_id": "b3a9e2d4-7f61-4f0e-8a51-2c4d9e0f6a77",
"direction": "outgoing",
"status": "paid"
}
}
The body always has the fields id (ID of the message), event, created_at (time of the event, ISO 8601) and data. For invoice events, data contains the invoice fields managed_invoice_id (number), invoice_id (UUID of the invoice), direction and status (status of the invoice at the time of the event).
Events and their data
invoice.exported – Invoice created (ZUGFeRD PDF or XRechnung exported): Sent when a ZUGFeRD PDF or an XRechnung of an outgoing invoice was created and the check found no errors. data contains the invoice fields and valid (true or null).
{
"managed_invoice_id": 1234,
"invoice_id": "b3a9e2d4-7f61-4f0e-8a51-2c4d9e0f6a77",
"direction": "outgoing",
"status": "issued",
"valid": true
}
invoice.paid – Invoice paid: Sent when the status of an invoice changes to paid, for outgoing and incoming invoices. data contains the invoice fields.
{
"managed_invoice_id": 1234,
"invoice_id": "b3a9e2d4-7f61-4f0e-8a51-2c4d9e0f6a77",
"direction": "outgoing",
"status": "paid"
}
invoice.overdue – Invoice overdue: Sent when the status of an invoice changes to overdue, for outgoing and incoming invoices. data contains the invoice fields.
{
"managed_invoice_id": 1234,
"invoice_id": "b3a9e2d4-7f61-4f0e-8a51-2c4d9e0f6a77",
"direction": "outgoing",
"status": "overdue"
}
incoming_invoice.imported – Incoming invoice imported and checked: Sent when an incoming invoice was imported and checked. data contains the invoice fields and valid (true, false or null).
{
"managed_invoice_id": 1234,
"invoice_id": "b3a9e2d4-7f61-4f0e-8a51-2c4d9e0f6a77",
"direction": "incoming",
"status": "received",
"valid": false
}
webhook.test – Test event: Sent only with the button “Send test event” of an endpoint in your account; it cannot be chosen as an event. data contains only endpoint_id, the ID of the endpoint, and no managed_invoice_id.
{
"endpoint_id": 42
}
valid is the overall result of the check made at the export or import: true = no errors found, false = errors found, null = no overall result available. invoice.exported is not sent when the check found errors, so it contains only true or null.
Values of direction:
incoming: Incomingoutgoing: Outgoing
Values of status:
draft: Draftissued: Issuedpartially_paid: Partially paidpaid: Paidoverdue: Overduecancelled: Cancelledreceived: Receivedin_review: In reviewapproved: Approveddisputed: Disputed
Headers
Each request contains these headers:
Content-Type: Alwaysapplication/json; the body is JSON in UTF-8.User-Agent: AlwaysWebhooks/1.0.Webhook-Id: ID of the message, the same asidin the body. It stays the same for every attempt of the same message.Webhook-Event: The event, the same aseventin the body.Webhook-Timestamp: Time of this attempt as Unix time in seconds. It is new for every attempt.Webhook-Signature:v1=followed by the HMAC-SHA256 signature as a hexadecimal string.
Verifying the signature
Verify every message: compute HMAC-SHA256 with the signing secret of the endpoint over the value of the header Webhook-Timestamp, a dot and the raw request body, and compare it with the value after v1= in the header Webhook-Signature. Reject messages whose timestamp is more than five minutes old (replay protection). Use Webhook-Id to ignore duplicates.
import hashlib
import hmac
import time
SECRET = "whsec_..." # signing secret of the endpoint
def verify(headers, raw_body: bytes) -> bool:
timestamp = headers["Webhook-Timestamp"]
if abs(time.time() - int(timestamp)) > 300:
return False # too old: possible replay
expected = hmac.new(SECRET.encode(), timestamp.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
received = headers["Webhook-Signature"].removeprefix("v1=")
return hmac.compare_digest(expected, received)
A complete receiver in Python (Flask) and Node.js (Express) with duplicate detection and a local test: Guide: webhooks.
Delivery and retries
Answer with an HTTP status 2xx within 10 seconds. Otherwise the attempt counts as failed and the delivery is attempted up to 6 times in total. Redirects are not followed, and only public addresses are delivered to. The delivery log of each endpoint shows the result.
Waiting time before the next attempt, after each failed attempt:
- 1 minute
- 5 minutes
- 30 minutes
- 2 hours
- 12 hours
Notes for your receiver
- Answer quickly with 2xx and process the message afterwards, for example in a queue. The time limit of 10 seconds applies to the whole attempt.
- The same message can arrive more than once, for example when your answer did not arrive in time. Recognise duplicates by
Webhook-Id. - Messages can arrive in a different order than the events occurred, because every message is delivered and retried on its own. Use
created_ator retrieve the current state via the API. - Ignore events you do not know and additional fields in the body or in
data.
Next step: retrieve the invoice with managed_invoice_id from data. The answer contains the status, the export and payment states, the payments and the audit log.
curl "https://www.e-rechnungsfreund.de/api/v1/managed-invoices/$MANAGED_INVOICE_ID/" \
-H "Authorization: Api-Key $API_KEY"
Example response: GET /api/v1/managed-invoices/{id}/ → 200 OK
{
"id": 1234,
"invoice_id": "b3a9e2d4-7f61-4f0e-8a51-2c4d9e0f6a77",
"invoice_number": "RE-2026-001",
"buyer_name": "Käufer AG",
"seller_name": "Muster GmbH",
"direction": "outgoing",
"issue_date": "2026-10-01",
"payment_due_date": null,
"due_payable_amount": "904.4000",
"paid_amount": "904.40",
"open_amount": "0.00",
"status": "paid",
"export_status": "ready",
"source_file": null,
"is_overdue": false,
"issued_at": null,
"sent_at": null,
"paid_at": "2026-11-25T10:15:00.000000Z",
"updated_at": "2026-11-25T10:15:00.000000Z",
"payments": [
{
"id": 1,
"amount": "904.40",
"payment_date": "2026-11-25",
"method": "",
"reference": "",
"note": "",
"created_at": "2026-11-25T10:15:00.000000Z"
}
],
"audit_logs": [
{
"id": 2,
"action": "status_changed",
"actor_display": "Max Mustermann",
"old_value": {
"status": "issued"
},
"new_value": {
"status": "paid"
},
"created_at": "2026-11-25T10:15:00.000000Z"
},
{
"id": 1,
"action": "payment_added",
"actor_display": "Max Mustermann",
"old_value": null,
"new_value": {
"note": "",
"amount": "904.40",
"method": "",
"reference": "",
"payment_id": 1,
"payment_date": "2026-11-25"
},
"created_at": "2026-11-25T10:15:00.000000Z"
}
],
"validation_checks": [
{
"id": 1,
"checked_at": "2026-10-01T09:30:00.000000Z",
"source": "export",
"is_valid": true,
"format": "ZUGFERD_CII",
"profile": "EN16931",
"rule_sets": {
"kosit": "xrechnung-3.0.2-validator-configuration-2026-08-31",
"mustang": "Mustang 2.26.0",
"saxon": "Factur-X 1.09.2 / ZUGFeRD 2.5"
}
}
]
}