• Console

›Identity Verification Premium

FaceID service introduction

  • FaceID
  • FaceID-Pro

Identity Verification Basic

  • App-GetBizToken
  • App-Verify
  • App-Authentication
  • H5-Raw-UploadVideo
  • H5-Raw-Verify

Identity Verification Premium

  • APP_Pro-Access-Guide
  • APP_Pro-Authentication
  • APP_Pro-Encrption-Guide
  • APP_Pro-GetBiztoken
  • APP_Pro-Liveness
  • APP_Pro-Verify
  • H5-Lite_Pro-Access-Guide
  • H5-Lite_Pro-GetToken
  • H5-Lite_Pro-Redirect-To-Liveness-URL
  • H5-Lite_Pro-Callbacks
  • H5-Lite_Pro-GetResult
  • H5-Lite_Pro-UsinginAnApp
  • H5-Lite_Pro-UI-Customization
  • H5-Lite_Pro-RTC-Compatibility

OCR

  • Indonesian_ID_Card
H5-Lite_Pro-GetToken

Describe

This API is provided for the FaceID H5 verification service. You can use this API to obtain a token (each token is unique and can only be used once). This API also helps complete face comparison and return the comparison results after verification for easy integration.

Call URL

Indonesia region :https://api-idn.megvii.com/faceid/lite/get_token

Note : Please use HTTPS in production environments. HTTP communication is not secure, poses risks, and is not recommended for production environments. If you use HTTP in production environments, service reliability cannot be guaranteed.

Call method

POST Note: Use form-data format to request

Permissions

Only when the user accesses the FaceID product can the FaceID Web APIs be called. Please consult FaceID business personnel for the process of accessing FaceID.

Parameter

Required/optionalparametertypeParameter Description
Requiredapi_keyStringThe api_key used to call this API.
Requiredapi_secretStringThe secret of the api_key used to call this API.
Requiredreturn_urlStringThe destination URL to redirect to after the user completes or cancels the verification (the callback method is POST).
Requirednotify_urlStringThe customer server URL the FaceID server requests after the user completes or cancels the verification or the verification times out. (An HTTPS URL is recommended. If an HTTP URL is used, you need to verify the request with a signature. The callback method is POST.) Note: For security reasons, the FaceID verification service only supports ports 443, 5000, 16003, 8883, and 8028 for server callbacks.
Requiredbiz_noStringThe serial number of the customer business. The value of this parameter must be unique. This number is returned to your server in notify and return to help you confirm business relationships. The length of the value cannot exceed 128 bytes.
Optionalbiz_extra_dataStringThe additional data returned when notify_url and return_url are invoked. You can use this to pass additional information for debugging and other purposes. The length of the value cannot exceed 4096 bytes.
Optionalscene_idStringThe scene_id of the scene configured in the console. This is used to customize UI elements in the verification process. If you do not pass this parameter, the default scene in the console is used. If no scene is configured in the console, the default solution of the system is used. If you use a scene_id that does not exist, the API fails and returns the error code 400 (BAD_ARGUMENTS).
OptionallanguageStringThis parameter is optional. This parameter is used to change the language of the page.
  0: English (default)
  1: Chinese
  2: Indonesian
  3: Thai
  4: Filipino
  5: Vietnamesei
  6: Spanish
Optionalprocedure_typeStringThe method of the liveness detection process. Valid values:
  "flash": Flash-based liveness detection.
  "distance": 3D liveness detection.
  "still": Passive liveness detection with a video selfie ranging from 0.5 to 10 seconds.
The default value of this parameter is "flash".
Optionalprocedure_priorityStringThis parameter is optional. This parameter is used to configure the alternative solution when WebRTC is not supported.
  still: Use still (passive) detection first. If passive detection is not supported, use the pre-installed camera app to record the video.
  keep: No alternative solution is used. If the browser is not supported, return.
Default value:
  If procedure_type is flash, the default value is "still".
  If procedure_type is distance, the default value is "still".
If you set this parameter to another value, the error code 400 (BAD_ARGUMENTS) is returned.
Optionalget_shooting_errorStringThis parameter specified whether to obtain the shooting error. Valid values:
  "1": Obtain the error for not uploading the video in a long time.
  "0": Do not obtain the error for not uploading the video in a long time.
Note: If the value of this parameter is "1" and the user's video is not received in the FaceID face verification process, the error message {"shooting_error":true/false} is returned in return_url and notify_url. If the value of this parameter is "0", no error message is returned even if the user's video is not received in the FaceID face verification process. The default value is "0".
Optionalmaximum_shooting_timeIntThe timeout configuration after the user taps to start shooting. After this time, the pop-up window that contains the message "Recorded video not received in a long time" appears. Note: Valid values of this parameter range from 2 to 60 seconds.
The default value of this parameter is 15 seconds. We recommend that you set this to 10 to 15 seconds.
Requiredcomparison_typeStringSet the type of the service. The current supported options are "liveness check+face comparison" (value "0") and "only liveness check without face comparison" (value "-1"). Passing other values ​​​ will be recognized and error code 400 (BAD_ARGUMENTS) will be returned.
  “0” indicates that liveness check+face comparison.
  “-1” indicates that only liveness check will be operated without face comparison.
comparison_type=0,RequireduuidStringIf no reference data is used for comparison, this field is uploaded. This parameter is the ID used to uniquely identify the user in this verification. The length of this parameter cannot exceed 512 bytes. We recommend that you use the same ID for comparison requests of the same user to help you query and view verification results and obtain better reports.
comparison_type=0,Requiredimage_ref [x]FileThe face reference photos you provide. x indicates that you can provide multiple photos. In this case, 1 <= x <= 2 and 2 face reference photos can be uploaded (the parameters are image_ref1 and image_ref2). If no face is detected in one of the photos in image_ref1 and image_ref2, the error code 400 (NO_FACE_FOUND) is returned. If multiple faces are detected in one of the photos, the error code 400 (MULTIPLE_FACES) is returned.
comparison_type=-1,RequireduuidStringThis parameter is the ID used to uniquely identify the user in this verification. The length of this parameter cannot exceed 512 bytes. We recommend that you use the same ID for comparison requests of the same user to help you query and view verification results and obtain better reports.
Optionalmulti_oriented_detectionStringThis parameter specifies whether to rotate the photos in image_ref [x ] by 90, 180, and 270 degrees for face detection if no face is detected. The valid values of this parameter are "1" and "0" (default is "0").
  1: Rotate.
  0: Do not rotate.
  Other value: The error code 400 (BAD_ARGUMENTS) is returned.
Note: Setting this parameter to 1 might increase the false positive rate of face detection. If your business scenario does not contain or contain few photos with different orientations, you can ignore this parameter.
Optionalfail_when_ref_multiple_facesStringThis parameter specifies whether to immediately return an error code if multiple faces are detected in the face reference photos (image_ref[x]). Valid values:
  1: Immediately return error code 400 (MULTIPLE_FACES).
  0: Use the largest face in the photo for comparison.
Note: The default value of this parameter is "1".
Optionalreturn_multifaces_tagStringThis parameter specifies whether to return the multiple faces tag.
  0: Do not return (default)
  1: Return
Optionalfmp_modeStringThis parameter specifies whether to perform cloud face spoofing attack identification in the liveness detection results. The default value is 1. Valid values:
  1: Do not perform cloud face spoofing attack identification (synthetic faces, masks, and screen replays) in the liveness detection results, but return the attack scores. You can design subsequent processes based on your business needs and the attack scores.
  0: Perform cloud face spoofing attack identification in the liveness detection results.
If you choose the RTC liveness detection method (update_rtc), this parameter is ignored and cloud face spoofing attack identification is always performed. Note: For details about the liveness detection results, see the "liveness_result" parameter in the "Return value" section of "Lite-GetResult".
Optionalget_fail_reasonStringThis parameter specifies whether to return the reason for failure if the fail_reason is WEBRTC_UNSUPPORTED (default value is "0"). Valid values:
  1: Return reason for failure.
  0: Do not return reason for failure.
Optionalface_occlusion_detectionStringThis parameter specifies whether to enable face occlusion detection. Valid values:
  0: Disable (default).
  1: Enable. If the user's face is obstructed during the entire process,the verification fails.
Optionaleye_close_detectionStringThis parameter specifies whether to enable closed eye detection. Valid values:
  0: Disable .
  1: Enable(default).
Optionalaction_http_methodStringThe method used to redirect to return_url.
  POST: (Default) Return detailed data in the form format. For details, see Callbacks.
  GET: Return biz_id as a parameter in the return_url. For details, see Callbacks.
Optionalredirect_typeStringThe redirect method of the page (if redirect_type =1 and action_http_method=GET, users can go back to the previous page before FaceID Lite by tapping the Back button in the browser or on the phone). Valid values:
  0: (Default) Normal redirect if this parameter is not used or 0 is set.
  1: Use replace for page redirects, which does not leave a record in the browser's history.

Return value description

Fieldtypeillustrate
request_idStringThe unique string used to identify each request. This string can be used to query data later. This field is always returned.
time_usedIntThe time taken by the entire request in milliseconds. This field is always returned.
tokenStringThe string that is used as a parameter to call the DoVerification API to perform liveness detection based on the above configurations. (Note: Each token can only be used once.)
biz_idStringThe business ID used to query comparison results.
expired_timeIntThe timestamp that indicates the expiration time of the token.
error_messageStringThis string is returned if the request fails. For the details of this field, see the "Error codes" section below. If the request is successful, this field is not returned.

Return value example

Correct request return example

{
    "time_used": 5,
    "token": "34fb21937e47ae719f11cbc719615687",
    "biz_id": "1462259748,52b13fb5-8dfb-4537-a62b-a641d5e929f1",
    "request_id": "1462257147,3149525e-2c24-4862-8e9f-92040595f0a4",
    "expired_time": 1462257765
}

Failed request return example

{
    "error_message": "BAD_ARGUMENTS: return_url",
    "request_id": "1461740007,71eeb124-08f0-47b3-8fc8-ac048cfa1372",
    "time_used": 4
}

Error code list

ERROR_MESSAGE specific to GetToken

HTTP status codeerror fieldvalueillustrate
400error_messageIMAGE_ERROR_UNSUPPORTED_FORMAThe <param> parameter is the image that cannot be parsed. The file might not be an image or the data is corrupted. <param> is image_ref1 or image_ref2. Note: The error message only contains one <param> that corresponds to the first image that meets the conditions. <param> is image_ref1 or image_ref2.
400error_messageNO_FACE_FOUNDThis error indicates that no face is detected in the uploaded image in image_ref[x].
400error_messageINVALID_TOKENThe token does not exist, has expired, is invalid, or is not returned by the API with the same API key.
400error_messageMULTIPLE_FACESThis error indicates that multiple faces are detected in the uploaded image in image_ref[x].

General ERROR_MESSAGE

HTTP status codeerror fieldvalueillustrate
403errorAUTHENTICATION_ERRORapi_key and api_secret do not match.
403errorAUTHORIZATION_ERROR:<reason>The api_key is disabled, call limit is reached, no permission to call this API, or no permission to call this API with the current method. Valid values for <reason> include "Denied." (no permission to call this API).
403error_messageCONCURRENCY_LIMIT_EXCEEDEDThe concurrency limit is exceeded.
400error_messageMISSING_ARGUMENTS:<key>A required parameter is missing.
400error_messageBAD_ARGUMENTS:<key>An error occurred while parsing a parameter (for example, a parameter is a number but a non-numeric string is used, or the value is too long).
404errorAPI_NOT_FOUNDThe API does not exist.
500error_messageINTERNAL_ERRORInternal server error. If this error occurs, send the request again. If this persists, contact FaceID customer service or business support.

© 2012-2021 北京旷视科技有限公司 版权所有 | 京ICP备12036813号-6

京公网安备 11010802025957号