Skip to main content

OCR Pipeline for ID Documents: A Build Guide for 2026

Send an uncropped ID photo to POST /v3/id-verification/ and read back typed holder fields, the parsed MRZ, a decision and a warnings list. $0.15 inside a workflow, $0.20 standalone.

OCR Pipeline for ID Documents: A Build Guide for 2026

Contents

In this guide

Jump to the part you need.

This guide shows how to build an OCR pipeline for ID documents on Didit: send an uncropped photo of an ID, get back typed holder fields, the parsed MRZ, a decision and a warnings list. It fits engineering teams shipping onboarding or KYC without a document team. The ID document check is $0.15 inside a workflow and $0.20 through the standalone API. The caveat: reading a document is not proving it is genuine, so read the warnings, not the HTTP status.

Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.

Summary: which route reads which document

Three Didit routes for turning a document into data, with list prices
RouteWhat it returnsPriceUse it when
ID Verification step inside a workflowClassification, OCR of the visual zone, MRZ and barcode decode, cross-checks, document liveness, a decision and warnings in the returned session report$0.15 per checkYou run a hosted or API verification flow and want a session with a full report
ID Verification standalone API, POST /v3/id-verification/The same OCR and fraud checks, server to server, no workflow needed$0.20 per checkYour backend already holds the image
Document AI, POST /v3/document-ai/Fields you define from any PDF or image, plus name matching and tampering checks$0.20 per documentThe document is not a fixed-template ID: bank statement, payslip, proof of funds

Start free in the sandbox at https://business.didit.me/, no sales call. Sandbox testing is free and unlimited, and nothing is charged in sandbox. Developers who want an AI assistant to run the calls can connect Didit over MCP at https://didit.me/developers/mcp/. The endpoint reference is the ID Verification overview and the price list is at https://didit.me/pricing/.

What an OCR pipeline for ID documents gives you

The outcome is a JSON object per document: the holder fields already split into keys, the machine readable zone decoded, any barcode decoded, a decision, and a list of warnings that explains every issue found. Your application reads typed fields and warning codes straight from the response instead of parsing pixels or scraping a text blob.

  • Typed fields instead of a text blob. document_type, document_subtype, document_number, personal_number, first_name, last_name, date_of_birth, expiration_date, issuing_state.
  • Two independent readings that check each other. The visual zone is read by OCR, the MRZ and barcodes are decoded, and the service compares one against the other instead of trusting a single read.
  • A decision you can route on. Approved, Declined or In Review, with the risk codes that produced it.
  • Authenticity signals in the same call. Screen replays, printed copies, portrait manipulation, public document images and specimens are all flagged by risk code.

We run this pipeline for 4,000+ companies across 220+ countries and 14,000+ document types, with sub-2-second p99 inference.

ID OCR vs ID document recognition

OCR reads characters. ID document recognition is the wider step around it: deciding which document you were sent, finding its layout, decoding the MRZ and barcodes, then validating number formats, check digits and date plausibility before anyone sees a field. A pipeline that only does OCR gives you text with no guarantee about which field is which. Didit does the full step, and you never declare the country or the document type: classification happens on the image.

Document recognition languages and capture languages are different numbers, and both matter. The capture flow and native SDKs ship in 54 languages; recognition covers 130+ languages across 50+ scripts.

Use one call and let the service do the preprocessing, the classification and the cross-checks. Do not build your own crop, deskew or binarize step in front of it. The endpoint expects the raw capture: uncropped, all four corners visible. The service detects the document, aligns it, crops it, classifies it, reads the visual zone, decodes the MRZ and any barcode, validates the fields against each other, and optionally screens the images for replay and manipulation. Document-level issues appear in the response as status values and warning codes. Authentication, credit, transport, and file-processing failures return HTTP errors, so handle both response warnings and HTTP status codes.

Build the decision logic around warnings, not around the HTTP status. A readable but problematic document returns HTTP 200 with status: "Declined".

A user capturing the front of an ID document inside the Didit verification flow
Capture is the only step you control. Send the full frame, not a crop.

Prerequisites

  • A Didit application and an API key from https://business.didit.me/. The key needs to reach the endpoint you call; scoped keys are refused with 403 when a scope is missing.
  • An image of the front of the document, which is required, plus the back for two-sided documents. Upload uncropped photos with all four corners of the document visible: the service detects, aligns and crops the document itself.
  • curl and jq if you want to follow the examples below verbatim. Any HTTP client works.
  • Credit on the organization, or a sandbox application. Sandbox testing is free and unlimited; a live call without balance returns 403 before any image processing.
  • A place to store the request_id. When save_api_request is true (the default) it is a real session id you can query later.

Steps

  1. Create the sandbox application and copy the key. Sign in at https://business.didit.me/, create a sandbox application, and export the key in your shell as DIDIT_API_KEY. Nothing is billed in sandbox.

  2. Capture honestly. For a driver's license or an ID card, send the front and the back. For a passport, the data page. Keep all four corners inside the frame, avoid glare across the number, and do not crop, rotate or enhance. The service detects, aligns and crops the document itself, so a pre-crop removes the edges it uses for classification.

  3. Call the standalone ID Verification endpoint. One request sends the image and gets the fields, the MRZ parse, the decision and the warnings.

    curl -X POST https://verification.didit.me/v3/id-verification/ \
      -H "x-api-key: $DIDIT_API_KEY" \
      -F "front_image=@./licence-front.jpg" \
      -F "back_image=@./licence-back.jpg" \
      -F "perform_document_liveness=true" \
      -F "save_api_request=true"
  4. Read the status and the warnings, in that order. Look at id_verification.status and every entry in id_verification.warnings. Fraud and hard failures always decline: DOCUMENT_EXPIRED, SCREEN_CAPTURE_DETECTED, PRINTED_COPY_DETECTED, PORTRAIT_MANIPULATION_DETECTED, PUBLIC_DOCUMENT_IMAGE_DETECTED, SPECIMEN_DOCUMENT_DETECTED, plus the extraction failures NAME_NOT_DETECTED, DATE_OF_BIRTH_NOT_DETECTED and DOCUMENT_NUMBER_NOT_DETECTED. Three risk groups you can tune per request: invalid_mrz_action, inconsistent_data_action and expiration_date_not_detected_action, each set to DECLINE or NO_ACTION. Informational warnings such as POSSIBLE_DUPLICATED_USER never decline on their own.

  5. Pull the stored session when you need the full report. With save_api_request=true the call becomes an API-type session, emits a status.updated webhook to your configured endpoints, and returns cropped media as short-lived URLs.

    curl https://verification.didit.me/v3/session/<SESSION_ID>/decision/ \
      -H "x-api-key: $DIDIT_API_KEY"

    The response is always plural for features: id_verifications[], liveness_checks[], face_matches[]. Branch on session_kind, which is user or business. The key needs read:sessions.

  6. Correct a field the OCR misread, deliberately. Sometimes the document genuinely says something the model reads differently, or an operator fixes a typo before the record leaves your system. Use the partial update endpoint rather than writing your own database copy.

    curl -X PATCH "https://verification.didit.me/v3/session/<SESSION_ID>/update-data/" \
      -H "x-api-key: $DIDIT_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "first_name": "John",
        "last_name": "Doe",
        "date_of_birth": "1990-01-01",
        "issuing_state": "ESP"
      }'

    Only the fields you send change. The key needs write:sessions, and the session must be Approved, Declined, In Review or Kyc Expired. The update fires a data.updated webhook and the audit trail records the changed fields with their previous and new values.

  7. Send non-ID documents to Document AI. Bank statements, payslips, tax forms and proof of funds have no fixed template, so you define the fields instead of relying on a document registry.

    curl -X POST https://verification.didit.me/v3/document-ai/ \
      -H "x-api-key: $DIDIT_API_KEY" \
      -F "document=@./bank-statement.pdf" \
      -F 'fields=[{"key":"account_holder","name":"Account holder","instruction":"Full name of the account holder","type":"text","required":true,"is_full_name":true},{"key":"balance","name":"Closing balance","instruction":"Closing balance as a number","type":"number","required":true}]' \
      -F "expected_first_name=Jane" \
      -F "expected_last_name=Doe"

    The fields array takes 1 to 30 items as one JSON-encoded string. Values come back typed as text, number or date in YYYY-MM-DD, with null for anything the model could not find. Send expected_first_name and expected_last_name for a person, or expected_company_name for a company, never both groups.

    Uploading a document to Document AI in the Didit console
    Document AI takes the same upload for documents that are not IDs, with fields you define per request.
Didit processing a captured ID document after upload
Between capture and result the service classifies the document, reads the visual zone, decodes the MRZ and runs the cross-checks.

Expected output

A clean read returns HTTP 200 and a body shaped like this, trimmed to the fields this walkthrough reads:

{
  "request_id": "9f2a1c4e-...",
  "status": "Approved",
  "id_verification": {
    "status": "Approved",
    "document_type": "Driver's License",
    "document_number": "AB1234567",
    "first_name": "JANE",
    "last_name": "DOE",
    "date_of_birth": "1990-01-01",
    "expiration_date": "2031-04-18",
    "issuing_state": "ESP",
    "barcodes": [],
    "warnings": []
  }
}

Every warning object follows the same schema across features: feature, risk, log_type (error, warning or information), short_description, long_description, additional_data and node_id. A document whose forgery check did not run looks like this instead:

{
  "status": "In Review",
  "id_verification": {
    "status": "In Review",
    "warnings": [
      { "feature": "ID_VERIFICATION", "risk": "DOCUMENT_LIVENESS_NOT_COMPUTED", "log_type": "warning" }
    ]
  }
}

Media fields such as portrait_image and front_image are presigned URLs with a limited validity window. Download them promptly instead of storing the URL.

Failure cases and recovery

Two codes sound similar and mean different things. COULD_NOT_RECOGNIZE_DOCUMENT is the HTTP 400 for a file that cannot be processed at all. COULD_NOT_DETECT_DOCUMENT_TYPE is the warning returned when the front image is readable but does not match a known official document design with high confidence, and it declines the check.

What each response means and what to do next
What you seeWhat it meansRecovery
HTTP 400, {"error": "COULD_NOT_RECOGNIZE_DOCUMENT"}The file cannot be processed at all. This is a file-level failure, not a verdict on the document designAsk the user for a new capture in a supported file format. Retrying the same file will fail the same way
HTTP 200, Declined, COULD_NOT_DETECT_DOCUMENT_TYPEThe front image does not match a known official document design with high confidence. Unlike COULD_NOT_RECOGNIZE_DOCUMENT, the image was processed and this warning declines the checkAsk for a new capture of the front with all four corners visible, or route the session to a reviewer with the image
HTTP 200, Declined, fraud or hard-failure risk codesFraud risk or an unreadable mandatory field. These always declineReject, or route to a reviewer with the image. Do not auto-retry
HTTP 200, In Review, DOCUMENT_LIVENESS_NOT_COMPUTEDThe forgery check produced no usable score. A check that did not run is not evidence that the document is genuineQueue for manual review. The escalation is not configurable and never overrides a Declined
HTTP 200, POSSIBLE_DUPLICATED_USER or other informational codesContext, not a verdictLog it. Informational warnings never decline on their own
HTTP 403 not-enough-creditsThe organization balance cannot cover the callTop up, or keep testing in the sandbox, which stays free and unlimited
HTTP 401Missing or invalid API keyCheck the header name, x-api-key, and the key's environment
HTTP 403 on the decision or update callThe key lacks read:sessions for the decision, or write:sessions for the updateUse a full-access key or add the scope
HTTP 404 on the decision or update callThe session does not exist, belongs to another application, or carries no record of the feature you are patchingRe-check the request_id and the session kind
HTTP 400 on update-dataValidation error: invalid country code, unknown parsed_address key, extra_fields not an objectRead the field-keyed error body and resend only that field

Inputs and outputs of the ID call

Fields you send and fields you read on POST /v3/id-verification/
DirectionFieldTypeNotes
Infront_imagefileRequired. Uncropped, all four corners visible
Inback_imagefileTwo-sided documents only
Inperform_document_livenessbooleanDefault true. Screens for screen replays, printed copies and portrait manipulation
Insave_api_requestbooleanDefault true. Persists the call as a session and emits status.updated
Ininvalid_mrz_action, inconsistent_data_action, expiration_date_not_detected_actionenumDECLINE or NO_ACTION, set per request
Outstatus, id_verification.statusstringApproved, Declined or In Review
Outid_verification.warnings[]arrayOne object per risk, with a stable risk code and descriptions
Outrequest_idUUIDA real session id when save_api_request is true
OutHolder fields and barcodes[]variousdocument_type, document_subtype, document_number, personal_number, names, dates, issuing_state; barcodes carry type, position, data and side

Every HTTP 200 from the ID Verification endpoint consumes one ID Verification API credit, paid from your plan credit or top-up balance. Inside a workflow, the ID document step is $0.15. Through the standalone endpoint it is $0.20. Document AI is $0.20 per document, and a malformed fields payload returns 400 before any extraction runs, so nothing is billed. Sandbox testing is free and unlimited on every plan.

The review boundary sits at In Review. One path into it is an unavailable liveness score: when the forgery check returns no usable score, the call returns In Review with a DOCUMENT_LIVENESS_NOT_COMPUTED warning, and the session needs manual or investigator handling. That status is not an approval and not a rejection: a person or an investigator decides, and the session's decision_trace records decided_by as manual, automatic or investigator, together with automatic_status and the warning counts. Corrections through update-data are an operator action with the same weight: they rewrite the record, they fire a webhook, and they leave an audit trail of previous and new values. Keep the two apart in your head. Reading a document is automated. Changing a document's record is a decision someone made.

Didit Business Console session detail showing the ID document report with extracted fields
The same report is stored on the session, where the extracted fields and every warning are readable.

Worked cost example

A month with 8,000 full ID checks inside workflows, 1,200 standalone ID Verification calls from a backend that already holds images, and 600 Document AI documents. A full ID check is four modules: ID document verification $0.15 + passive liveness $0.10 + face match 1:1 $0.05 + device and IP analysis $0.03 = $0.33.

  • 8,000 x $0.33 = $2,640.00
  • 1,200 x $0.20 = $240.00
  • 600 x $0.20 = $120.00
  • Total at list price: $2,640.00 + $240.00 + $120.00 = $3,000.00

On the Scale plan the same month carries a 10% discount on every module price: $0.135 + $0.09 + $0.045 + $0.027 = $0.297 per full check.

  • 8,000 x $0.297 = $2,376.00
  • 1,200 x $0.135 = $162.00
  • 600 x $0.18 = $108.00
  • Total at Scale prices: $2,376.00 + $162.00 + $108.00 = $2,646.00

The $299 monthly plan fee is separate, and the $350 of monthly credit is spent before any top-up balance. On the Free plan the $10 of monthly credit buys about 30 full ID checks at $0.33.

Add Didit to Claude · Open Didit in ChatGPT · MCP setup for every client

Sources

The next step is a sandbox call, not a sales call. Create an application at https://business.didit.me/, send one uncropped license photo to the endpoint above, and check the warnings array before you design a single screen around it.

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alejandro Rosas

Co-founder and CTO

Alejandro Rosas

Alejandro Rosas

Co-founder and CTO

About Didit

Questions

Frequently asked questions

What is ID OCR?

ID OCR is optical character recognition applied to a government-issued identity document: the service finds the text zone on the card or passport page and turns it into fields such as name, date of birth and document number. Didit's ID Verification endpoint does that plus classification, MRZ and barcode decoding, cross-checks and document liveness in one call. It costs $0.15 inside a workflow and $0.20 through the standalone API.

What is the difference between ID document recognition and ID OCR?

OCR reads characters. ID document recognition is the wider step: classifying which document you sent, finding its layout, decoding the MRZ and barcodes, then comparing the visual zone against the MRZ and validating number formats and check digits. Didit does the whole step in one call and never asks you to declare the country or the document type.

Do I need to crop, rotate or straighten the photo before sending it?

No. Send uncropped photos with all four corners of the document visible. The service detects, aligns and crops the document itself, so pre-cropping can remove the edges it uses to classify the document and to read the number.

What does COULD_NOT_RECOGNIZE_DOCUMENT mean?

It is the HTTP 400 response returned when the file cannot be processed at all, for example because it is unreadable or in a format the endpoint cannot open. It is a file-level failure, not a verdict on the document design, and it returns no field data. Ask the user for a new capture instead of retrying the same file.

What does COULD_NOT_DETECT_DOCUMENT_TYPE mean?

It is the warning returned when the front image does not match a known official document design with high confidence, and it declines the check. The image was processed, which is what separates it from COULD_NOT_RECOGNIZE_DOCUMENT, the HTTP 400 for a file that cannot be processed at all. Ask for a new capture of the front with all four corners visible, or route the session to a reviewer with the image.

Why did a call return HTTP 200 with status In Review?

When perform_document_liveness is true, which is the default, and the forgery check returns no usable score, Didit returns 200 with status: "In Review" and a DOCUMENT_LIVENESS_NOT_COMPUTED warning instead of Approved. A check that did not run is not evidence that the document is genuine. The escalation is not configurable and never overrides a Declined.

Can I correct a field the OCR misread?

Yes. PATCH /v3/session/{session_id}/update-data/ rewrites KYC fields such as first_name, last_name, date_of_birth, document_number and issuing_state on a finished session. It is a partial update: only the fields you send change. It fires a data.updated webhook, and the audit trail records the previous and new values. The key needs write:sessions.

Which documents should go to Document AI instead of the ID pipeline?

Anything that is not a fixed-template identity document: bank statements, payslips, tax forms, invoices, proof of funds. You define from 1 to 30 fields, each with a key, an instruction and a type, and you can mark one field as the full name so the service compares it against the expected person or company. Document AI costs $0.20 per document.

Does the pipeline read MRZ and barcodes?

Yes. The ID Verification call parses the MRZ on passports and some national IDs and decodes barcodes on the document. The session report returns id_verifications[].barcodes as an array with type, position, data and side, and an empty array when the document carries none. Document AI returns detected_codes for every supported QR code and barcode on each processed page.

How many document types and countries are supported?

14,000+ document types from 220+ countries and territories, with 130+ document-recognition languages across 50+ scripts. Classification is automatic, so the same request handles a Spanish driver's license and a Japanese passport without configuration, and the capture flow itself is available in 54 languages.

Is an OCR result the same as a verified identity?

No. OCR gives you the fields; verification is the decision around them. A full ID check on Didit pairs the document step with passive liveness, face match 1:1 and device and IP analysis for $0.33, and the session report returns each part as its own object with its own warnings.

Can I test the pipeline without paying?

Yes. Sandbox testing is free and unlimited, and nothing is charged in sandbox. A live call without enough credit returns HTTP 403 before any image processing, so a missing balance never costs you an image upload.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.