Skip to content

Read ID Card Info ​

Extracts the printed and encoded fields from an ID card image — OCR text, the MRZ machine-readable zone, the QR code and, where available, NFC chip data — each with a confidence score.

Endpoint ​

http
POST /v1/read_id_card_info_sync
Content-Type: application/json
json
{
  "card_type": "vn.national_id",
  "image1": {
    "id": "2dc863d6-1f68-4c82-8380-dd34e4ed7da0",
    "base64": "",
    "label": "id_card.vn.national_id.front",
    "metadata": "{}"
  }
}

Parameters:

ParamTypeRequiredDefaultDescription
card_typestringYes—The card type. See Usage Recommendations.
image1ImageDataYes—Image of the identity card's front side or back side.

ImageData ​

ParamTypeRequiredDefaultDescription
idstringNo—ID of the image returned by Upload Image.
base64stringNo—Base64-encoded text of the image data.
labelstringNo—Label of the image, as described in Usage Recommendations.
metadatastring_jsonNo—Key/value JSON string. Example: {"id":"<ID>","type":1}

Supply either id or base64, never both.

Sample Request ​

bash
curl --location '<BASE_URL>/v1/read_id_card_info_sync' \
  --header 'Authorization: ATV <ACCESS_ID>:<SIGNATURE>' \
  --header 'X-TV-Timestamp: <TIMESTAMP>' \
  --header 'Content-Type: application/json' \
  --data '{
    "card_type": "vn.national_id",
    "image1": {
      "id": "e94288e6-7ab5-4aeb-9608-8382f4ceb92f",
      "base64": "",
      "label": "id_card.vn.national_id.back",
      "metadata": "{}"
    }
  }'

Response ​

json
{
  "data": {
    "request_id": "09c1bf6b-2522-4202-b3e5-a2d63dc2d0ea",
    "status": "success",
    "card_information": [
      {
        "field": "name",
        "value": "NGUYỄN VĂN A",
        "confidence_score": 0.904328,
        "confidence_verdict": "SURE",
        "digit_confidence_scores": []
      }
    ],
    "image1": {
      "id": "2dc863d6-1f68-4c82-8380-dd34e4ed7da0",
      "card_box": {
        "top_left": { "x": 134, "y": 191 },
        "top_right": { "x": 946, "y": 191 },
        "bottom_left": { "x": 134, "y": 710 },
        "bottom_right": { "x": 946, "y": 710 }
      },
      "ocr": {
        "parsed": [
          {
            "field": "id",
            "value": "001xxxxxxxxx",
            "confidence_score": 0.90224093,
            "confidence_verdict": "SURE",
            "digit_confidence_scores": []
          }
        ],
        "char_probs": [],
        "confidence_score": 0,
        "entropy": 0,
        "group": 0,
        "label": 0,
        "line": 0,
        "text": ""
      },
      "mrz": { "parsed": [], "char_probs": [], "confidence_score": 0, "entropy": 0, "group": 0, "label": 0, "line": 0, "text": "" },
      "qr": { "parsed": [], "char_probs": [], "confidence_score": 0, "entropy": 0, "group": 0, "label": 0, "line": 0, "text": "" },
      "nfc": null
    },
    "image2": null
  },
  "errors": []
}
FieldTypeDescription
data.request_idstringRequest ID; quote it to CAKE Support when checking logs.
data.statusstringsuccess or failure.
data.card_informationParsedField[]Consolidated card fields, merged across every available source.
data.image1ImageResultPer-source extraction result for the first image.
data.image2ImageResultResult for the second image, or null when not supplied.

ImageResult ​

FieldTypeDescription
idstringID of the analysed image.
card_boxCardBoxCorner coordinates of the detected card, each corner { "x": int, "y": int }.
ocrExtractionResultFields read from the printed card surface.
mrzExtractionResultFields read from the machine-readable zone.
qrExtractionResultFields read from the QR code.
nfcExtractionResultFields read from the NFC chip, or null when no chip data was supplied.

ExtractionResult ​

FieldTypeDescription
parsedParsedField[]The structured fields extracted from this source.
textstringRaw text read from this source.
char_probsfloat[]Per-character confidence probabilities.
confidence_scorefloatOverall confidence for this source.
entropyfloatEntropy of the recognition result.
groupintInternal grouping index.
labelintInternal label index.
lineintLine index within the source.

ParsedField ​

FieldTypeDescription
fieldstringField name, e.g. id, name.
valuestringExtracted value.
confidence_scorefloatConfidence in the extracted value, range 0–1.
confidence_verdictstringCategorical confidence, e.g. SURE.
digit_confidence_scoresfloat[]Per-digit confidence for numeric fields.

INFO

Do not treat a low-confidence field as verified data. Gate acceptance on confidence_verdict and confidence_score, and route anything below your threshold to manual review — especially the ID number and date of birth.

Errors ​

CodeMessage
2001010Access ID not found.
401100You are not authorized to perform the action.
4001000Input parameter violates a constraint.
4001001The X-TV-Timestamp header is expired, need a newer one.
5001000Some unexpected error occurs while processing the request.
CodeDescription
access_denied_exceptionYou are not authorized to perform the action.
invalid_parameter_exceptionInput parameter violates a constraint.
request_time_too_skewedThe X-TV-Timestamp header is expired, need a newer one.
image_not_found_exceptionThe image ID is not found in DB.
rate_limit_exceptionThe number of requests exceeded your throughput limit.
internal_server_errorSome unexpected error occurs while processing the request.

Next Steps ​

Developers