Face Authentication

Common objects & errors

The Face Authentication endpoints are built from a small set of shared request and response objects, and they fail the same way at the transport layer — all of it defined once, here, and referred to by name from each endpoint page.

Request objects

Clients can provide image data to the TrustVision API by specifying the ID the image by using upload API, or by sending the image data as base64-encoded text.

image

One image. Register a face takes an array of them in faces and a single one in face_in_id_card; Authenticate takes an array in faces; gesture_image nests an array in images.

NameTypeRequiredDescription
idstringOptionalID of image is returned from API Upload
base64stringOptionalbase64 encoded text of image data
labelstringOptionallabel of the image as described at Label table
metadatastring_jsonOptionalkey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"

If you use id (result id is returned from Upload Image API), omit parameter base64, label and metadata. If you use base64, label and metadata, omit parameter id.

gesture_image

One gesture together with the images captured for it. Register a face and Authenticate both take an array of them in gesture_faces.

NameTypeRequiredDescription
gesturestringRequiredspecify a gesture value from Gesture values. Example left, right, up or down
images[]imageRequiredan array of images for each gesture

video

One video. Register a face and Authenticate both take an array of them in videos; gesture_video nests an array in videos.

NameTypeRequiredDescription
idstringOptionalID of video is returned from API Upload
metadatastring_jsonOptionalkey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"
frames[]FrameDataOptionallist of video frames to be uploaded

If you use id (result id is returned from Upload File API), omit parameter frames, metadata. If you use frames, metadata, omit parameter id.

FrameData

One frame of a video, for the case where frames are sent inline rather than by upload id.

NameTypeRequiredDescription
base64stringOptionalbase64 encoded text of image data
labelstringOptionallabel of the image as described at Label table
indexintOptionalthe index of this frame in the video
metadatastring_jsonOptionalkey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"

gesture_video

One gesture together with the videos captured for it. Register a face and Authenticate both take an array of them in gesture_videos.

NameTypeRequiredDescription
gesturestringRequiredspecify a gesture value from Gesture values. Example left, right, up or down
videos[]videoRequiredan array of videos for each gesture

Enums

Gesture values

The values the gesture parameter accepts, on both gesture_image and gesture_video.

GesturesDescription
leftthe face turns left
rightthe face turns left
upthe face up
downthe face down

Response objects

history

One record of a past registration or authentication. Register a face, Authenticate and Check registration all return an array of them in data.histories.

NameTypeDescription
idstringid of this history
client_idstringclient id
cus_user_idstringuser id
face_auth_idstringid of selfie image containing user's face
id_card_face_idstringid of id card image containing user's face
live_face_idstringid of input image for this request
device_idstringdevice id input for this request
app_idstringapp id input for this request
latitudefloatlatitude input for this request
longitudefloatlongitude input for this request
created_atstringtime of this request
auth_actionstringthe action this record belongs to (register, login)
statusstringsuccess or failure
resultstringdetail result of this request
metadatajson_objectmetadata input for this request
face_typestringtype of face for this request (selfie, id_card) — the face input on registration, the face compared against the input face on authentication

face_auth_user

The user record as it stands after the call. Unregister returns it in data.face_auth_user as the user information after unregistration, and Unlock returns it as the user information after unlock.

NameType
idstring
client_idstring
access_key_idstring
face_auth_idstring
id_card_face_idstring
cus_user_idstring
device_idstring
app_idstring
latitudefloat
longitudefloat
metadatajson_object
is_deactivatedbool
is_unregisteredbool
created_atstring_time
updated_atstring_time

Error envelope

Every response carries an errors array alongside data. When data.status is "failure" it tells you why the request failed; when the call failed before processing, data is empty and errors carries the transport error.

JSON
{
    "errors": [
        {
            "code": string,
            "message": string,
            "detail": {
                "field": string, // optional, which parameter is invalid.
                ... // any other information that can be useful for client
            },
        },
        ... // other errors
    ]
}

Each entry contains:

NameTypeDescription
codestringwhich error occurred — see Shared transport errors, or the failure codes on the endpoint's own page
messagestringthe message that accompanies the code
detailjson_objectfield is optional and says which parameter is invalid, plus any other information that can be useful for client

Shared transport errors

In case of any other errors, the data field will be empty, and the server sends one of the following HTTP status codes with an error code. These are the same on every Face Authentication call.

HTTP codeerror codedescription
401access_denied_exceptionYou are not authorized to perform the action.
400invalid_parameter_exceptionInput parameter violates a constraint.
400request_time_too_skewedThe X-TV-Timestamp header is expired, need a newer one.
400incorrect_number_of_facesSelfie or original image have more than 1 faces.
404image_not_found_exceptionThe image ID is not found in DB.
404request_not_found_exceptionThe request ID is not found when polling result by id
404face_auth_user_not_found_exceptionThe user of face_auth service not found.
408request_timeout_exceptionRequest takes too long to process
429rate_limit_exceptionThe number of requests exceeded your throughput limit.
500internal_server_errorSome unexpected error occurs while processing the request

A code that arrives with HTTP 200 and data.status: "failure" belongs to the endpoint that returned it, and is documented under Failure codes on that endpoint's own page.