Skip to content

Detect ID Cards ​

Locates every ID card inside an image and returns its corner coordinates and card label. Use it to confirm a card is present and correctly framed before running OCR or tampering checks.

Endpoint ​

http
POST /v1/detect_id_cards_sync
Content-Type: application/json
json
{
  "card_type": "vn.national_id",
  "image": {
    "id": "a4facba3-334b-41fb-97e3-4766cb70ae29",
    "base64": "",
    "label": "id_card.vn.national_id.front",
    "metadata": "{}"
  }
}

Parameters:

ParamTypeRequiredDefaultDescription
card_typestringYes—Type of identity card. See Usage Recommendations.
imageImageDataYes—Image of the identity card's front side.

ImageData ​

typescript
interface ImageData {
  id?: string;
  base64?: string;
  label?: string;
  metadata?: string; // JSON string
}
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. If you use base64, also send label and metadata and omit id. If you use id, omit the other three.

Sample Request ​

bash
curl -X POST \
  '<BASE_URL>/v1/detect_id_cards_sync' \
  -H 'Authorization: ATV <ACCESS_ID>:<SIGNATURE>' \
  -H 'X-TV-Timestamp: <TIMESTAMP>' \
  -H 'Content-Type: application/json' \
  -d '{
    "card_type": "vn.national_id",
    "image": {
      "id": "a4facba3-334b-41fb-97e3-4766cb70ae29"
    }
  }'

Response ​

json
{
  "data": {
    "request_id": "f77bf948-fce3-48f3-b61c-396e4cd9a89b",
    "status": "success",
    "image": {
      "id": "854322f0-eb49-4bd6-b870-050fcc088d10",
      "cards": [
        {
          "card_box": {
            "top_left": { "x": 90.52290163561702, "y": 110.761657032324 },
            "top_right": { "x": 981.4022462964058, "y": 101.39770825190935 },
            "bottom_left": { "x": 102.62150720786303, "y": 679.5154545297846 },
            "bottom_right": { "x": 996.863339483738, "y": 661.6368409626185 }
          },
          "card_label": "vn.cccd_new.front",
          "transformed_image_id": ""
        }
      ]
    }
  },
  "errors": []
}
FieldTypeDescription
data.request_idstringRequest ID; quote it to CAKE Support when checking logs.
data.statusstringsuccess or failure.
data.image.idstringID of the analysed image.
data.image.cardsarrayOne entry per card detected in the image.
data.image.cards[].card_labelstringDetected card label, e.g. vn.cccd_new.front.
data.image.cards[].transformed_image_idstringID of the deskewed/cropped card image. Present only when the tenant setting enable_create_image is true.
data.image.cards[].card_boxCardBoxCorner coordinates of the detected card.

CardBox ​

FieldTypeDescription
top_leftPointTop-left corner, { "x": float, "y": float }.
top_rightPointTop-right corner.
bottom_leftPointBottom-left corner.
bottom_rightPointBottom-right corner.

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.
request_not_found_exceptionThe request ID is not found when polling result by id.
rate_limit_exceptionThe number of requests exceeded your throughput limit.
internal_server_errorSome unexpected error occurs while processing the request.

Next Steps ​

Developers