Skip to content

lexoffice Integration

Combine lexoffice for accounting with thelawin.dev for e-invoice generation. lexoffice manages contacts and bookkeeping, thelawin.dev produces ZUGFeRD/XRechnung-compliant PDFs.

Use Case

lexoffice has its own invoicing feature, but:

  • No ZUGFeRD 2.4 with full EN16931 profile
  • No XRechnung export for B2G (Leitweg-ID)
  • No API-first generation for automation

thelawin.dev fills these gaps.

Workflow: lexoffice → thelawin.dev

lexoffice API → Fetch contact and invoice data
    → Build JSON for thelawin.dev
    → POST api.thelawin.dev/v1/generate
    → Send ZUGFeRD PDF to customer
    → Optionally: post receipt back to lexoffice

Example: Contact from lexoffice → Invoice

python
import httpx
from thelawin import ThelawinClient

LEXOFFICE_TOKEN = "your-lexoffice-api-token"

# 1. Load contact from lexoffice
contact = httpx.get(
    f"https://api.lexoffice.io/v1/contacts/{contact_id}",
    headers={"Authorization": f"Bearer {LEXOFFICE_TOKEN}"}
).json()

company = contact.get("company", {})
address = company.get("contactAddresses", [{}])[0]

# 2. Generate invoice with thelawin.dev
client = ThelawinClient("env_sandbox_demo")

result = (
    client.invoice()
    .number("RE-2026-042")
    .date("2026-01-15")
    .format("zugferd")
    .profile("en16931")
    .seller("Deine Firma GmbH", vat_id="DE123456789", city="Berlin", country="DE")
    .buyer(
        company.get("name", "Kunde"),
        street=address.get("street"),
        city=address.get("city"),
        postal_code=address.get("zip"),
        country=address.get("countryCode", "DE"),
    )
    .add_item("Dienstleistung", quantity=10, unit_price=120, unit="HUR")
    .payment(iban="DE89370400440532013000", terms="14 Tage netto")
    .generate()
)

if result.success:
    result.save_pdf(f"rechnungen/{result.filename}")

Alternative: n8n as Middleware

Connect lexoffice and thelawin.dev without writing code:

  1. Schedule Trigger -- Check daily for new invoices
  2. HTTP Request | lexoffice API: fetch open orders
  3. HTTP Request | thelawin.dev: generate ZUGFeRD PDF
  4. Email | Send PDF to customer

See the n8n Guide for details.

Next Steps

ZUGFeRD 2.4 & Factur-X 1.0.8 compliant