API v1XRechnung 3.0EN 16931

Developer docs

Rechnly works without writing code: connect Stripe, fill in the company form, done. The API and webhooks are for teams that want invoice status inside their own systems.

Base URL
http://localhost:3000/api/v1
On this page

How it works

  1. You connect Stripe with a restricted key that can only read invoices, customers, credit notes, tax rates and events. Every minute or two Rechnly asks Stripe what is new. For each finalized invoice or issued credit note it reads the document, combines it with your company details and builds an XRechnung 3.0 file (UBL syntax, EN 16931).
  2. The file is validated before anything is sent. If it passes, your customer receives an e-mail with the XML attached and Stripe's PDF as a readable copy. If it fails, nothing is sent and the invoice shows up as “needs fixing” with instructions.
  3. When you correct the customer in Stripe, Rechnly notices and re-checks the invoices that were waiting for that customer. A sent e-invoice is never changed.

What Rechnly reads from Stripe

In StripeHow it is used
Invoice number, dates, currency, totalsTaken as they are. The e-invoice total always equals Stripe's total; otherwise the invoice is held.
Customer name, address, e-mailFrom the invoice; missing fields fall back to the customer record. The e-mail address is where the e-invoice goes.
Customer tax IDsThe EU VAT ID (type eu_vat) becomes the buyer's VAT ID.
Line items, discounts, taxEach line needs exactly one tax rate, or you are marked as a small business (§ 19 UStG). Discounts become line allowances.
Collection method“Send invoice” invoices show your IBAN and the due date. Automatically charged invoices state that the stored payment method is charged, and show no bank details.
Custom field “Buyer reference” or “Leitweg-ID”Optional. Becomes the buyer reference (BT-10). Otherwise the Stripe customer ID is used.
Custom field “PO number” / “Bestellnummer”Optional. Becomes the order reference (BT-13).
Note. Invoices to customers whose billing country is not Germany are skipped: the German obligation covers domestic business customers only.

Test mode

Every account has a test mode, switched at the top of the dashboard. In test mode you can create sample invoices that run through the real pipeline, or connect a Stripe test-mode account.

Test mode never e-mails a real person. Messages are captured and shown on the invoice page. An address containing “bounce” is reported as bounced, so you can try that path too.

Test API keys start with rk_test_ and only see test data. They are free on every plan.

API

Authentication

Create a key under Settings → API keys and send it as a Bearer token. Live keys (rk_live_) need the Growth plan or higher.

Authorization
curl http://localhost:3000/api/v1/invoices?status=needs_fixing \
  -H "Authorization: Bearer rk_test_…"

Endpoints

GET/invoices

List invoices, newest first. Query: status, stripe_customer_id, limit (1–100), starting_after (an invoice id), locale (en|de).

GET/invoices/{id}

One invoice. {id} is a Rechnly id (inv_…) or the Stripe id (in_… / cn_…).

POST/invoices/{id}/resend

Send the archived e-invoice again to the customer's current e-mail address.

GET/invoices/{id}/xml

The e-invoice file as sent.

GET/invoices/{id}/pdf

The PDF copy as sent.

POST/validate

Validate any XRechnung or ZUGFeRD file. Send it as multipart field “file” or as the raw body.

curl
# List (returns { "object": "list", "has_more": false, "data": [ … ] })
curl "http://localhost:3000/api/v1/invoices?limit=20" -H "Authorization: Bearer rk_test_…"

# Re-send
curl -X POST http://localhost:3000/api/v1/invoices/inv_8sK2mQ4xYb7LwT1nR5cZ/resend \
  -H "Authorization: Bearer rk_test_…"

# Validate a file
curl http://localhost:3000/api/v1/validate -H "Authorization: Bearer rk_test_…" -F file=@invoice.xml

The invoice object

invoice.json
{
  "id": "inv_8sK2mQ4xYb7LwT1nR5cZ",
  "object": "invoice",
  "livemode": false,
  "kind": "invoice",
  "status": "needs_fixing",
  "hold_reason": null,
  "number": "RE-2026-0417",
  "stripe_id": "in_1QdX2nLkdIwHu7ixA1b2C3d4",
  "stripe_customer_id": "cus_QwErTy123456",
  "buyer": { "name": "Acme GmbH", "email": "rechnung@acme-gmbh.example" },
  "currency": "EUR",
  "total": 29155,
  "issued_at": 1795000000,
  "problems": [
    {
      "rule": "RY-BUYER-VAT-ID",
      "field": "BT-48",
      "message": "Customer Acme GmbH has no VAT ID.",
      "how_to_fix": "Add it in Stripe → Customers → Acme GmbH → Tax IDs. …"
    }
  ],
  "sent_to": null,
  "sent_at": null,
  "delivered_at": null,
  "bounced_at": null,
  "xml_sha256": null,
  "download_url": null,
  "created_at": 1795000004
}

Statuses

received

Picked up from Stripe. If hold_reason is set, it is waiting (quota, plan, incomplete company details or a temporary error).

needs_fixing

Validation found problems. Nothing was sent. See problems[] for what to change.

sent

Handed to the buyer's mail server.

delivered

The buyer's mail server confirmed receipt.

bounced

The buyer's mail server rejected the message.

skipped

Out of scope (buyer outside Germany, or voided before sending).

Webhooks

Add an endpoint under Settings → Webhooks. Rechnly sends a POST with a JSON body for each of these events:

  • invoice.received
  • invoice.needs_fixing
  • invoice.sent
  • invoice.delivered
  • invoice.bounced
POST · event.json
{
  "id": "evt_Jq1x…",
  "object": "event",
  "type": "invoice.delivered",
  "created": 1795000123,
  "livemode": true,
  "data": { "invoice": { "id": "inv_…", "status": "delivered", … } }
}

Respond with any 2xx status within 10 seconds. Failed deliveries are retried up to 8 times over about a day. Events can arrive more than once or out of order; use the event id to de-duplicate and read the invoice's current status from data.invoice.

Verifying signatures

Each request carries a Rechnly-Signature header: t is a Unix timestamp, v1 is the HMAC-SHA256 of “{t}.{raw body}” with your endpoint's signing secret, in hex. Reject requests with an old timestamp.

Header
Rechnly-Signature: t=1795000123,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
verify.js
import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(rawBody, header, secret) {
  const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false; // too old
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  return v1.length === expected.length && timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
}

Errors and limits

Errors use standard HTTP status codes and a JSON body with error.code and error.message.

The limit is 300 requests per minute per key. Uploaded files may be up to 10 MB.

409 Conflict
HTTP/1.1 409 Conflict
{ "error": { "code": "not_sent", "message": "Only invoices that were already sent can be re-sent. …" } }

Stripe events used: invoice.finalized, invoice.voided, credit_note.created, customer.updated, customer.tax_id.created, customer.tax_id.updated, customer.tax_id.deleted, account.application.deauthorized.