This topic describes how to call the Initialize API operation to start a face liveness verification request.
Initiate a verification request
-
API operation: Initialize
-
Request method: HTTPS POST
-
Description: Before starting a verification flow, call this API operation to obtain a transactionId. This ID links all API operations in the verification 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 debug this API operation in OpenAPI Explorer. You can also generate sample SDK code for this operation.
Input image format requirements
Image format: JPG, JPEG, or PNG.
Image size: 50 KB to 100 KB is recommended. The maximum size is 1 MB.
Image resolution: The resolution must be between 640 × 480 pixels (height × width) and 1920 × 1080 pixels. We recommend scaling the shorter side to 720 pixels with a compression ratio greater than 0.9. The image height should be greater than the width. If the width is greater than the height, detection accuracy may be reduced.
NoteConverting an image to Base64 format increases its data size. To pass parameters in Base64 format, ensure that the original image size does not exceed 0.6 MB to avoid exceeding the 1 MB data transfer limit.
Image quality recommendations:
The face in the image must be complete, clear, and unobstructed. The subject should be facing the camera directly. We recommend using facial images captured by a front-facing camera.
The face should occupy more than 60% of the image area. A smaller face may reduce detection accuracy.
If there are multiple faces in the image, the algorithm crops the largest face by default. We recommend avoiding images with multiple faces.
Request parameters
|
Name |
Type |
Required |
Description |
Example |
|
ProductCode |
String |
Yes |
The product solution to use. The only valid value is FACE_VERIFY. |
FACE_VERIFY |
|
SceneCode |
String |
No |
A custom ID for the verification scenario. You can use this ID to query related records in the console. The ID can be up to 10 characters in length and can contain letters, digits, and underscores (_). |
1234567890 |
|
MerchantBizId |
String |
Yes |
A custom unique business ID. You can use this ID to track and troubleshoot issues. The ID can be up to 32 characters in length and can contain letters and digits. Make sure the ID is unique. Note
Alibaba Cloud servers do not check the uniqueness of this field. For better tracking, we strongly recommend that you ensure the uniqueness of this field. |
e0c34a77f5ac40a5aa5e6ed20c35**** |
|
MetaInfo |
String |
Yes |
The MetaInfo environment parameter. Obtain this parameter using the client SDK. For more information, see Android integration. Note
Do not modify the return value. Pass it through directly. |
|
|
MerchantUserId |
String |
Yes |
A custom user ID or another identifier for a specific user, such as a mobile phone number or an email address. We strongly recommend that you desensitize the value of this field in advance, for example, by hashing the value. |
123456789 |
|
FacePictureBase64 |
String |
No |
The Base64-encoded face image. If you use the FacePictureBase64 parameter to pass the face image, check the image size. Do not pass an oversized image. |
/9j/4AAQSkZJRgABAQAASASBC**** |
|
FacePictureUrl |
String |
No |
The URL of the face image. The URL must be an HTTP or HTTPS link that is accessible over the public network. Note
If ProductCode is set to FACE_VERIFY, you must specify either FacePictureBase64 or FacePictureUrl. |
https://cn-shanghai-aliyun-cloudauth-****.oss-cn-shanghai.aliyuncs.com/verify/****.jpeg |
|
SecurityLevel |
String |
No |
The mode that represents different security levels of the verification flow. Valid values:
|
02 |
|
Model |
String |
No |
The type of liveness detection to perform:
Note For information about the supported SDK versions, see SDK release notes. |
PHOTINUS_LIVENESS |
|
DocVideo |
String |
No |
Specifies whether to save a verification video.
Note Because the video file is large, the system may discard it if the network is unstable to prioritize the transmission of essential verification images. |
N |
|
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. |
NMjvQanQgplBSaEI0sL86WnQplB |
|
AppQualityCheck |
String |
No |
Specifies whether to enable strict face quality checks.
Important
|
N |
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-5384FF0**** |
|
Code |
String |
Success |
||
|
Message |
String |
A detailed description of the return 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.Protocol |
String |
The standard encrypted protocol for verification. 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 to improve user experience. |
hksb7ba1b28130d24e015d********* |
|
Return codes
HTTP Status Code | Code | Description |
200 | Success | The request was successful. |
400 | MissingParameter | A parameter cannot be empty. |
400 | InvalidParameter | The parameter is invalid. |
401 | NoFaceDetected | Feature extraction failed for the face in the custom source image. Upload a different image. |
401 | UnqualifiedPhoto | The uploaded image is unreadable or its resolution does not meet the requirements. Replace the image. Make sure that the photo is clear, properly exposed, complete, and unobscured, and that the subject's head has no significant tilt. |
401 | ToolargeImage | The image is too large. Compress the image or use a different upload method. |
401 | DataDuplication | You can also pass images using Base64 or a link. |
401 | DownloadTimeout | The image download from the URL timed out. |
403 | Forbidden.RAMUserAccessDenied | Grant the AliyunAntCloudAuthFullAccess permission to the Resource Access Management (RAM) user. For more information, see Grant a RAM user permissions to access the service. |
403 | Forbidden.AccountAccessDenied | Make sure that you have activated ID Verification and that your account does not have an overdue payment. |
403 | Throttling.Api | The API call is blocked by throttling. |
500 | InternalError | An internal system error occurred. Contact technical support for assistance. |