Skip to main content

Barcode Decoding for Document Authentication (2026 How-To)

Send front and back images of an ID document to Didit's ID Verification API, read the decoded barcodes array, and compare it with the visual fields and the MRZ. $0.15 per check inside a workflow, $0.20 on the standalone API.

Barcode Decoding for Document Authentication (2026 How-To)

Contents

In this guide

Jump to the part you need.

Barcode decoding fits teams that must prove the printed fields of an ID were not edited after issue. With Didit you send front and back images to the ID Verification API, or run that step inside a workflow at $0.15 per check, then read the decoded barcodes array. The caveat: a decoded payload proves what the code says, not that the paper is genuine, so read it beside the tamper checks.

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

Barcode decoding at a glance
ItemDetail
What you getDecoded barcode payloads from an ID document or any PDF or image, returned as structured data you compare with the visual zone and the MRZ
Endpoint, identity documentsPOST https://verification.didit.me/v3/id-verification/
Endpoint, other documentsPOST https://verification.didit.me/v3/document-ai/
Price, ID document inside a workflow$0.15 per check
Price, ID Verification API (server to server)$0.20 per call
Price, Document AI$0.20 per document
Symbologies returnedPDF_417, QR_CODE, DATA_MATRIX, CODE_128, EAN_13 and other supported codes
Human review boundaryIn Review goes to your review queue, Declined stops the flow
TestingFree sandbox on every plan, $10 of credit each month on the Free plan

Start free in the sandbox at business.didit.me, no sales call. Developers who want an AI assistant to call the API can connect Didit through the Didit MCP server. Every number below is on the Didit pricing page.

How barcode decoding authenticates a document

Treat the barcode as a second copy of the record, printed when the document was issued. The front of a driver's license shows a name and a date of birth in human-readable type. The code on the back carries the same values in a machine-readable string. If someone edits the front and leaves the code alone, the two copies disagree.

Didit runs the whole read inside one call. The image is classified and aligned, the visual zone is read with OCR, the MRZ and any barcodes are decoded, and cross-checks then validate dates, number formats and MRZ check digits while comparing the visual zone against the MRZ. Barcode output is an array, one entry per code found, so a document with a PDF417 on the back and a QR code on the front returns two entries.

One concrete mismatch, as implementation guidance: a license that prints an expiry of 2029-08-01 on the front while the decoded payload on the back carries 2026-08-01 is the kind of contradiction the cross-checks exist to catch. With inconsistent_data_action=DECLINE, a contradiction the cross-checks detect comes back as Declined with INCONSISTENT_DATA in the warnings array.

PDF417 on driver's licenses

PDF417 is a stacked 2D symbology, and it is the code you meet on driver's licenses and state ID cards. It usually sits on the back, which is why back_image matters. Didit returns the symbology as PDF_417 and the decoded string in data. A front edited while the back stays untouched is a direct contradiction, and that contradiction is the fraud signal.

QR codes and the other symbologies

Beyond PDF417, Didit returns QR_CODE, DATA_MATRIX, CODE_128 and EAN_13 when a document carries them. The handling does not change with the symbology: read the payload, then compare it with the visual zone and the MRZ.

What you need before you start

  • A Didit application. Create one at business.didit.me; the sandbox is free on every plan.
  • An API key, sent in the x-api-key header.
  • One image per side: tiff, jpg, jpeg, png, webp or pdf, max 5 MB per file, uncropped, with all four corners of the document visible.
  • Both sides for two-sided documents. ID cards and driver's licenses need back_image, and on many licenses that is exactly where the PDF417 sits.
  • A decision per risk: which warnings decline and which go to review, set per request with the action parameters.
  • For Document AI, the list of fields you want read, 1 to 30 items, sent as one JSON array string.

Decode an ID barcode, step by step

  1. Create the application and copy the key. Obtain an API key for your application and send it in the x-api-key header. Sandbox calls are not charged.
  2. Pick the route. Government-issued IDs (passports, ID cards, driver's licenses, residence permits) go to ID Verification, which decodes barcodes as part of the document read. Anything else carrying a code, such as payslips, bank statements, invoices or tickets, goes to Document AI.
  3. Capture uncropped images of both sides. Do not pre-crop: the service detects, aligns and crops the document itself. Stay under 5 MB per file.
  4. Send the request and set the actions you want. The call below is the published form of the endpoint, with the back image included and the three main risks set to decline.
    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'
  5. Read status before anything else. id_verification.status is Approved, Declined or In Review in this endpoint, and the warnings array explains every issue behind that status.
  6. Read the barcodes array. Each entry preserves the reader output, including type, side, data, data_raw and position. An empty array means no supported code was found on that document.
  7. Compare the payload with the visual zone and the MRZ. With inconsistent_data_action=DECLINE, a contradiction between the decoded barcode, the printed fields and the MRZ raises INCONSISTENT_DATA and the request is declined.
  8. Fetch the same result later. With save_api_request=true the call is stored as an API session: request_id is a real session id you can pass to GET /v3/session/{sessionId}/decision/, and a status.updated webhook fires. Inside a workflow, read id_verifications[].barcodes from the session decision.
The user is guided through photographing the document with all four corners visible
The capture step in a Didit flow. Uncropped images with all four corners visible are what makes the barcode readable.
The document is being read, with OCR, MRZ and barcode decoding running
The document read in progress: OCR, MRZ decoding, barcode decoding and the tamper checks run in the same pass.

What the response looks like

The example below is trimmed to the fields you act on, with values replaced by placeholders. Field names are exactly as returned.

{
  "request_id": "SESSION_OR_REQUEST_UUID",
  "id_verification": {
    "status": "Approved",
    "full_name": "<name read from the document>",
    "document_type": "Driver's License",
    "document_number": "<number read from the document>",
    "date_of_birth": "YYYY-MM-DD",
    "expiration_date": "YYYY-MM-DD",
    "barcodes": [
      {
        "type": "PDF_417",
        "side": "back",
        "data": "<decoded payload>",
        "data_raw": "<raw reader output>"
      }
    ],
    "warnings": []
  }
}

Three things matter in that body. barcodes is always an array, and documents without barcode output return [] rather than null, so your handler never has to guess. status is the decision: a readable document with a problem returns HTTP 200 with status: Declined, so branching on the HTTP code alone will let bad documents through. And the path differs by route: the standalone call returns the data under id_verification.barcodes, while a session decision returns it under id_verifications[].barcodes, one entry per document collected in the workflow.

Decoding barcodes on documents that are not IDs

Bank statements, proof of funds, payslips, tax documents and invoices often carry a QR code or a barcode as well. Document AI extracts the fields you define and returns every code it detects, with the payload parsed where it can be.

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"

Every successful response includes document_ai.detected_codes, one item per code on each processed page of the PDF.

Fields in the document_ai.detected_codes array
FieldWhat it gives you
typeSymbology, such as QR_CODE, CODE_128, EAN_13, DATA_MATRIX or PDF_417
page_number1-based page number
position, x, y, width, heightDetected polygon and bounding box in rendered-page pixels, or null when no reliable location is available
parsed_payloadDecoded string or structured value, or null when the code can only be located
raw_payloadRaw decoder payload as a base64 string when available, otherwise an empty string

Didit never guesses a payload. A damaged QR code can come back with its location and parsed_payload: null, and a failure in code detection does not fail the Document AI request. Two other defaults matter for authentication: DOCUMENT_AI_SUSPECTED_MANIPULATION is set to DECLINE out of the box, while DOCUMENT_AI_NAME_MISMATCH defaults to NO_ACTION, so a name that scores below the document_ai_name_match_score_threshold of 80 only blocks the document if you change that action. See the Document AI warnings reference.

Inputs and outputs

What you send and what comes back
DirectionFieldNotes
Infront_imageRequired. One file, max 5 MB, uncropped
Inback_imageRequired for two-sided documents such as ID cards and driver's licenses
Ininconsistent_data_action, invalid_mrz_action, expiration_date_not_detected_actionDECLINE or NO_ACTION, set per request
Insave_api_requestDefault true. Keeps the call as an API session with a usable request_id
OutstatusApproved, Declined or In Review
Outbarcodes[]Always an array, empty when no supported code is found
Outwarnings[]Risk code, short and long description, and additional data per warning
Outdocument_ai.detected_codes[]Document AI only: type, page, position and payload per code
Outname_match_scoreDocument AI only, 0 to 100, null when the check is skipped

Failure cases and recovery

What goes wrong and what to do
SymptomCauseRecovery
HTTP 403, not enough creditsBalance cannot cover the callTop up or move plan. The call is refused before any image processing
HTTP 400 COULD_NOT_RECOGNIZE_DOCUMENTThe file could not be processed at allRe-capture uncropped, better light, both sides. Do not retry the same file
HTTP 400 on multipart validationMissing back_image, file over 5 MB, unsupported extensionFix the file, then resend
status: Declined with DOCUMENT_EXPIRED or DOCUMENT_LIVENESS_FAILEDTerminal warningStop the flow and show the first warning's long_description
status: In Review with DOCUMENT_LIVENESS_NOT_COMPUTEDThe forgery check produced no usable scoreTreat the document as unchecked and route it to manual review
barcodes: []No supported code, or the side that carries it was not sentNot fraud by itself. Re-request the missing side before deciding
parsed_payload: null in Document AIDamaged or unreadable codeThe location is still returned; fall back to the extracted fields
HTTP 400 on a Document AI fields valueSent as bracket-style form keys instead of one JSON array stringResend as a single array. Nothing is billed when this fails

What is paid, and where a human decides

Inside a workflow, the ID Verification step costs $0.15 per check and barcode decoding is part of that step, not a separate line. The standalone server-to-server call is its own price-book line at $0.20 per call. Document AI is $0.20 per document.

A machine never becomes the last word on a mismatch. Declined is terminal and your application should stop the flow. In Review requires manual review, including when a requested check produced no usable result, and a check that did not run is not evidence that a document is genuine. Review the returned barcode payload alongside the visual fields and warnings in your application.

The Didit Business Console session detail showing the ID document, its extracted fields and warnings
A session in the Didit Business Console: the document, the extracted fields and the warnings a reviewer works from.

Worked cost example

Take 40,000 full KYC checks a month, all on documents that carry a barcode, plus 6,000 bank statements read with Document AI.

  • ID document: 40,000 x $0.15 = $6,000.00
  • Passive liveness: 40,000 x $0.10 = $4,000.00
  • Face match 1:1: 40,000 x $0.05 = $2,000.00
  • Device and IP analysis: 40,000 x $0.03 = $1,200.00
  • Full KYC subtotal: $6,000.00 + $4,000.00 + $2,000.00 + $1,200.00 = $13,200.00, which is 40,000 x $0.33
  • Document AI on statements: 6,000 x $0.20 = $1,200.00
  • Monthly total at list price: $13,200.00 + $1,200.00 = $14,400.00
  • On the Scale plan, 10% off every Didit price: $14,400.00 x 0.10 = $1,440.00, so $12,960.00

The same 40,000 documents sent to the standalone ID Verification API instead cost 40,000 x $0.20 = $8,000.00 for the documents alone, with no liveness, face match or device analysis in that figure. If you are building a user-facing flow, the workflow route is both cheaper per document and the one that returns a decision.

Sources

Your next step: open a free sandbox application at business.didit.me, send one driver's license front and back, and read the barcodes array yourself. No sales call.

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

Alberto Rosas

Co-founder and CEO

Alberto Rosas

Alberto Rosas

Co-founder and CEO

About Didit

Questions

Frequently asked questions

What is barcode decoding for document authentication?

It is the process of reading the machine-readable code printed on an identity document and comparing the decoded payload with the human-readable fields and the MRZ. A disagreement between the copies is evidence of tampering. Didit returns the payload in barcodes on the ID Verification response, alongside a status and a warnings list.

Which barcode types does Didit decode?

Document AI returns QR_CODE, CODE_128, EAN_13, DATA_MATRIX and PDF_417 among supported codes. ID Verification decodes the codes found on identity documents, including the PDF417 on driver's licenses, and returns them as an array. Each entry carries the symbology, the side, the parsed data and the raw reader output.

How much does barcode decoding cost?

Nothing on its own. Inside a workflow the ID Verification step is $0.15 per check and barcode decoding runs as part of it. The standalone ID Verification API is $0.20 per call, and Document AI, which is the route for non-ID documents, is $0.20 per document.

Does a decoded barcode prove the document is genuine?

No. It proves what the code says, which is useful only when it is compared with the visual zone and the MRZ. A forger who edits the front and not the back creates the mismatch, but a good forgery that edits both needs the tamper checks, and document liveness adds a further signal when you enable it with perform_document_liveness=true. Read the barcode as one signal among several.

What happens if the barcode is damaged or unreadable?

Didit does not guess. In Document AI a damaged code can come back with its location and parsed_payload: null, and a failure in code detection does not fail the request. In ID Verification, when the reader gets no usable code, the barcodes array comes back empty for that document.

Can I decode a barcode on a document that is not an ID?

Yes, with Document AI at POST https://verification.didit.me/v3/document-ai/. Send the file plus 1 to 30 field definitions as one JSON array string, and the response includes document_ai.detected_codes for every processed page. It is built for proof of funds, payslips, bank statements, tax documents and invoices.

How do I interpret a barcode mismatch?

Compare the decoded payload with the printed fields and the MRZ. If they disagree, the document was edited after issue or the code was rebuilt. With inconsistent_data_action=DECLINE the call returns Declined with INCONSISTENT_DATA in warnings. When no code is returned, treat the empty barcodes array as an absence of barcode output and evaluate the document using its status and warnings.

Where do I find the barcode data in a session decision?

At id_verifications[].barcodes, which is always an array. Each entry preserves the reader output, including type, position, data, data_raw and side. Documents without barcode output return [], so you never have to handle a null in place of a list.

How do I test all of this without paying?

Create a sandbox application at business.didit.me. Sandbox testing is free and unlimited on every plan, and the Free plan adds $10 of credit each month for live calls. You can send real document images and read the actual response shape before you spend anything.

Do I need both sides of a driver's license?

Yes. ID cards and driver's licenses are two-sided documents, so back_image is required, and the PDF417 usually sits on the back. Sending only the front leaves the barcode unread and returns an empty barcodes array for that document.

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.