Skip to main content

Barcode Decoding on ID Documents: Read Barcodes and MRZ

Didit decodes the barcodes found on supported documents and returns them in the barcode array inside the ID document check, then cross-checks them against OCR and the MRZ.

Barcode Decoding on ID Documents: Read Barcodes and MRZ

Contents

In this guide

Jump to the part you need.

This guide is for developers and fraud teams who need the barcode on a driver's license or ID card decoded, compared with the printed text and turned into a decision. On Didit a document check costs $0.15 inside a workflow, or $0.20 per call on the standalone direct-upload API. The caveat up front: a decoded barcode is evidence, not a verdict, and it never replaces the visual and biometric checks.

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

Barcode decoding on Didit at a glance
QuestionAnswer
What it doesReads the barcodes found on supported documents and returns them in the barcode array, next to OCR of the printed text and MRZ decoding, then cross-checks them.
Where the data appearsid_verifications[].barcodes in the session decision, and id_verification.barcodes in the standalone API response.
Price inside a workflow$0.15 per ID document check. No separate line item for barcode decoding.
Price on the standalone API$0.20 per call, the documented direct-upload API price. One credit per 200 response.
Coverage14,000+ document types in 220+ countries and territories, 54 languages in the flow and SDKs.
LatencySub-2-second p99 inference.
Cost to testSandbox is free and unlimited. The Free plan adds $10 of credit each month for eligible organizations that sign up with a qualifying company-domain work email.

Start free in the sandbox at business.didit.me, no sales call. If you build with an AI assistant, connect Didit through the MCP server. Prices are on the pricing page, and the technical detail is in the ID verification docs.

What barcode decoding adds to a document check

A barcode on an identity document is a machine-readable copy of facts that are also printed on the card, and many driver's licenses carry one on the back. Passports and newer ID cards add a machine readable zone, and e-passports hold the same data in an NFC chip that can be checked against the issuing country's digital signature.

The value is not the copy. The value is the comparison. Didit classifies the document, reads the visual zone with OCR, decodes the MRZ and returns any barcodes it reads, then validates dates, number formats and MRZ check digits, and compares the visual zone against the MRZ and the barcode. A card whose printed name was altered but whose barcode was not produces a mismatch you can act on, which is why the decoded fields are stored next to the OCR fields and the warnings.

Barcode decoding does not prove the document is genuine, and it does not prove the person holding it is the owner. It is one more signal next to document liveness, passive liveness and face match. Didit has 4,000+ active companies and supports 220+ countries and territories.

The capture screen while a user photographs an identity document
Capture comes first: the document must be uncropped with all four corners visible before the barcode can be read.

Document liveness is not person liveness

Two different checks share the word. Document liveness screens the submitted images of the document for screen replays, printed copies and portrait manipulation, and on the standalone endpoint it runs by default with perform_document_liveness=true. Person liveness is a separate feature inside a workflow: it checks that a live person is in front of the camera, and passive liveness is priced at $0.10. The standalone document endpoint runs document liveness, needs no selfie, and never asks for person liveness.

What an ID decoder is in this context

An ID decoder is the component that reads the machine-readable layers of a document: the barcode, the MRZ and, in some products, the NFC chip. On Didit there is no separate decoder to buy or wire up. The decoder runs inside the ID document check, and its output arrives in the same result object as the OCR fields, the warnings and the status.

That shape matters for integration. You make one call and get one decision, instead of running a barcode reader next to a separate OCR vendor and reconciling two answer formats. The decoded code, the printed text it should match, and the risk decision live in the same record, which is also the record your reviewers see in the Console.

Prerequisites

  • A Didit organization. Sign up at business.didit.me. The sandbox is free and unlimited.
  • An API key sent in the x-api-key header. A sandbox key is enough to build; the live key needs credit on the organization.
  • The document images. front_image is required, and back_image is required for two-sided documents such as ID cards and driver's licenses. Allowed formats: tiff, jpg, jpeg, png, webp, pdf, maximum 5 MB per file. Upload uncropped photos with all four corners visible, because the service detects, aligns and crops the document itself.
  • For a hosted flow instead of a server-to-server call: a workflow with the ID_VERIFICATION feature, built in the console or with POST /v3/workflows/.

How to decode a barcode on an ID document

The steps use the standalone endpoint, because it is the shortest path from two images to a decoded barcode. Step 2 covers the session route for user-facing flows.

  1. Create the account and copy an API key. Sign up at business.didit.me, create an organization, open the API keys section and copy the sandbox key. To register programmatically, call POST https://apx.didit.me/auth/v2/programmatic/register/, then POST https://apx.didit.me/auth/v2/programmatic/verify-email/ with the 6-character code. The response returns sandbox_application.api_key for testing and application.api_key for live traffic.

  2. Choose the route. Use the standalone endpoint when you already hold the images, for example a back-office re-check or a migration. Use a workflow session when a person uploads the document in your app: create a workflow with the ID_VERIFICATION feature, then call POST https://verification.didit.me/v3/session/ with workflow_id, vendor_data and callback, and send the user to the returned url. The barcode output lands in the same id_verifications[] array in the decision, so your downstream code is the same on both routes.

  3. Send the images. One multipart call runs OCR, MRZ decoding, barcode decoding and the document fraud checks.

    curl -X POST 'https://verification.didit.me/v3/id-verification/' \
    -H 'x-api-key: YOUR_API_KEY' \
    -F 'front_image=@./id_front.jpg' \
    -F 'back_image=@./id_back.jpg' \
    -F 'perform_document_liveness=true' \
    -F 'minimum_age=18' \
    -F 'expiration_date_not_detected_action=DECLINE' \
    -F 'invalid_mrz_action=DECLINE' \
    -F 'inconsistent_data_action=DECLINE' \
    -F 'preferred_characters=latin' \
    -F 'save_api_request=true' \
    -F 'vendor_data=user-123'

    You never declare the country or the document type. The service classifies the document automatically.

  4. Read the status and the warnings before the fields. id_verification.status is Approved, Declined or In Review. id_verification.warnings explains every issue found, each entry with a stable risk code such as DOCUMENT_EXPIRED, INVALID_MRZ or INCONSISTENT_DATA, a short description and a long description you can show to the user.

  5. Read the barcode array and compare it. id_verification.barcodes is always an array. Each entry keeps the reader output: type, position, data, data_raw and side. A document with no barcode output returns an empty array. Compare the decoded values with full_name, document_number, date_of_birth, expiration_date and parsed_address, and with mrz where the document carries one.

  6. Store the record and branch on the status. With save_api_request=true, which is the default, the call is persisted as an API-type session. It appears in the Business Console, request_id is a real session id you can pass to GET /v3/session/{sessionId}/decision/, the cropped images come back as short-lived media URLs, and a status.updated webhook is emitted to your configured endpoints. Store the decoded fields, the cross-check results and the decision together so a reviewer or an auditor can see what was read and what followed.

The screen shown while the document is analyzed
OCR, MRZ decoding, barcode decoding and the fraud checks run in the same call.

Expected output

A successful call returns HTTP 200 with the shape below. The field names and types follow the documented schema; the values are placeholders, and mrz is null when the document has no machine readable zone.

{
  "request_id": "0f1c...",
  "id_verification": {
    "status": "Approved",
    "document_type": "Driver's License",
    "document_number": "...",
    "full_name": "...",
    "date_of_birth": "...",
    "expiration_date": "...",
    "parsed_address": "...",
    "mrz": null,
    "barcodes": [
      {
        "type": "...",
        "position": "...",
        "data": "...",
        "data_raw": "...",
        "side": "back"
      }
    ],
    "warnings": []
  }
}

Inputs and outputs

Request fields and response fields for barcode decoding
FieldDirectionWhat it does
front_imageRequest, requiredThe front of the document. Uncropped, all four corners visible, maximum 5 MB.
back_imageRequest, required for two-sided documentsThe back of the card, where the barcode on a driver's license usually sits.
perform_document_livenessRequest, defaults to trueScreens the images for screen replays, printed copies and portrait manipulation.
invalid_mrz_actionRequest, DECLINE or NO_ACTIONWhether an MRZ that fails its check digits declines the request.
inconsistent_data_actionRequest, DECLINE or NO_ACTIONWhether a mismatch between the visual zone, the MRZ and the barcode declines the request.
save_api_requestRequest, defaults to truePersists the call as an API session in the Console and emits a webhook.
statusResponseApproved, Declined or In Review.
barcodes[]ResponseThe decoded codes, each with type, position, data, data_raw and side. Empty array when none were found.
mrzResponseThe parsed machine readable zone, null when the document has none.
full_name, document_number, date_of_birth, expiration_date, parsed_addressResponseThe extracted holder fields you compare against the barcode and against what the user typed.
warnings[]ResponseThe risk codes, each with a description you can act on or display.
The ID document panel of a session in the Didit Business Console
With save_api_request set to true, the saved call appears in the Business Console.

Failure cases and recovery

What goes wrong and what to do about it
What you seeWhyRecovery
HTTP 400 with {"error": "COULD_NOT_RECOGNIZE_DOCUMENT"}The document cannot be processed at all.Re-capture with all four corners visible and no crop, then retry once. If it fails again, route the case to manual review.
HTTP 400 with multipart validation errorsMissing back_image on a two-sided document, a file over 5 MB, or an unsupported extension.Fix the payload. Confirm the request is sent as multipart/form-data, not JSON.
HTTP 403, not enough creditsThe organization balance cannot cover the call. It is refused before any image processing.Top up, or keep testing with the sandbox key, which costs nothing.
HTTP 403 with a permission messageThe key lacks permission for the endpoint.Check the key's privileges for that endpoint, and that the header name is x-api-key.
HTTP 401The API key is invalid, revoked or expired.Rotate the key and retry.
HTTP 200 with status Declined and a terminal warningExamples: expired document, screen capture, printed copy, portrait manipulation, specimen document, or a field that could not be extracted.Show the first warning's long description to the user and stop the flow. Do not retry the same images.
HTTP 200 with status In ReviewA person has to decide.Send the session to your manual review queue. Do not approve it automatically.
In Review with DOCUMENT_LIVENESS_NOT_COMPUTEDThe forgery check returned no usable score, for example because the provider failed.Treat the document as unchecked and review it by hand. This escalation is not configurable.

Each HTTP 200 response on the standalone endpoint consumes one ID Verification API credit at $0.20, which is the documented direct-upload API price for this call. Inside a workflow the same document step is $0.15. Passive liveness is $0.10, face match is $0.05, device and IP analysis is $0.03, so the full KYC check is $0.33. Reading an e-passport chip is a separate $0.15 add-on. Sandbox testing is free and unlimited.

Review is a boundary, not a fallback. When a result comes back In Review, a human makes the call: you route the session to your queue and you do not approve the user. A document whose forgery check did not compute is treated as unchecked, never as clean. When a reviewer changes a status by hand, the decision record keeps the automatic status and the override, so the original answer stays visible.

A session overview showing its status and warnings in the Didit Business Console
The session overview is where a reviewer sees the status, the warnings and the evidence before overriding anything.

Worked cost example

Take 1,000 verifications a month where every user submits a driver's license with a barcode on the back.

  • ID document check inside a workflow: 1,000 x $0.15 = $150.00. Barcode decoding is part of that check, and the price book has no separate line for it.
  • The same volume on the standalone direct-upload API: 1,000 x $0.20 = $200.00.
  • The standalone route costs $0.20 - $0.15 = $0.05 more per document, or $50.00 across 1,000 calls.
  • Full KYC check: ID document $0.15 + passive liveness $0.10 + face match $0.05 + device and IP $0.03 = $0.33. At volume: 1,000 x $0.33 = $330.00.
  • The gap between the document alone and the full check is $0.33 - $0.15 = $0.18 per check, or $180.00 across 1,000 checks.
  • On the Scale plan, with its 10% discount, the full check is $0.297 and 1,000 checks cost 1,000 x $0.297 = $297.00.

When barcode decoding is not enough

Plenty of documents carry no barcode at all: many passports rely on the MRZ, and some national cards rely on a chip or on the visual zone alone. A damaged or scratched code can fail to read while the card is perfectly valid. And a synthetic identity can carry a barcode and printed text that agree with each other, because both were fabricated. That is why the barcode feeds a decision rather than making one, and why the decision also uses document liveness, liveness of the person, face match and, where it is configured, a database lookup or an NFC read.

Sources

Next step: open the sandbox at business.didit.me, create an organization with a work email, copy the sandbox key and run the call above against one of your own documents. No sales call, and nothing is charged while you test.

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 barcode decoding on an identity document?

It is the process of reading the machine-readable code printed on a document and turning it into structured data. Didit decodes the barcodes found on supported documents and returns them in the barcode array, next to the printed text read by OCR and the parsed MRZ. The comparison is the useful part, because it exposes documents that were altered after issue.

Which barcodes can Didit decode on a document?

Didit decodes the barcodes found on supported documents and returns them in the barcode array, and each entry records the reader output including its type. The array is always present, so a document with no barcode output returns an empty array rather than an error. Didit covers 14,000+ document types in 220+ countries and territories.

Is there an extra fee for barcode decoding?

No. Barcode decoding runs inside the ID document check, which is $0.15 inside a workflow or $0.20 per call on the standalone direct-upload API, and the public price book has no separate line for barcode decoding. Reading an e-passport chip is the one document add-on with its own price, at $0.15.

Where does the decoded barcode appear in the API response?

On the standalone endpoint it is id_verification.barcodes. In a session decision it is id_verifications[].barcodes. The array is always present, and each entry carries type, position, data, data_raw and side.

What is the difference between barcode decoding and OCR?

OCR reads the printed characters a person can see on the card. Barcode decoding reads the encoded block that a machine reads. They should describe the same holder, and when they do not, Didit raises a cross-check warning such as INCONSISTENT_DATA or INVALID_MRZ.

What happens when the barcode and the printed text disagree?

Didit reports a mismatch warning on the ID verification result. Whether that declines the request is up to the caller: inconsistent_data_action and invalid_mrz_action accept DECLINE or NO_ACTION. Set DECLINE where a mismatch must stop onboarding, and NO_ACTION where you would rather review the case by hand.

Can I decode a barcode without running a full KYC check?

Yes. The standalone endpoint at POST https://verification.didit.me/v3/id-verification/ does OCR, MRZ decoding, barcode decoding and document fraud checks from one or two images, for $0.20 per call, the documented direct-upload API price. It does not require a user session or selfie. Document liveness runs by default and can be disabled with perform_document_liveness=false.

What does document liveness check that person liveness does not?

Document liveness screens the images of the document for screen replays, printed copies and portrait manipulation, and it runs by default on the standalone endpoint. Person liveness is a different feature inside a workflow: it checks that a live person is in front of the camera, and passive liveness costs $0.10. The standalone document endpoint does not ask for a selfie or run person liveness.

What image quality does the decoder need?

Send uncropped images with all four corners of the document visible, in tiff, jpg, jpeg, png, webp or pdf, at a maximum of 5 MB per file. Didit detects, aligns and crops the document itself, so pre-cropping hurts rather than helps. Those are the documented image requirements, and the endpoint returns HTTP 400 when they are not met.

What does status In Review mean for a document check?

It means a human has to decide. Didit returns In Review when the result does not support an automatic approval, including when a requested forgery check produced no usable score. Route those sessions to your review queue and do not approve the user automatically.

Is a decoded barcode proof that a document is genuine?

No. It shows what the code contains and whether that agrees with the printed text, the MRZ and the expected details. A fabricated document can carry a matching code. Authenticity also depends on the document fraud checks, and on the biometric check that the person holding the card is the person in the photo.

Can I test barcode decoding for free?

Yes. The sandbox is free and unlimited on every plan, and the Free plan adds $10 of credit each month for eligible organizations that sign up with a qualifying company-domain work email. You only need a live key and credit when you move real traffic. Didit publishes this guidance from its own documentation, and the price list lets you check every number here.

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.