The DocuneX REST API
Send a document, get back its text, tables and structured fields as JSON. Connect DocuneX to your accounting software, ERP or internal tools.
Authentication
The API is part of the Business plan. Create a key under Account → API keys and send it with every request:
Authorization: Bearer dx_live_your_keyKeys are shown once, stored only as a hash, and can be revoked at any time. Keep them on your server, never in a browser or mobile app.
POST /api/v1/extract
Upload one document as multipart/form-data. Processing is synchronous: the response arrives when the document has been read (usually 1–25 seconds per page).
| Field | Required | Description |
|---|---|---|
file | Yes | PDF, PNG, JPG, WEBP, BMP, GIF, DOCX, XLSX, PPTX, CSV or TXT, up to 50 MB. |
template | No | invoice, receipt, bank_statement, prescription. Adds structured fields to the response. |
force_ocr | No | true to OCR a PDF even if it has a text layer. |
curl
curl https://YOUR-DOCUNEX-DOMAIN/api/v1/extract \
-H "Authorization: Bearer dx_live_your_key" \
-F file=@invoice.pdf \
-F template=invoicePython
import requests
res = requests.post(
"https://YOUR-DOCUNEX-DOMAIN/api/v1/extract",
headers={"Authorization": "Bearer dx_live_your_key"},
files={"file": open("invoice.pdf", "rb")},
data={"template": "invoice"},
timeout=300,
)
res.raise_for_status()
doc = res.json()
print(doc["fields"]["values"]["invoice_number"], doc["fields"]["values"]["total_amount"])Node.js
const form = new FormData();
form.append("file", new Blob([await fs.promises.readFile("invoice.pdf")]), "invoice.pdf");
form.append("template", "invoice");
const res = await fetch("https://YOUR-DOCUNEX-DOMAIN/api/v1/extract", {
method: "POST",
headers: { Authorization: "Bearer dx_live_your_key" },
body: form,
});
const doc = await res.json();Response
{
"ok": true,
"id": "5315e631-81b5-40dd-adfb-7c4afb3ef533",
"file_name": "invoice.pdf",
"file_type": "PDF",
"page_count": 1,
"duration_ms": 1840,
"text": "Sharma Electronics Pvt Ltd\nGSTIN: 19AABCS1429B1Z5 ...",
"markdown": "# Sharma Electronics Pvt Ltd ...",
"pages": [{ "number": 1, "source": "ocr", "engine": "paddleocr", "confidence": 97, "blocks": [ ... ] }],
"warnings": [],
"fields": {
"template": "invoice",
"method": "ai",
"values": {
"invoice_number": "SE/24-25/0248",
"invoice_date": "2025-03-12",
"seller_gstin": "19AABCS1429B1Z5",
"subtotal": "3400",
"cgst": "306",
"sgst": "306",
"total_amount": "4012"
},
"items": [{ "description": "Logitech M331 Mouse", "hsn_sac": "8471", "quantity": "2", "unit_price": "1250", "amount": "2500" }],
"confidence": { "invoice_number": "high", "total_amount": "high" },
"warnings": []
},
"usage": { "period": "2026-10", "pages": 3, "apiCalls": 1, "limits": { "pages": 10000 } }
}Dates are returned as YYYY-MM-DD and amounts as plain numbers without currency symbols or separators. Each page counts toward your monthly allowance.
Templates
Every template returns values (one per field), items (repeating rows), a confidence level per field and warnings from the built-in checks (GSTIN format, totals that don't add up).
invoice · GST invoice / bill
Fields: invoice_number, invoice_date, due_date, seller_name, seller_gstin, buyer_name, buyer_gstin, place_of_supply, subtotal, cgst, sgst, igst, total_tax, total_amount
Line items: description, hsn_sac, quantity, unit_price, tax_rate, amount
receipt · Receipt / expense
Fields: merchant, date, receipt_number, payment_method, subtotal, tax, total_amount, category
Items: description, quantity, amount
bank_statement · Bank statement
Fields: bank_name, account_holder, account_number, period_start, period_end, opening_balance, closing_balance
Transactions: date, description, reference, debit, credit, balance
prescription · Prescription
Fields: doctor, clinic, patient, date
Medicines: medicine, strength, dosage, duration
GET /api/v1/documents/{id}
Returns a document processed earlier: its text, Markdown and template fields. Documents are available until your account's retention period ends (up to 90 days on Business).
GET /api/v1/usage
This month's pages and API calls against your plan's limits. Useful for alerting before you run out.
{ "ok": true, "plan": "business", "period": "2026-10", "pages": 3, "apiCalls": 1, "limits": { "pages": 10000, "questions": 10000 } }Errors & limits
Errors return { "ok": false, "error": { "code", "message" } } with an HTTP status. The rate limit is 60 requests a minute per account.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request / invalid_template | The file field is missing, or the template name is unknown. |
| 401 | invalid_api_key | The key is missing, wrong or revoked. |
| 402 | quota_exceeded | This month's page allowance is used up. |
| 403 | plan_required | The account isn't on the Business plan. |
| 413 | extraction_failed | The file is larger than 50 MB. |
| 415 | extraction_failed | The file type isn't supported (e.g. legacy .doc, HEIC). |
| 422 | extraction_failed | The document couldn't be read (corrupted or password-protected). |
| 429 | rate_limited | More than 60 requests a minute. Wait for the Retry-After seconds. |
| 503 | ocr_unavailable | The OCR service is temporarily unavailable. Retry shortly. |

