{"slug": "extracting-structured-data-from-invoices-and-contracts-with-one-api-call", "title": "Extracting structured data from invoices and contracts with one API call", "summary": "Mediavox released a document analysis API that extracts structured data from invoices, contracts, and receipts in a single call, supporting Spanish and Portuguese. The multimodal AI endpoint handles scanned PDFs, Word files, and phone photos, returning entities like vendor name, tax ID, and totals with confidence scores. A session feature allows follow-up questions without re-uploading, and an integrity check automatically verifies arithmetic consistency.", "body_md": "I've been working on a document analysis API and wanted to share a pattern that saved me from writing custom parsers for every document type my clients throw at me.\n\nIf you work with LATAM businesses, you know the pain: invoices in PDF (sometimes scanned), contracts in Word, receipts as phone photos. Every client has a different format. Building regex parsers for each one is a nightmare that breaks every time the layout changes slightly.\n\nInstead of building N parsers, I use a single multimodal AI endpoint that:\n\n``` python\nimport requests\n\n# Upload and analyze in one call\nwith open(\"invoice.pdf\", \"rb\") as f:\n    response = requests.post(\n        \"https://mediavox.co/mvai/api/v1/documents/analyze\",\n        files={\"file\": f},\n        data={\n            \"api_key\": \"your_key_here\",\n            \"question\": \"Extract: vendor name, tax ID, invoice number, date, line items with quantities and prices, subtotal, tax, total.\"\n        },\n        timeout=60\n    )\n\nresult = response.json()\n\nprint(result[\"answer\"])       # Human-readable summary\nprint(result[\"entities\"])     # Structured: [{type: \"vendor\", value: \"...\"}]\nprint(result[\"document_type\"]) # \"factura\", \"contrato\", \"recibo\"...\nprint(result[\"session_id\"])   # For follow-up questions\n```\n\nThe session persists the document context, so you can ask clarifying questions without re-uploading:\n\n```\nfollow_up = requests.post(\n    \"https://mediavox.co/mvai/api/v1/chat\",\n    json={\n        \"api_key\": \"your_key_here\",\n        \"question\": \"What are the payment terms?\",\n        \"session_id\": result[\"session_id\"]\n    }\n)\n\nprint(follow_up.json()[\"answer\"])\n# \"Payment terms: 30 days net. Due date: August 15, 2026.\"\n```\n\nThe AI answers from the document only — no hallucinations from external knowledge.\n\nInput: a crumpled photo of a Colombian restaurant receipt (low light, tilted)\n\n```\n{\n  \"document_type\": \"recibo\",\n  \"entities\": [\n    {\"type\": \"vendor\", \"value\": \"Restaurante El Portal\", \"confidence\": 0.94},\n    {\"type\": \"tax_id\", \"value\": \"901234567-8\", \"confidence\": 0.91},\n    {\"type\": \"total\", \"value\": \"98700\", \"confidence\": 0.97},\n    {\"type\": \"tax\", \"value\": \"15800\", \"confidence\": 0.89},\n    {\"type\": \"date\", \"value\": \"2026-06-28\", \"confidence\": 0.95}\n  ],\n  \"integrity\": {\n    \"subtotal_matches_items\": true,\n    \"tax_calculation_correct\": true\n  }\n}\n```\n\nThe `integrity`\n\ncheck catches arithmetic mismatches automatically — useful for expense auditing.\n\nIf you use n8n, there's a community node (`n8n-nodes-mediavox`\n\n) that wraps all of this. Or use HTTP Request nodes directly — the API is straightforward REST.\n\nI published a ready-to-use workflow template: [Extract invoice details and ask follow-ups](https://mediavox.co/mvdevportal/static/n8n/documentpower-analyze-invoice.json) — import it and replace the file path.\n\nFree tier: 100 requests/month. Enough to test with real documents.\n\n`n8n-nodes-mediavox`\n\non npm*Built this for LATAM businesses dealing with messy paperwork. If you're processing documents in Spanish/Portuguese and tired of custom parsers, this might save you time.*", "url": "https://wpnews.pro/news/extracting-structured-data-from-invoices-and-contracts-with-one-api-call", "canonical_source": "https://dev.to/mediavox/extracting-structured-data-from-invoices-and-contracts-with-one-api-call-n5p", "published_at": "2026-07-25 18:13:52+00:00", "updated_at": "2026-07-25 19:01:15.067887+00:00", "lang": "en", "topics": ["artificial-intelligence", "computer-vision", "natural-language-processing", "ai-products", "developer-tools"], "entities": ["Mediavox", "n8n"], "alternates": {"html": "https://wpnews.pro/news/extracting-structured-data-from-invoices-and-contracts-with-one-api-call", "markdown": "https://wpnews.pro/news/extracting-structured-data-from-invoices-and-contracts-with-one-api-call.md", "text": "https://wpnews.pro/news/extracting-structured-data-from-invoices-and-contracts-with-one-api-call.txt", "jsonld": "https://wpnews.pro/news/extracting-structured-data-from-invoices-and-contracts-with-one-api-call.jsonld"}}