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.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Optional | ID of image is returned from API Upload |
base64 | string | Optional | base64 encoded text of image data |
label | string | Optional | label of the image as described at Label table |
metadata | string_json | Optional | key-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}" |
If you use
id(resultidis returned from Upload Image API), omit parameterbase64,labelandmetadata. If you usebase64,labelandmetadata, omit parameterid.
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.
| Name | Type | Required | Description |
|---|---|---|---|
gesture | string | Required | specify a gesture value from Gesture values. Example left, right, up or down |
images | []image | Required | an 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.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Optional | ID of video is returned from API Upload |
metadata | string_json | Optional | key-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}" |
frames | []FrameData | Optional | list of video frames to be uploaded |
If you use
id(resultidis returned from Upload File API), omit parameterframes,metadata. If you useframes,metadata, omit parameterid.
FrameData
One frame of a video, for the case where frames are sent inline rather than by upload id.
| Name | Type | Required | Description |
|---|---|---|---|
base64 | string | Optional | base64 encoded text of image data |
label | string | Optional | label of the image as described at Label table |
index | int | Optional | the index of this frame in the video |
metadata | string_json | Optional | key-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.
| Name | Type | Required | Description |
|---|---|---|---|
gesture | string | Required | specify a gesture value from Gesture values. Example left, right, up or down |
videos | []video | Required | an array of videos for each gesture |
Enums
Gesture values
The values the gesture parameter accepts, on both gesture_image and gesture_video.
| Gestures | Description |
|---|---|
left | the face turns left |
right | the face turns left |
up | the face up |
down | the 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.
| Name | Type | Description |
|---|---|---|
id | string | id of this history |
client_id | string | client id |
cus_user_id | string | user id |
face_auth_id | string | id of selfie image containing user's face |
id_card_face_id | string | id of id card image containing user's face |
live_face_id | string | id of input image for this request |
device_id | string | device id input for this request |
app_id | string | app id input for this request |
latitude | float | latitude input for this request |
longitude | float | longitude input for this request |
created_at | string | time of this request |
auth_action | string | the action this record belongs to (register, login) |
status | string | success or failure |
result | string | detail result of this request |
metadata | json_object | metadata input for this request |
face_type | string | type 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.
| Name | Type |
|---|---|
id | string |
client_id | string |
access_key_id | string |
face_auth_id | string |
id_card_face_id | string |
cus_user_id | string |
device_id | string |
app_id | string |
latitude | float |
longitude | float |
metadata | json_object |
is_deactivated | bool |
is_unregistered | bool |
created_at | string_time |
updated_at | string_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.
{
"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:
| Name | Type | Description |
|---|---|---|
code | string | which error occurred — see Shared transport errors, or the failure codes on the endpoint's own page |
message | string | the message that accompanies the code |
detail | json_object | field 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 code | error code | description |
|---|---|---|
401 | access_denied_exception | You are not authorized to perform the action. |
400 | invalid_parameter_exception | Input parameter violates a constraint. |
400 | request_time_too_skewed | The X-TV-Timestamp header is expired, need a newer one. |
400 | incorrect_number_of_faces | Selfie or original image have more than 1 faces. |
404 | image_not_found_exception | The image ID is not found in DB. |
404 | request_not_found_exception | The request ID is not found when polling result by id |
404 | face_auth_user_not_found_exception | The user of face_auth service not found. |
408 | request_timeout_exception | Request takes too long to process |
429 | rate_limit_exception | The number of requests exceeded your throughput limit. |
500 | internal_server_error | Some 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.