Home / Developers

Developer guide

A REST API with JSON responses. Most teams integrate in an afternoon.

1. Get a key

You get two kinds of key. lo_test_... keys are free, work on every endpoint and are never billed, so use them while you build. lo_live_... keys are for production. Keep keys on your server, never in a mobile app or web page.Request a test key.

2. Send a document

curl https://api.lendocr.com/v1/documents:extract \
  -H "Authorization: Bearer lo_test_..." \
  -F file=@pan.jpg

Python

import requests

r = requests.post(
    "https://api.lendocr.com/v1/documents:extract",
    headers={"Authorization": "Bearer lo_test_..."},
    files={"file": open("statement.pdf", "rb")},
    data={"password": "optional-pdf-password"},
    timeout=60,
)
r.raise_for_status()
doc = r.json()
if doc["needs_review"]:
    print("Send to a reviewer:", doc["warnings"])

Node.js

const form = new FormData();
form.append("file", new Blob([await fs.promises.readFile("pan.jpg")]), "pan.jpg");

const res = await fetch("https://api.lendocr.com/v1/documents:extract", {
  method: "POST",
  headers: { Authorization: "Bearer lo_test_..." },
  body: form,
});
const doc = await res.json();
console.log(doc.document_type, doc.fields);

Form fields

FieldDefaultMeaning
filerequiredJPEG, PNG, WebP, TIFF, BMP or PDF; up to 10 MB and 50 pages
document_typeautoName the type, or let LendOCR detect it
engineautofast, accurate, or auto (fast first, careful second read when needed)
passwordnoneFor password-protected PDFs

Endpoints

MethodPathPurpose
POST/v1/documents:extractFields, checks and needs_review for one document
POST/v1/documents:batchUp to 10 documents in one call, results per file
POST/v1/documents:readAll the text in any document, page by page
POST/v1/jobsQueue 1-20 documents for background processing (202)
GET/v1/jobs/{job_id}Job status, and the full result when done
DELETE/v1/jobs/{job_id}Cancel a queued job or erase a result now
POST/v1/validateCheck a single PAN, Aadhaar, GSTIN, IFSC, DL, passport and more
GET/v1/usagePages your organisation used this month
GET/v1/document-typesSupported documents

Responses and errors

Successful responses carry fields (value and confidence), checks,needs_review and warnings. Errors use standard HTTP codes with a JSON body (application/problem+json) and a request_id for support.

StatusWhen
401Missing, wrong, revoked or expired API key
403The key does not have this scope
413 / 415File larger than 10 MB / not a readable image or PDF
422Invalid field, wrong PDF password, or unknown document type
429Rate limit or monthly quota reached; see Retry-After
503Busy; see Retry-After and try again

Every response includes X-RateLimit-Limit, X-RateLimit-Remaining and X-Request-ID.

Background jobs and webhooks

For large statements and bulk uploads, queue the files and get notified. Sending the sameIdempotency-Key again returns the same jobs, so retries never create duplicates.

curl https://api.lendocr.com/v1/jobs \
  -H "Authorization: Bearer lo_live_..." \
  -H "Idempotency-Key: loan-app-1042" \
  -F files=@statement.pdf -F files=@pan.jpg \
  -F webhook_url=https://your-server.example.com/hooks/lendocr

When each job finishes we POST to your webhook_url (https only), retrying for about a day if your server is down. The body has no document data; fetch the result withGET /v1/jobs/{job_id}. Verify the X-LendOCR-Signature header with your webhook secret:

import hashlib, hmac, time

def verify(secret: str, header: str, body: bytes) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))  # t=...,v1=...
    if abs(time.time() - int(parts["t"])) > 300:  # reject replays
        return False
    mac = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256)
    return hmac.compare_digest(mac.hexdigest(), parts["v1"])