invoice data extraction api
Automate Invoice Data Extraction
One endpoint. POST a PDF, get complete Markdown back — simple tables as GFM, and complex table structure preserved as sanitized HTML when GFM would be lossy.
Server-side PDF processing. Review privacy, security, and data retention.
Start with a bounded conversion batch
The Python local-file recipe converts up to five selected PDFs sequentially and preserves the original input, options and identity for recovery. It saves Markdown, not structured invoice records. Use the table workflow for simple rows, then validate the business fields separately.
Convert invoices, then validate business fields
The API returns invoice content as Markdown. Extracting vendor details, dates, totals and line items into a business schema is your application’s next step.
Inspect a real conversion
The Contoso invoice capture pairs a source PDF with complete Mistral OCR 4.1 output dated 10 September 2026. It includes simple GFM and a complex HTML table; fabricated sample values are not evidence of extraction accuracy.
Validate before export
Preserve currency, signs, tax rates and decimal precision. Reconcile line totals, subtotal, tax and final amount using decimal arithmetic. Missing or ambiguous fields need review; neither regex nor an LLM guarantees correctness.
Separate conversion from accounting
Save an immutable source and conversion identity. Deduplicate invoices using your business rules before creating an accounting record. Test any accounting integration against its own schema and authorization requirements; the conversion API does not create bills.
Automate deliberately
Wait for a file to finish writing before enqueueing it. Retain recoverable failures and apply documented rate-limit guidance. The Python invoice workflow covers these boundaries.
Convert a document
Use the tested Python, JavaScript or curl workflow. Choose one input: a public PDF URL, Base64 bytes, or a raw PDF upload. Raw uploads avoid Base64 expansion; all three send the document to an external processor.
See the API reference for authentication, limits and recovery.
Optional API demo: invoice PDF to Markdown
Bash, curl and Python 3. This demo script validates success before printing Markdown.
#!/usr/bin/env bash
set -euo pipefail
key=demo_public_key
identity=demo-example
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
result=$work/result
status=$(curl --silent --show-error --max-time 660 -o "$result" -w '%{http_code}' \
"https://pdftomarkdown.dev/v1/convert" \
-H "Authorization: Bearer $key" -H "Idempotency-Key: $identity" \
-H "Content-Type: application/json" \
--data '{"input":{"pdf_url":"https://pdftomarkdown.dev/samples/invoice.pdf"}}')
if [ "$status" != 200 ]; then echo "HTTP $status; keep the identity for recovery" >&2; exit 1; fi
python3 - "$result" <<'PY'
import json, sys
with open(sys.argv[1]) as response:
result = json.load(response)
if not (isinstance(result, dict) and result.get("complete") is True
and isinstance(result.get("markdown"), str)
and type(result.get("pages")) is int and result["pages"] >= 0
and isinstance(result.get("request_id"), str) and result["request_id"].strip()):
sys.exit("Incomplete or invalid conversion response")
sys.stdout.write(result["markdown"])
PY{
"complete": true,
"markdown": "# CONTOSO LTD.\n\n# INVOICE\n\nContoso Headquarters\n\n123 456th St\n\nNew York, NY, 10001\n\nINVOICE: INV-100\n\nDATE: 11/15/2019\n\nDUE DATE: 12/15/2019\n\nCUSTOMER NAME: MICROSOFT CORPORATION\n\nCUSTOMER ID: CID-12345\n\nMicrosoft Corp\n\n123 Other St,\n\nRedmond WA, 98052\n\nBILL TO:\n\nMicrosoft Finance\n\n123 Bill St,\n\nRedmond WA, 98052\n\nSHIP TO:\n\nMicrosoft Delivery\n\n123 Ship St,\n\nRedmond WA, 98052\n\nSERVICE ADDRESS:\n\nMicrosoft Services\n\n123 Service St,\n\nRedmond WA, 98052\n\n| SALESPERSON | P.O. NUMBER | REQUISITIONER | SHIPPED VIA | F.O.B. POINT | TERMS |\n| --- | --- | --- | --- | --- | --- |\n| | PO-3333 | | | | |\n\n<table><tr><th>QUANTITY</th><th>DESCRIPTION</th><th>UNIT PRICE</th><th>TOTAL</th></tr><tr><td>1</td><td>Test for 23 fields</td><td>1</td><td>$100.00</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td colspan=\"3\">SUBTOTAL</td><td>$100.00</td></tr><tr><td colspan=\"3\">SALES TAX</td><td>$10.00</td></tr><tr><td colspan=\"3\">TOTAL</td><td>$110.00</td></tr><tr><td colspan=\"3\">PREVIOUS BALANCE</td><td>$500.00</td></tr><tr><td colspan=\"3\">TOTAL DUE</td><td>$610.00</td></tr></table>\n\nTHANK YOU FOR YOUR BUSINESS!\n\nREMIT TO:\n\nContoso Billing\n\n123 Remit St\n\nNew York, NY, 10001\n\n> Processed by pdfToMarkdown.dev",
"pages": 1,
"request_id": "req_example_invoice"
}Pricing
Try page 1 free, or get 20 trial pages once with a new account. Then choose paid credits. Monthly pages expire; top-ups do not.