This topic describes the server-side integration of the DocOcrV2 API, which automatically extracts information from ID document images and performs anti-spoofing risk assessments.
API details
API: DocOcrV2
Request method: HTTPS POST
Description: Extracts information from various ID documents, such as passports and ID cards, and performs anti-spoofing checks.
QPS limit: Each API has its own QPS limit. For more information, see QPS limits of ID Verification server-side APIs.
Endpoints:
NoteBenefits of internal network access: An internal network is a private communication network connecting Alibaba Cloud products within the same region. If your application server is deployed in the same region, use the internal endpoint to access the ID Verification service for enhanced security and stability.
Optimizing overseas access: Overseas network environments can be complex. Refer to Optimize server network latency to tune your integration and reduce network latency and request failures.
China (Hong Kong)
Public endpoint:
cloudauth-intl.cn-hongkong.aliyuncs.comInternal endpoint:
cloudauth-intl-vpc.cn-hongkong.aliyuncs.com
Online debugging and integration
Before debugging and integration, read the Use OpenAPI document to learn how to call APIs on the OpenAPI platform and obtain the SDK.
In OpenAPI Explorer, you can directly run and debug this API, and generate SDK sample code.
Image format requirements
To ensure stable model performance, provide images that meet all of the following conditions:
Image format: JPG, JPEG, or PNG.
Size: The recommended size is 50 KB to 100 KB. The maximum size is 1 MB.
NoteSince the base64 encoding process increases data size, to stay within the 1 MB data transfer limit for base64 data, the original image must not exceed 0.6 MB.
Image resolution: Height and width must be between 201 and 8,191 pixels. A resolution of 480×640 (height × width) is recommended.
Image quality recommendations:
All four corners of the card must be visible. Do not cover any part of the card, as this can impair detection.
The card image must be clear, unobstructed, free of glare, and correctly oriented (not tilted or upside down).
The card must occupy more than 60% of the total image area. If the card area is too small, it can impair recognition accuracy.
Use a photo of an actual card.
Request parameters
Parameter | Type | Required | Description | Example |
ProductCode | String | Yes | The product plan to use. Set the value to ID_OCR_MIN for the ID document OCR API. | ID_OCR_MIN |
SceneCode | String | No | A custom authentication scenario ID that you can use to query related records in the console. The ID can be up to 10 characters long and can contain letters, digits, and underscores (_). | 1234567890 |
MerchantBizId | String | Yes | A custom unique business ID for tracking and troubleshooting. The ID can be a string of up to 32 letters and digits. Ensure this ID is unique for each request. Note Alibaba Cloud servers do not check the uniqueness of this field. For effective tracking, we strongly recommend ensuring the ID is unique. | e0c34a77f5ac40a5aa5e6ed20c35**** |
MerchantUserId | String | Yes | A custom user identifier, such as a phone number or email address. We strongly recommend masking this value before submission, for example, by using hashing. | 123456789 |
IdOcrPictureBase64 | String | No. Select one of the three upload methods. | The base64-encoded image of the ID document. If you use this method, verify the image size to avoid exceeding the data transfer limit. | base64 |
IdOcrPictureUrl | String | The publicly accessible HTTP or HTTPS URL of the ID document image. | https://*** | |
IdOcrPictureFile | InputStream | The file stream of the ID document image. | For integration instructions, see Special scenario: File upload with the Advance interface. | |
DocType | String | Yes | The document type, specified as an 8-digit unique identifier. For more information, see Document types. | 01000000 |
Spoof | String | No | [OCR Configuration] Specifies whether to enable the anti-spoofing feature. Note This parameter is valid only for the portrait side of the ID document.
| F |
IdThreshold | String | No | OCR card quality check:
| 3 |
CardSide | String | No | [OCR Configuration] The side of the ID document to recognize. Defaults to the portrait side.
Important This parameter applies only to resident identity cards from the People's Republic of China. | OCR_ID_NATIONAL_EMBLEM |
Document types
DocType | Document |
01000000 | Global passport |
00000006 | Hong Kong Identity Card (2003 edition) |
00000008 | Hong Kong Identity Card (2018 edition) |
00000007 | Exit-Entry Permit for Travelling to and from Hong Kong and Macao |
00000009 | Mainland Travel Permit for Hong Kong and Macao Residents |
000000011 | Macao SAR Resident Identity Card |
000000012 | Mainland Travel Permit for Taiwan Residents |
00000001 | Second-generation resident identity card of the Chinese mainland |
Response parameters
Parameter | Type | Description | Example | |
HTTP Status Code | Integer | The HTTP status code. | 200 | |
HTTP Body | RequestId | String | The request ID. | 130A2C10-B9EE-4D84-88E3-5384FF039**** |
Result.TransactionId | String | The unique ID for the entire authentication process. | hksb7ba1b28130d24e015d694361b**** | |
Code | String | The response code. For more information, see Server-side HTTP status codes. | Success | |
Message | String | A detailed description of the response code. | success | |
Result.Passed | String | The authentication result. Valid values:
| Y | |
Result.SubCode | String | A description of the authentication result. For more information, see Result.SubCode error codes. | 200 | |
Result.ExtIdInfo | String | The ID document recognition results. For information about the JSON format, see the example on the right. For more information, see ExtIdInfo. | | |
ExtIdInfo
Parameter | Type | Description | Example |
ocrIdInfo | String | Information extracted from the ID document. For more information, see ID Document OCR Fields (for Chinese-funded overseas enterprises). Note If the OCR process fails, this field is empty. | |
spoofInfo | String | The anti-spoofing detection result, which includes the risk decision and the detected risk type. Note Spoofing detection is performed only when the Spoof parameter is set to T. Otherwise, spoofResult returns N and spoofType is empty.
| |
Result.SubCode error codes
Error code | Billed | Description and suggestions |
200 | Yes | Authentication passed. |
211 | Yes | [Document solution] The image quality or resolution does not meet the requirements, or the image is incomplete. Ensure the document image is clear, properly exposed, complete, unobstructed, and correctly oriented. |
212 | Yes | [Document solution] Document anti-spoofing detection has detected a risk. Possible causes include screen recapture, tampering, or photocopying. |
213 | Yes | [Document solution] The specified document type was not detected (in specified document recognition mode), or the document type could not be identified (in automatic classification mode). Provide a clear, complete, and correctly oriented document image. |