• 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
  • H5-RAW_Pro-JS-SDK
  • H5-RAW_Pro-GetToken
  • H5-RAW_Pro-GetResult
  • H5-RAW_Pro-CommonProblem

OCR

  • Indonesian_ID_Card
H5-Lite_RAW-GetToken

Describe

The server requests the Raw-GetToken interface to obtain the token parameter, which serves as the imported parameter for calling the js-sdk.

Call URL

  • Singapore: https://api-sgp.megvii.com/facoid/lite/raw/get_token
  • Note:
    • In the production environment, use HTTPS for communication. HTTP is insecure and poses security risks; do not use it in production.
    • Using HTTP in production will not guarantee service reliability.

Call Method

  • Method: POST
  • Format: Request in form-data format.

Parameters

Parameters must be passed in form-data format. Below is a summary table:

ParameterTypeRequired/OptionalDescription
api_keyStringRequiredAPI key for calling this API.
api_secretStringRequiredThe secret of the api_key for calling this API.
biz_noStringOptionalUsed to mark a verification process (max length 128 bytes). Use the same biz_no for APIs in a single verification process (e.g., Raw-GetTokenFlash, Raw-GetResultFlash), and different biz_no for different processes.
color_numberIntOptionalNumber of lighting colors during the flash sensor face ID process. Allowed values: 4, 6, 8. Recommended: 6.
liveness_preferencesStringOptionalSets the strictness level of live detection. Options: "none" (Quick Mode, default).
languageStringOptionalThis parameter is optional, and the page prompt language can be switched through this parameter,0: English (default),1: Chinese
procedure_typeStringOptionalSpecifies the live detection method. Only supported value: "raw_flash" (flash sensor face ID).
comparison_typeStringRequiredComparison method. Options: "0" (face comparing, compares with user-provided photo in image_ref[x]). Note: If the appkey lacks face comparing permission, this will return error 403 (AUTHORIZATION_ERROR: Denied).
uuidStringRequiredUnique ID for the user (max 512 bytes), used if no reference data is provided for comparison. Use the same ID for comparison requests from the same user to improve result tracking and reporting.
image_ref[x]FileRequiredUser-provided reference face photos. x can be 1 or 2 (e.g., image_ref1, image_ref2). Max 2 photos. Errors: 400 (NO_FACE_FOUND) if no face is detected, 400 (MULTIPLE_FACES) if multiple faces found in any image.
multi_oriented_detectionStringOptionalThis 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.
fail_when_ref_multiple_facesStringOptionalThis 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".
max_upload_timesIntRequiredThis parameter is used to set the maximum number of uploads, with an allowed setting range of 2 - 5 times. It is recommended to set it to 5 (times).
life_timeIntRequiredThis parameter is used to set the valid period of the token, with an allowed setting range of 5 - 1440 (unit: minutes). This parameter determines the valid period of the query results. It is recommended to set it to 60 (minutes).
return_multifaces_tagStringOptionalThis parameter specifies whether to return the multiple faces tag.
  0: Do not return (default)
  1: Return
face_occlusion_detectionStringOptionalEnables facial occlusion detection. Values: "0" (disabled, default), "1" (enabled; liveness check fails if occlusion occurs).

Notes on parameters:

  • For image_ref[x]: If no face is found or multiple faces are detected, the first problematic image triggers the error (e.g., image_ref1).
  • For comparison_type: Only "0" is valid; other values return error 400 (BAD_ARGUMENTS).

API Response

Returns a JSON string. Fields:

FieldTypeDescription
request_idStringUnique string to distinguish each request. Always returned except for error 404 (API_NOT_FOUND).
biz_noStringReturned only if biz_no was set in the request. Value matches the input biz_no.
time_usedIntTime taken for the entire request in milliseconds. Always returned except for error 404 (API_NOT_FOUND).
tokenStringReturned only on success. Used as a parameter for the Raw-ValidateFlash interface (max 1024 bytes). Note: Default validity period is 1 hour.
error_messageStringReturned only on failure. Describes the error (see Error Code List below). Not present on success.

Error Code List

Below are common and specific errors. All errors return JSON except where noted.

Universal Errors

HTTP Status CodeError MessageDescriptionIs it billed?
403AUTHENTICATION_ERRORInvalid signature.No
403CONCURRENCY_LIMIT_EXCEEDEDConcurrency exceeds the limit.No
400MISSING_ARGUMENTS:<key>Missing a required parameter. <key> indicates the missing parameter.No
400BAD_ARGUMENTS:<key>Error parsing a parameter (e.g., non-numeric string where number expected, or length too long). <key> indicates the invalid parameter.No
400IMAGE_ERROR_UNSUPPORTED_FORMAT:<param>Image for <param> (e.g., image_ref1) cannot be parsed (not an image file or corrupted data). Only the first invalid parameter is reported.No
400NO_FACE_FOUND:<param>No face detected in the image for <param> (e.g., image_ref1). Only the first problematic parameter is reported.No
400INVALID_IMAGE_SIZE:<param>Image for <param> exceeds size limits (e.g., pixel dimensions > 4096px). Only the first invalid parameter is reported.No
403AUTHORIZATION_ERROR:<reason>Permission issue. <reason> values: API_KEY_BE_DISCONTINUED (api_key deactivated), IP_NOT_ALLOWED (IP blocked), LIMIT_REACHED (call limit reached for test keys), MORE_RETRY_TIMES (comparison retries exceeded), NO_VERIFY_PERMISSION (no face comparing permission), DENIED (no API permission).No
404API_NOT_FOUNDCalled API does not exist.No
413Request Entity Too LargeRequest size exceeds 20MB limit. Note: Returns plain text, not JSON.No
500INTERNAL_ERRORInternal server error. Retry the request. If persistent, contact FaceID support.No

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

京公网安备 11010802025957号