API documentation

Base URL: https://ocr.onegovai.app. All endpoints return JSON. Documents are processed in memory and never stored.

Authentication

Send your key in the X-API-Key header on every request except /health. Create keys yourself in the developer portal — sign up with an email, create up to 3 keys, and watch per-key usage. The browser demo on the home page needs no key (5 extractions/IP/day).

POST /extract

Multipart upload. JPEG/PNG/WEBP/BMP/TIFF or PDF, max 15MB.

ParamInValuesDefault
fileform-datathe documentrequired
documentTypequery AUTO, NATIONAL_ID, PASSPORT, PROOF_OF_RESIDENCE AUTO
curl -H "X-API-Key: $KEY" \
  -F "file=@id.jpg" \
  "https://ocr.onegovai.app/extract?documentType=NATIONAL_ID"

Response

{
  "fields": {
    "documentType": "NATIONAL_ID",
    "idNumber": "63-123456A70",
    "surname": "MOYO",
    "firstName": "TENDAI",
    "dateOfBirth": "1990-05-14",
    "placeOfBirth": "HARARE",
    "villageOfOrigin": "GUTU",
    "dateOfIssue": "2015-02-10"
  },
  "fieldConfidences": { "idNumber": 0.99, "surname": 0.97 },
  "warnings": [],
  "ocrConfidence": 0.96,
  "rawText": ["..."]
}

Warning codes: PASSPORT_EXPIRED, CHECK_DIGIT_FAILED, DOCUMENT_TOO_OLD, NO_DOCUMENT_DATE, MISSING_FIELDS, LOW_OCR_CONFIDENCE, UNRECOGNISED_ISSUER.

Errors

StatusMeaning
401Missing or invalid API key
413File over 15MB
415Unsupported file type
422POOR_QUALITY (blurry / low resolution / too dark — ask the customer to retake) or no text detected
429Demo limit reached (keyless demo endpoint only)

POST /match

Cross-document KYC check. Send the fields objects from 2–5 /extract responses. Names match on tokens (initials match full names), ID numbers are zero-padding tolerant (passport personalNumber vs national idNumber).

curl -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
  -d '{"documents":[{ "...fields A..." : "" },{ "...fields B..." : "" }]}' \
  https://ocr.onegovai.app/match

Returns per-attribute scores (name, dateOfBirth, idNumber) and an overall matched boolean.

GET /api/v1/usage

Your metered usage: {"client": "...", "today": 12, "total": 340}.

GET /health

Liveness: {"status": "UP"}. No key required.

Outputs are OCR extractions, not identity verification. Always review low-confidence fields and warnings before making KYC decisions.