Skip to content

DocAuth

You can check the validity of someone’s documents through our DocAuth API.

Authorization

This endpoint requires an API token as Bearer in the Authorization header. Go to Authorization guide for details.

Request

POST https://api.biometrysolutions.com/api-gateway/v2/documents/check

Headers

  • Authorization* - Your API Token.

request part fields

FieldTypeDescription
session_idstringOptional. Link this transaction to a session.
providerstringOptional. Document authenticity provider: inhouse (our GPT-powered extraction, the default) or idscan (legacy IDScan flow). Defaults to your project configuration.
mrz_providerstringOptional. MRZ (Machine Readable Zone) extraction provider: inhouse or idscan. When set, the response includes MRZ parsing, check-digit validation, and cross-validation against OCR-extracted fields. See MRZ Validation below.

File parts

  • document* (formData file) — image of the document (JPEG, PNG, or JPG).
Request
curl --location 'https://api.biometrysolutions.com/api-gateway/v2/documents/check' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--form 'request={"provider":"inhouse"}' \
--form 'document=@"/Users/john/Desktop/IMG_0001.jpeg"'
Response

The data object contains the information extracted from the document. Check the current_result field for validity:

  • Passed - The document is valid
  • Failed - The document is not valid

In most cases we return the data even if the document is not valid. It is up to you to decide whether you care about validity.

{
"data": {
"document_type": "National Identification Card",
"country_code": "UTO",
"nationality_code": "UTO",
"nationality_name": "UTOPIAN",
"sex": "FEMALE",
"first_name": "ANNA",
"father_name": "ERIK",
"last_name": "ERIKSSON",
"expiry_date": "2028-08-03",
"document_number": "D23145890",
"birth_date": "1974-08-12",
"portrait_photo": "",
"document_category": "National Identification Card",
"current_result": "Passed",
"face_image_base64": "RQWW..."
},
"meta": { "request_id": "fc5605c5-...", "message": "Document uploaded successfully, looks like it's authentic" }
}

MRZ Validation

When you set mrz_provider in the request part, the API performs additional MRZ (Machine Readable Zone) validation. This feature:

  1. Extracts the MRZ from the document image (if present)
  2. Validates check digits using the ICAO 9303 standard algorithm
  3. Cross-validates MRZ data against OCR-extracted fields
  4. Reports discrepancies that may indicate document tampering

Supported MRZ Formats

FormatLinesCharacters/LineDocument Type
TD1330ID cards
TD2236Some ID cards, older formats
TD3244Passports

Request with MRZ Validation

curl --location 'https://api.biometrysolutions.com/api-gateway/v2/documents/check' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--form 'request={"provider":"inhouse","mrz_provider":"inhouse"}' \
--form 'document=@"/Users/john/Desktop/passport.jpeg"'

Response with MRZ Validation

When MRZ validation is enabled, the data object includes an additional mrz_validation object:

{
"data": {
"document_type": "Passport",
"country_code": "UTO",
"nationality_code": "UTO",
"nationality_name": "UTOPIAN",
"sex": "FEMALE",
"first_name": "ANNA MARIA",
"last_name": "ERIKSSON",
"expiry_date": "2030-12-31",
"document_number": "L898902C3",
"birth_date": "1974-08-12",
"current_result": "Passed",
"face_image_base64": "RQWW...",
"mrz_validation": {
"has_mrz": true,
"raw_mrz": "P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<\nL898902C36UTO7408122F1204159ZE184226B<<<<<10",
"check_digits_valid": true,
"fields_match": true,
"discrepancies": [],
"validation_performed": true
}
},
"meta": { "request_id": "fc5605c5-...", "message": "Document uploaded successfully, looks like it's authentic" }
}

MRZ Validation Fields

FieldTypeDescription
has_mrzbooleanWhether an MRZ was detected in the document
raw_mrzstringThe raw MRZ text extracted from the document
check_digits_validbooleanWhether all MRZ check digits are valid (ICAO 9303 algorithm)
fields_matchbooleanWhether MRZ fields match the OCR-extracted fields
discrepanciesarrayList of specific mismatches between MRZ and OCR data
validation_performedbooleanWhether MRZ validation was attempted

Interpreting Results

  • check_digits_valid: false - The MRZ may have been tampered with or incorrectly read. Check digits protect against manual modification.
  • fields_match: false - Discrepancies exist between the MRZ data and the visually printed fields. This could indicate document forgery.
  • has_mrz: false - No MRZ was detected. This is normal for the front side of ID cards (MRZ is typically on the back) or for documents without MRZ.