Invoice PNG Preview
Render a realistic image/png preview of an invoice.
Use this when an AI agent, chat UI, or browser client cannot display PDF directly. Use /v1/generate for the final compliant PDF/XML artifact.
Quick start (two steps)
Step 1 — Generate the invoice and save the transaction_id:
bash
TRANSACTION_ID=$(curl -s -X POST https://api.thelawin.dev/v1/generate \
-H "Content-Type: application/json" \
-H "X-API-Key: env_sandbox_demo_public" \
-d '{
"format": "zugferd",
"template": "minimal",
"invoice": {
"number": "RE-2026-001",
"date": "2026-01-15",
"seller": {
"name": "Acme GmbH",
"street": "Musterstr. 1",
"city": "Berlin",
"postal_code": "10115",
"country": "DE",
"vat_id": "DE123456789"
},
"buyer": {
"name": "Customer AG",
"street": "Kundenweg 5",
"city": "Munich",
"postal_code": "80331",
"country": "DE"
},
"items": [{
"description": "Consulting",
"quantity": 8,
"unit": "HUR",
"unit_price": 150.00,
"vat_rate": 19
}]
}
}' | jq -r '.transaction_id')
echo "Transaction ID: $TRANSACTION_ID"Step 2 — Fetch the PNG preview (no API key needed):
bash
curl -s "https://api.thelawin.dev/v1/preview/${TRANSACTION_ID}.png" -o preview.pngThe preview is available for 5 minutes after generation.
GET /v1/preview/{transaction_id}.png
Retrieve a cached invoice preview by transaction ID. No authentication required.
GET https://api.thelawin.dev/v1/preview/{transaction_id}.png| Parameter | In | Default | Description |
|---|---|---|---|
transaction_id | path | required | The transaction_id from /v1/generate response |
page | query | 1 | Page number to render |
dpi | query | 150 | Resolution (72-300) |
Example:
GET https://api.thelawin.dev/v1/preview/a1b2c3d4e5f67890.png?page=1&dpi=200POST /v1/preview
Alternative: render a preview from a transaction ID or invoice JSON body. Requires API key when sending invoice JSON (costs 1 credit).
POST https://api.thelawin.dev/v1/previewFrom transaction ID
bash
curl -s -X POST https://api.thelawin.dev/v1/preview \
-H "Content-Type: application/json" \
-d '{
"transaction_id": "a1b2c3d4e5f67890a1b2c3d4e5f67890",
"page": 1,
"dpi": 144
}' -o preview.pngFrom invoice JSON (costs 1 credit)
bash
curl -s -X POST https://api.thelawin.dev/v1/preview \
-H "Content-Type: application/json" \
-H "X-API-Key: env_sandbox_demo_public" \
-d '{
"template": "minimal",
"page": 1,
"dpi": 144,
"invoice": {
"number": "RE-2026-001",
"date": "2026-01-15",
"seller": {
"name": "Acme GmbH",
"street": "Musterstr. 1",
"city": "Berlin",
"postal_code": "10115",
"country": "DE",
"vat_id": "DE123456789"
},
"buyer": {
"name": "Customer AG",
"street": "Kundenweg 5",
"city": "Munich",
"postal_code": "80331",
"country": "DE"
},
"items": [{
"description": "Consulting",
"quantity": 8,
"unit": "HUR",
"unit_price": 150.00,
"vat_rate": 19
}]
}
}' -o preview.pngResponse
The response body is the PNG image directly.
Content-Type: image/png
X-Transaction-Id: a1b2c3d4e5f67890a1b2c3d4e5f67890
X-Preview-Source: cache
X-Preview-Width: 1191
X-Preview-Height: 1684PNG previews are cached for 5 minutes after generation.