AI Agents Integration
thelawin.dev works well with AI agents. The API is stateless and JSON-based, so any agent that can make HTTP requests can generate invoices.
3 Ways to Integrate
| Method | Best for | Setup |
|---|---|---|
| MCP Server | Claude Code, MCP-capable clients | Clone from GitHub |
| REST API + curl | Any agent with HTTP access | No setup, start immediately |
| SDKs | Agents in Python, TypeScript, etc. | Install SDK |
MCP Server (recommended for Claude)
The Model Context Protocol server gives Claude Code (and other MCP clients) two tools: thelawin_generate and thelawin_validate.
Installation
git clone https://github.com/steviee/thelawin.dev.git
cd thelawin.dev/mcp-server
npm install && npm run buildConfiguration for Claude Code
Add to your Claude Code MCP config:
{
"mcpServers": {
"thelawin": {
"command": "node",
"args": ["/path/to/thelawin.dev/mcp-server/dist/index.js"],
"env": {
"THELAWIN_API_KEY": "env_sandbox_demo"
}
}
}
}Without MCP Server
You can also use thelawin.dev without the MCP server, directly via REST API (curl) or SDKs.
Natural Language → Invoice
After setup, Claude Code can generate invoices from natural language:
"Create a ZUGFeRD invoice for 8 hours of consulting at 150 EUR from Acme GmbH to Customer AG"
Claude automatically uses the thelawin_generate tool and returns the PDF.
REST API with curl
Any agent that can execute HTTP requests can use thelawin.dev. The demo key env_sandbox_demo works immediately without an account.
Minimal Invoice
curl -s -X POST https://api.thelawin.dev/v1/generate \
-H "Content-Type: application/json" \
-H "X-API-Key: env_sandbox_demo" \
-d '{
"format": "zugferd",
"template": "minimal",
"invoice": {
"number": "RE-2026-001",
"date": "2026-01-15",
"seller": {"name": "Acme GmbH", "country": "DE", "vat_id": "DE123456789"},
"buyer": {"name": "Customer AG", "country": "DE"},
"items": [{"description": "Beratung", "quantity": 8, "unit": "HUR", "unit_price": 150}]
}
}'Save PDF
curl -s -X POST https://api.thelawin.dev/v1/generate \
-H "Content-Type: application/json" \
-H "X-API-Key: env_sandbox_demo" \
-d '{"invoice":{"number":"001","date":"2026-01-15","seller":{"name":"Test GmbH"},"buyer":{"name":"Kunde AG"},"items":[{"description":"Service","quantity":1,"unit_price":100}]}}' \
| jq -r '.pdf_base64' | base64 -d > rechnung.pdfPre-validation (free)
curl -s -X POST https://api.thelawin.dev/v1/validate \
-H "Content-Type: application/json" \
-H "X-API-Key: env_sandbox_demo" \
-d '{"format":"xrechnung","invoice":{"number":"XR-001","date":"2026-01-15","leitweg_id":"04011000-12345-67","seller":{"name":"GmbH","vat_id":"DE123"},"buyer":{"name":"Amt"},"items":[{"description":"Lizenz","quantity":1,"unit_price":1000}]}}' \
| jq '.valid, .format'Extract Data from PDF
PDF_BASE64=$(base64 < rechnung.pdf)
curl -s -X POST https://api.thelawin.dev/v1/retrieve \
-H "Content-Type: application/json" \
-H "X-API-Key: env_sandbox_demo" \
-d "{\"data_base64\": \"$PDF_BASE64\"}" \
| jq '.invoice'SDKs for Agent Frameworks
Python (LangChain, CrewAI, AutoGen)
from thelawin import ThelawinClient
client = ThelawinClient("env_sandbox_demo")
result = (
client.invoice()
.number("RE-2026-001")
.date("2026-01-15")
.format("zugferd")
.seller("Acme GmbH", vat_id="DE123456789", city="Berlin", country="DE")
.buyer("Customer AG", city="Muenchen", country="DE")
.add_item("Beratung", quantity=8, unit_price=150, unit="HUR")
.generate()
)
if result.success:
result.save_pdf("rechnung.pdf")pip install git+https://github.com/steviee/thelawin-clients.git#subdirectory=pythonTypeScript (Vercel AI SDK, LlamaIndex)
import { ThelawinClient } from '@thelawin/sdk';
const client = new ThelawinClient('env_sandbox_demo');
const result = await client.invoice()
.number('RE-2026-001')
.date('2026-01-15')
.format('zugferd')
.seller({ name: 'Acme GmbH', vatId: 'DE123456789', city: 'Berlin', country: 'DE' })
.buyer({ name: 'Customer AG', city: 'Munich', country: 'DE' })
.addItem({ description: 'Consulting', quantity: 8, unit: 'HUR', unitPrice: 150 })
.generate();npm install github:steviee/thelawin-clients#path:typescriptSupported Formats
| Format | Description | Region |
|---|---|---|
zugferd | PDF/A-3 + CII XML | Germany |
facturx | PDF/A-3 + CII XML | France |
xrechnung | PDF/A-3 + UBL XML | Germany B2G |
peppol | XML (UBL-based) | EU/international |
fatturapa | XML | Italy |
ubl | XML | OASIS standard |
cii | XML | UN/CEFACT |
pdf | Plain PDF | Universal |
auto | Auto-detect | EU |
API Key for Production
The demo key (env_sandbox_demo) adds a SANDBOX watermark. For production use:
- Sign up (free)
- Dashboard → API Keys → Create key
- Sandbox keys (
env_sandbox_*): 0 credits included, free (buy credit packs for clean PDFs) - Live keys (
env_live_*): From 9.50 EUR/month, no watermark
Next Steps
- MCP Server Docs | Detailed MCP documentation
- API Reference | Full request/response fields
- SDKs | All 8 official SDKs
- n8n Guide | Workflow automation with n8n