Skip to content

Generate Invoice

Generate EU-compliant electronic invoices in 9 different formats conforming to EN 16931.

Endpoint

POST https://api.thelawin.dev/v1/generate

Supported Formats

FormatOutputDescription
autoVariesAuto-detect best format
zugferdPDF + XMLZUGFeRD 2.3 (Germany)
facturxPDF + XMLFactur-X 1.0 (France)
xrechnungPDF + XMLXRechnung 3.0 (German B2G)
ublXMLUBL 2.1 (OASIS standard)
ciiXMLUN/CEFACT CII
peppolXMLPeppol BIS Billing 3.0
fatturapaXMLFatturaPA (Italy)
pdfPDFPlain PDF (no XML)

See Invoice Formats for detailed information.

Headers

HeaderRequiredDescription
X-API-KeyYesYour API key
Content-TypeYesapplication/json

Request Body

json
{
  "template": "minimal",
  "locale": "en",
  "customization": {
    "accent_color": "#8b5cf6",
    "footer_text": "Thank you for your business!"
  },
  "invoice": {
    "number": "2026-001",
    "date": "2026-01-15",
    "due_date": "2026-02-15",
    "currency": "EUR",
    "notes": "Project Alpha Q1",
    "seller": {
      "name": "Acme GmbH",
      "vat_id": "DE123456789",
      "street": "Hauptstraße 1",
      "city": "Berlin",
      "postal_code": "10115",
      "country": "DE",
      "email": "billing@acme.de",
      "phone": "+49 30 12345678"
    },
    "buyer": {
      "name": "Customer AG",
      "street": "Kundenweg 42",
      "city": "München",
      "postal_code": "80331",
      "country": "DE"
    },
    "items": [
      {
        "description": "Consulting Services",
        "quantity": 8,
        "unit": "HUR",
        "unit_price": 150.00,
        "vat_rate": 19.0
      }
    ],
    "payment": {
      "iban": "DE89 3704 0044 0532 0130 00",
      "bic": "COBADEFFXXX",
      "terms": "Net 30 days"
    }
  }
}

Parameters

Root Level

FieldTypeRequiredDescription
formatstringNoInvoice format (see above). Default: auto
profilestringNominimum, basic_wl, basic, en16931, extended. Default: en16931
templatestringNominimal, classic, or compact. Default: minimal
localestringNoen, de, fr, es, it. Default: en
customizationobjectNoPDF customization options
invoiceobjectYesInvoice data

Customization

FieldTypeRequiredDescription
logo_base64stringNoBase64-encoded image (PNG, JPEG, SVG)
logo_width_mmnumberNoLogo width in mm. Default: 40
footer_textstringNoCustom footer text
accent_colorstringNoHex color code. Default: #8b5cf6

Invoice Object

FieldTypeRequiredEN 16931Description
numberstringYesBT-1Invoice number
datestringYesBT-2Invoice date (YYYY-MM-DD)
due_datestringNoBT-9Due date (YYYY-MM-DD)
currencystringNoBT-5ISO 4217 code. Default: EUR
notesstringNoBT-22Invoice note / project reference
sellerobjectYesBG-4Seller information
buyerobjectYesBG-7Buyer information
itemsarrayYesBG-25Line items (min 1)
paymentobjectNoBG-16Payment information
leitweg_idstringNo-XRechnung: German routing ID
buyer_referencestringNoBT-10Peppol: Purchase order reference
tipo_documentostringNo-FatturaPA: IT document type (TD01, TD04)

Invoice Number

The invoice number (BT-1) must be unique and is used as the primary identifier.

Invoice Date

The invoice date (BT-2) in ISO 8601 format: YYYY-MM-DD

Due Date

The payment due date (BT-9) in ISO 8601 format: YYYY-MM-DD

Currency

ISO 4217 currency code (BT-5). Supported: EUR, USD, GBP, CHF, etc.

Address Object (Seller/Buyer)

FieldTypeRequiredEN 16931Description
namestringYesBT-27/BT-44Legal name
vat_idstringSeller: YesBT-31/BT-48VAT identification number
streetstringNoBT-35/BT-50Street address
citystringNoBT-37/BT-52City
postal_codestringNoBT-38/BT-53Postal code
countrystringNoBT-40/BT-55ISO 3166-1 alpha-2 code. Default: DE
emailstringNoBT-43/BT-58Email address
phonestringNoBT-42/BT-57Phone number
peppol_idstringNo-Peppol: Participant ID (e.g., 0088:123...)
codice_fiscalestringNo-FatturaPA: Italian tax code (11/16 chars)
codice_destinatariostringNo-FatturaPA: SDI recipient code (7 chars)
pecstringNo-FatturaPA: IT certified email

Line Item Object

FieldTypeRequiredEN 16931Description
descriptionstringYesBT-153Item description
quantitynumberYesBT-129Quantity
unitstringNoBT-130Unit code (UN/ECE Rec 20). Default: C62
unit_pricenumberYesBT-146Net price per unit
vat_ratenumberNoBT-152VAT rate (e.g., 19.0 for 19%). Default: 19.0
naturastringNo-FatturaPA: IT VAT exemption code (N1-N7)

Payment Object

FieldTypeRequiredEN 16931Description
ibanstringNoBT-84IBAN
bicstringNoBT-86BIC/SWIFT code
termsstringNoBT-20Payment terms description

Response

Success (200)

json
{
  "pdf_base64": "JVBERi0xLjcK...",
  "filename": "invoice-2026-001.pdf",
  "validation": {
    "status": "valid",
    "profile": "EN16931",
    "version": "2.3"
  },
  "account": {
    "remaining": 499,
    "plan": "starter",
    "overage_count": 0,
    "overage_allowed": 0
  }
}

Error (400/422)

json
{
  "error": "validation_failed",
  "message": "Invoice validation failed",
  "details": [
    {
      "path": "$.invoice.seller.vat_id",
      "code": "REQUIRED",
      "message": "Seller VAT ID is required",
      "expected": "string (e.g. DE123456789)"
    }
  ],
  "docs": "https://docs.thelawin.dev/api/generate.html#address-object"
}

Example

bash
curl -X POST https://api.thelawin.dev/v1/generate \
  -H "X-API-Key: env_sandbox_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "minimal",
    "invoice": {
      "number": "2026-001",
      "date": "2026-01-15",
      "seller": {
        "name": "Acme GmbH",
        "vat_id": "DE123456789",
        "city": "Berlin",
        "country": "DE"
      },
      "buyer": {
        "name": "Customer AG",
        "city": "München",
        "country": "DE"
      },
      "items": [{
        "description": "Consulting",
        "quantity": 8,
        "unit": "HUR",
        "unit_price": 150,
        "vat_rate": 19
      }]
    }
  }'

EN 16931 Compliance

This API generates invoices compliant with:

  • EN 16931 - European standard for electronic invoicing
  • ZUGFeRD 2.3 - German e-invoice standard (PDF/A-3 with embedded XML)
  • Factur-X 1.0 - French equivalent of ZUGFeRD

All generated PDFs include embedded XML metadata that can be extracted and processed automatically by accounting software.

ZUGFeRD 2.3 & Factur-X 1.0 compliant