Skip to content

Validate PDF

Validate an existing PDF file for ZUGFeRD/Factur-X compliance.

Endpoint

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

Headers

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

Request Body

json
{
  "pdf_base64": "JVBERi0xLjcK..."
}

Parameters

FieldTypeRequiredDescription
pdf_base64stringYesBase64-encoded PDF file

Response

Valid PDF (200)

json
{
  "valid": true,
  "profile": "EN16931",
  "version": "2.3.2",
  "errors": [],
  "warnings": [],
  "invoice": {
    "number": "2026-001",
    "date": "2026-01-15",
    "seller": {
      "name": "Acme GmbH"
    },
    "buyer": {
      "name": "Customer AG"
    },
    "total": {
      "net": 1200.00,
      "vat": 228.00,
      "gross": 1428.00
    }
  }
}

Invalid PDF (200)

json
{
  "valid": false,
  "errors": [
    {
      "code": "BR-02",
      "path": "$.invoice.seller.vatId",
      "message": "Seller VAT identifier is required"
    },
    {
      "code": "BR-CL-23",
      "path": "$.invoice.items[0].unit",
      "message": "Unit code must be from UN/ECE Recommendation 20"
    }
  ],
  "warnings": [
    {
      "code": "BR-CL-10",
      "message": "Currency code should be from ISO 4217"
    }
  ]
}

Not a ZUGFeRD PDF (400)

json
{
  "error": "not_zugferd",
  "message": "PDF does not contain ZUGFeRD/Factur-X XML data"
}

Validation Rules

The validator checks for compliance with:

  • ZUGFeRD 2.3 - German e-invoice standard
  • Factur-X 1.0 - French e-invoice standard
  • EN 16931 - European e-invoice standard

Error Codes

CodeDescription
BR-01Invoice must have an invoice number
BR-02Invoice must have seller VAT ID
BR-03Invoice must have a buyer
BR-CO-09VAT identifier format invalid
BR-CL-10Invalid currency code
BR-CL-23Invalid unit code

See Error Codes for the complete list.

Example

Validate a PDF file

bash
# Read PDF, base64 encode, and validate
PDF_BASE64=$(base64 -i invoice.pdf)

curl -X POST https://api.thelawin.dev/v1/validate \
  -H "X-API-Key: env_sandbox_xxx" \
  -H "Content-Type: application/json" \
  -d "{\"pdf_base64\": \"$PDF_BASE64\"}"

Using JavaScript

javascript
const fs = require('fs')

const pdfBuffer = fs.readFileSync('invoice.pdf')
const pdfBase64 = pdfBuffer.toString('base64')

const response = await fetch('https://api.thelawin.dev/v1/validate', {
  method: 'POST',
  headers: {
    'X-API-Key': 'env_sandbox_xxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ pdf_base64: pdfBase64 })
})

const result = await response.json()
console.log(result.valid ? 'Valid!' : 'Invalid')

Notes

  • Validation does not count against your quota for sandbox keys
  • The invoice field in the response contains extracted invoice data
  • Both ZUGFeRD and Factur-X formats are supported

ZUGFeRD 2.3 & Factur-X 1.0 compliant