This topic describes how to call the Initialize API operation to start an ID document Optical Character Recognition (OCR) process.
Initiate an authentication request
-
API operation: Initialize
-
Request method: HTTPS POST
-
Description: Before starting an ID document OCR process, call this operation to obtain a transactionId and a transactionUrl. These are used to link the API operations in the authentication request.
-
This API operation has a dedicated QPS limit. For more information, see QPS limits for ID Verification server-side API operations.
-
Endpoint:
NoteBenefits of internal network access: An internal network is a private communication network between Alibaba Cloud products within the same region. If your business server is deployed in the corresponding Alibaba Cloud region, you can use the internal same-region endpoint to access the ID Verification service. This provides more secure and stable communication.
Optimization suggestions for access from outside China: Network environments outside China can be complex. To optimize your integration solution, reduce network latency, and minimize request failures, see Server-side network latency analysis and optimization.
China (Hong Kong)
Public network:
cloudauth-intl.cn-hongkong.aliyuncs.comInternal network:
cloudauth-intl-vpc.cn-hongkong.aliyuncs.com
Online debugging and integration
Before you debug and integrate an API operation, see Debug and integrate server-side API operations using OpenAPI Explorer for information about how to call API operations and obtain SDKs and sample code in OpenAPI Explorer.
You can run and debug this API operation directly in OpenAPI Explorer, and generate SDK sample code.
Request parameters
|
Name |
Type |
Required |
Description |
Example |
|
ProductCode |
String |
Yes |
The product solution to use. Set the value to ID_OCR. |
ID_OCR |
|
MerchantBizId |
String |
Yes |
A custom unique business ID that you can use to track and troubleshoot issues. It must be a unique combination of up to 32 letters and digits. Note
Alibaba Cloud servers do not check the uniqueness of this value. To improve traceability, ensure this ID is unique. |
e0c34a77f5ac40a5aa5e6ed20c35**** |
|
MetaInfo |
String |
Yes |
The MetaInfo environment parameter. You must call the getMetaInfo() function through the JS file to obtain it. For more information about how to obtain MetaInfo, see the client integration document for the corresponding platform. Important
|
|
|
MerchantUserId |
String |
Yes |
A custom user ID or another identifier for a specific user, such as a mobile phone number or email address. Strongly recommend desensitizing this value in advance, for example, by hashing it. |
123456789 |
|
ReturnUrl |
String |
No |
The destination address to which your business page redirects. Important
This parameter is not required if you use an iframe for encapsulation. |
https://www.alibabacloud.com |
|
DocType |
String |
Yes |
The document type. It is a unique identifier composed of an 8-digit number. For more information, see the table below. |
01000000 |
|
SceneCode |
String |
No |
A custom authentication scene ID. You can enter this ID in the console to query related records. It can be a combination of up to 10 letters, digits, and underscores (_). |
1234567890 |
|
IdSpoof |
String |
No |
Specifies whether to enable document anti-spoofing detection:
|
Y |
|
IdThreshold |
String |
No |
The custom OCR quality detection threshold mode:
|
0 |
|
ShowAlbumIcon |
String |
No |
Specifies whether to display the album upload entry during the ID document OCR process:
|
1 |
|
ShowOcrResult |
String |
No |
Specifies whether to display the result page after the ID document OCR process:
|
1 |
|
ShowGuidePage |
String |
No |
Specifies whether to display the guide page:
|
1 |
|
CallbackUrl |
String |
No |
The webhook address for verification result notifications. The callback request method is GET by default. The webhook address must start with
Warning
|
https://www.aliyun.com?callbackToken=100000****&transactionId=shaxxxx&passed=Y&subCode=200 |
|
CallbackToken |
String |
No |
A security token that you generate. It is used for anti-replay and tamper-proofing checks. If you set this parameter, the CallbackToken field is included in the CallbackUrl webhook. |
NMjvQanQgplBSaEI0sL******** |
|
LanguageConfig |
String |
No |
The custom language configurations. Convert the language configurations that you want to add to a JSON string based on the configuration template. Then, specify this parameter to add the custom language configurations. For more information, see Internationalization language and custom text support. |
|
|
StyleConfig |
String |
No |
The custom UI configurations. Convert the UI configurations that you want to add to a JSON string based on the configuration template. Then, specify this parameter to add the custom UI configurations. For more information, see IDV UI style customization. |
|
|
EditOcrResult |
String |
No |
Specifies whether users can edit information on the OCR result page.
|
0 |
Document type list
|
DocType |
Corresponding document |
|
01000000 |
Global Passport |
|
00000006 |
Hong Kong Identity Card (2003 version) |
|
00000008 |
Hong Kong Identity Card (2018 version) |
|
00000007 |
Exit-Entry Permit for Travelling to and from Hong Kong and Macao |
|
00000009 |
Mainland Travel Permits for Hong Kong and Macao Residents |
|
000000011 |
Macao Identity Card |
|
000000012 |
Mainland Travel Permit for Taiwan Residents |
|
00000001 |
Second-generation resident identity card of the Chinese mainland |
Returned Data
|
Name |
Type |
Description |
Example |
|
|
HTTP Status Code |
Integer |
The HTTP status code. |
200 |
|
|
HTTP Body |
RequestId |
String |
The request ID. |
130A2C10-B9EE-4D84-88E3-5384******** |
|
Code |
String |
Success |
||
|
Message |
String |
The detailed description of the response code. |
success |
|
|
Result.TransactionId |
String |
The unique identifier for the entire verification flow. This field is used for billing statistics and to initiate a CheckResult API operation request. Important
|
hksb7ba1b28130d24e015d6******** |
|
|
Result.TransactionUrl |
String |
The web authentication URL. After authentication completes, the page redirects based on the ReturnUrl request parameter. Important
|
https://www.alibabacloud.com/index.html?clientcfg=**** |
|
|
Result.Protocol |
String |
The standard encryption protocol for authentication. We recommend that you obtain this parameter and pass it to the client SDK. The client SDK uses this parameter to reduce network interactions and support dynamic network switching, improving user experience. Note For H5 web integration using an iframe, this field is required. |
hksb7ba1b28130d24e015d********* |
|
Return Code
HTTP status code | Code | Description |
200 | Success | Request successful. |
400 | MissingParameter | Parameter cannot be empty. |
InvalidParameter | Invalid parameter. | |
401 | Forbidden.ExceptionRepeatedInvoke | The number of repeated abnormal calls exceeds the limit. |
403 | Forbidden.RAMUserAccessDenied | You need to grant the RAM user the AliyunAntCloudAuthFullAccess permission. For more information, see Authorize RAM users to access the service. |
Forbidden.AccountAccessDenied | Ensure that you have activated ID verification and your account has no overdue payment. | |
Throttling.Api | API request is blocked due to throttling. | |
500 | InternalError | Internal system error. Provide feedback to engineers for troubleshooting. |
503 | ServiceUnavailable | The service is unavailable. Contact engineers for troubleshooting. |