Skip to content

Parse QR Info ​

Parses the raw QR payload from a Vietnamese national ID card into structured fields, including a decomposed address hierarchy. Use it when your client already has the decoded QR string and needs it normalized without submitting an image.

Endpoint ​

http
POST /v1/parse_qr_info_sync
Content-Type: application/json
json
{
  "raw_qr": "string"
}

Parameters:

ParamTypeRequiredDefaultDescription
raw_qrstringYes—Raw QR code string from the card. Pipe-separated in order: Identity Number (12 digits) | Old Identity Number (9 digits or empty) | Full Name | Date of Birth (DDMMYYYY) | Gender (Nam/Nữ) | Native Place | Issue Date (DDMMYYYY).

Returns: ParseQrInfoResponse

Sample Request ​

bash
curl --location '<BASE_URL>/v1/parse_qr_info_sync' \
  --header 'Authorization: ATV <ACCESS_ID>:<SIGNATURE>' \
  --header 'X-TV-Timestamp: <TIMESTAMP>' \
  --header 'Content-Type: application/json' \
  --data '{
    "raw_qr": "001xxxxxxxxx|xxxxxxxxx|Nguyễn Văn A|12121990|Nam|Tổ 1, Phường Bến Nghé, Quận 1, TP. Hồ Chí Minh|01012021"
  }'

Response ​

json
{
  "success": true,
  "code": 0,
  "message": "Success",
  "data": {
    "request_id": "f48085e4-3ae4-40bb-b0e1-9b2c72575bc1",
    "status": "success",
    "qr": {
      "parsed": [
        { "field": "id", "value": "001xxxxxxxxx", "confidence_score": 1.0, "confidence_verdict": "" },
        { "field": "name", "value": "Nguyễn Văn A", "confidence_score": 1.0, "confidence_verdict": "" },
        { "field": "dob", "value": "12/12/1990", "confidence_score": 1.0, "confidence_verdict": "" },
        { "field": "address_level_1_(city)", "value": "TP. Hồ Chí Minh", "confidence_score": 1.0, "confidence_verdict": "" }
      ],
      "raw": "001xxxxxxxxx|xxxxxxxxx|Nguyễn Văn A|12121990|Nam|Tổ 1, Phường Bến Nghé, Quận 1, TP. Hồ Chí Minh|01012021"
    }
  },
  "errors": []
}
FieldTypeDescription
data.request_idstringRequest ID; quote it to CAKE Support when checking logs.
data.statusstringsuccess or failure.
data.qr.rawstringThe raw QR string as submitted.
data.qr.parsedParsedField[]The structured fields extracted from the QR payload.

ParsedField ​

FieldTypeDescription
fieldstringField name — see the table below.
valuestringExtracted value.
confidence_scorefloatAlways 1.0 for QR, which is encoded rather than recognized.
confidence_verdictstringEmpty for QR-sourced fields.

Fields returned ​

The seven pipe-separated inputs, plus a decomposed address hierarchy derived from the native place:

FieldTypeDescription
idstringNID number, 12 digits.
id_1stringLegacy CMND number, 9 digits.
namestringFull name.
dobstringDate of birth, normalized to DD/MM/YYYY.
genderstringNam or Nữ.
native_placestringPlace of origin as printed.
issue_datestringIssue date, normalized to DD/MM/YYYY.
address_level_1_(city)stringProvince or centrally-managed city.
address_level_1_(city)_codestringProvincial administrative code.
address_level_2_(district)stringDistrict.
address_level_2_(district)_codestringDistrict administrative code.
address_level_3_(ward)stringWard, commune or township.
address_level_3_(ward)_codestringWard administrative code.
address_level_4stringHamlet or residential group.

Dates arrive as DDMMYYYY and come back as DD/MM/YYYY.

Errors ​

Validation of the QR payload has its own 2007xxx code range:

CodeMessage
2007001Invalid QR identity number.
2007002Invalid QR old identity number.
2007003Invalid QR date of birth.
2007004Invalid QR gender value.
2007005Invalid QR issue date.
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
invalid_qr_identity_numberIdentity number must be exactly 12 digits.
invalid_qr_old_identity_numberOld identity number must be empty or exactly 9 digits.
invalid_qr_date_of_birthDate of birth format is invalid or the date does not exist. Expected format DDMMYYYY.
invalid_qr_gender_valueGender must be either Nam (male) or Nữ (female).
invalid_qr_issue_dateIssue date format is invalid or the date does not exist. Expected format DDMMYYYY.
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.
internal_server_errorSome unexpected error occurs while processing the request.

Next Steps ​

Developers