MRZ Parser and Generator API

Parse and validate the machine readable zone of passports, ID cards and visas (TD1, TD2, TD3, MRV-A/B), check digits, or generate an MRZ from data.

GETPOSThttps://apibox.io.vn/v1/mrz

Send the 2 or 3 lines of an MRZ as mrz (newlines, an array, or one string of 88 / 90 / 72 characters; spaces and « are cleaned) — the text that passport readers, OCR SDKs and hotel check-in scanners output. The format is detected: TD3 passports, TD1 identity cards (3 × 30), TD2 (2 × 36), MRV-A and MRV-B visas (ICAO Doc 9303 Part 7), plus French ID cards and Swiss / French driving licences. You get the document code and type, issuing state and nationality (ICAO codes with English and Vietnamese names, including D, XXA stateless, UN and EU codes), surname and given names, document number (long TD1 numbers rebuilt from the optional data), birth and expiry dates as ISO dates with age, expired and days to expiry, sex, personal number and optional data.

Each check digit (document number, birth date, expiry, personal number, composite) is recomputed with the 7-3-1 weights and reported with the expected value; autocorrect=true fixes common OCR confusions (O/0, I/1, B/8, S/5, Z/2, G/6) by field type. For Vietnamese chip ID cards (CCCD / thẻ căn cước, IDVNM) the 12-digit personal number in the optional data is decoded (province, century / sex, birth year) and cross-checked.

op=create builds an MRZ from format (TD1, TD2, TD3, MRVA, MRVB), issuing_state, last_name + given_names (or a Vietnamese full_name, family name first), document_number, nationality, birth_date, sex, expiry_date and optional data: names are transliterated to the ICAO form (Vietnamese diacritics removed, Đ → D, Ä → AE…) and truncated by the ICAO rules, check digits computed, and the result parsed back. Nothing is stored or logged; a valid MRZ does not prove a document is genuine.

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
mrzbody|querystringyesThe MRZ lines (newline separated, an array, or one string). Required for parsing.
autocorrectbody|querybooleannofalseFix OCR letter / digit confusions by field type.
opbody|querystringnoparseparse, create or check-digit (with value).
formatbodystringnoTD3create: TD1, TD2, TD3, MRVA or MRVB.
document_codebodystringnocreate: P, PN, I, ID, AC, V… (default P for TD3, I for cards, V for visas).
issuing_statebodystringnocreate: ICAO / ISO alpha-3 code (VNM) or alpha-2 (VN).
last_namebodystringnocreate: primary identifier (surname).
given_namesbodystringnocreate: secondary identifier.
full_namebodystringnocreate: Vietnamese full name, family name first (alternative to last_name + given_names).
document_numberbodystringnocreate: document number (9 characters; longer in TD1 / TD2).
nationalitybodystringnocreate: nationality code (default: issuing state).
birth_datebodystringnocreate: YYYY-MM-DD.
sexbodystringnocreate: M, F or X.
expiry_datebodystringnocreate: YYYY-MM-DD.
personal_numberbodystringnocreate (TD3): personal number, up to 14 characters.
optional_databodystringnocreate: optional data (TD1 line 1, TD2, visas); optional_data_2 for TD1 line 2.
vn_cccdbodystringnocreate (TD1): Vietnamese 12-digit personal number; fills the document number and optional data like issued cards.

Example

curl -X POST "https://apibox.io.vn/v1/mrz" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mrz":"P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<\nL898902C36UTO7408122F1204159ZE184226B<<<<<10"}'

Response

{
  "format": "TD3",
  "document_type": "passport",
  "valid": true,
  "checks_valid": true,
  "fields": {
    "document_code": "P",
    "issuing_state": {
      "code": "UTO",
      "alpha2": null,
      "name": "Utopia (ICAO specimen)",
      "name_vi": "Utopia (mẫu của ICAO)"
    },
    "last_name": "ERIKSSON",
    "given_names": "ANNA MARIA",
    "document_number": "L898902C3",
    "nationality": {
      "code": "UTO",
      "alpha2": null,
      "name": "Utopia (ICAO specimen)",
      "name_vi": "Utopia (mẫu của ICAO)"
    },
    "birth_date": "1974-08-12",
    "sex": "female",
    "expiry_date": "2012-04-15",
    "personal_number": "ZE184226B",
    "optional_data": null
  },
  "age": 52,
  "expired": true,
  "days_to_expiry": -5323,
  "checks": [
    {
      "field": "document_number",
      "valid": true,
      "expected": "6",
      "found": "6"
    },
    {
      "field": "birth_date",
      "valid": true,
      "expected": "2",
      "found": "2"
    },
    {
      "field": "expiry_date",
      "valid": true,
      "expected": "9",
      "found": "9"
    },
    {
      "field": "personal_number",
      "valid": true,
      "expected": "1",
      "found": "1"
    },
    {
      "field": "composite",
      "valid": true,
      "expected": "0",
      "found": "0"
    }
  ],
  "errors": [],
  "specimen": true,
  "lines": [
    "P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<",
    "L898902C36UTO7408122F1204159ZE184226B<<<<<10"
  ]
}

Use cases

  • Hotels and homestays: read passports from a scanner for guest registration of foreigners
  • Validate MRZ text from an OCR or eKYC SDK before saving it
  • Generate test MRZs for document readers and booking systems
  • Check expiry dates of travel documents in visa and HR software

FAQ

Does it read images?

No, it reads MRZ text. Use your scanner or an OCR SDK to get the text, then send it here.

Why is the issuing state of the sample "UTO"?

Utopia is the fictitious state of ICAO specimens; it is accepted and flagged with specimen=true.

How are Vietnamese names written?

Without diacritics, Đ as D, family name first: NGUYEN<<THI<ANH<TUYET. Long names are shortened from the last given name.

Related APIs

Start with 1,000 free requests every month. Get free API key →