Validate PDF
Validate an existing PDF file for ZUGFeRD/Factur-X compliance.
Endpoint
POST https://api.thelawin.dev/v1/validateHeaders
| Header | Required | Description |
|---|---|---|
X-API-Key | Yes | Your API key |
Content-Type | Yes | application/json |
Request Body
json
{
"pdf_base64": "JVBERi0xLjcK..."
}Parameters
| Field | Type | Required | Description |
|---|---|---|---|
pdf_base64 | string | Yes | Base64-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
| Code | Description |
|---|---|
BR-01 | Invoice must have an invoice number |
BR-02 | Invoice must have seller VAT ID |
BR-03 | Invoice must have a buyer |
BR-CO-09 | VAT identifier format invalid |
BR-CL-10 | Invalid currency code |
BR-CL-23 | Invalid 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
invoicefield in the response contains extracted invoice data - Both ZUGFeRD and Factur-X formats are supported