Face · Standard API · eKYC Core
Face OTP
Compares a newly taken selfie against the original image and returns a matched, unmatched or unsure verdict with a similarity score, alongside a liveness verdict for the selfie.
Request
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.
{
"selfie": [{
"id": string,
"base64": string,
}],
"original": {
"id": string,
"base64": string
}
}
Each image in selfie, and the original image, is given by:
| key | type | required | description |
|---|---|---|---|
id | string | Optional | ID of them image in DB |
base64 | string | Optional | Base64 encoded text of image1 data |
- If you use
base64,labelandmetadata(labelandmetadataof the image as described at Upload Image API), omit parameterid. - If you use
id(resultidis returned from Upload Image API), omit parameterbase64,labelandmetadata. - Upto 3
selfieimages can be provided all of them will be used for liveness verification, but only the first selfie image will be used for comparing faces - Atleast one
selfieimage should be provided - The
originaland theselfieimage should not contain more than 1 face
Sample request
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/face_otp \
-H 'Authorization: TV <YOUR ACCESS KEY>:<CREATED SIGNATURE>' \
-H 'X-TV-Timestamp: 2019-04-21T18:00:15+07:00' \
-H 'Content-Type: application/json' \
-d \
'
{
"selfie": [
{
"id": "7db00808-0416-45cf-a5cb-3b6dfbd7bb74"
}
],
"original": {
"id": "a4facba3-334b-41fb-97e3-4766cb70ae29"
}
}
'
Response
data.compare_faces carries the comparison verdict and data.is_live the liveness verdict for the selfie. In case the request processing has been finished, the HTTP status code will be 200, and the data.status is either "success" or "failure" depending on whether the request has been successfully processed or not.
{
"data": {
"status": string, // "success" or "failure"
"is_live": bool, // the face is live or not
"compare_faces": {
"score": float, // how likely that face1 and face2 are matched (0-1)
"result": string // "matched", "unmatched", "unsure"
},
"request_id": string // return request id to the client and can use request-id to check logs.
},
"errors": [
{
"code": string,
"message": string,
"detail": {
"field": string, // optional, which parameter is invalid.
... // any other information that can be useful for client
},
},
... // other errors
]
}
| fields | description |
|---|---|
is_live | the boolean to tell the selfie is live or not |
compare_faces | have result (matched/unmatched) and score |
A matched, live selfie comes back like this:
{
"data": {
"compare_faces": {
"face1_id": "349ac5cd-2bd1-4bff-8c10-1cdacdd4c66d",
"face2_id": "57263098-9c07-4220-888f-f8c4b73d4c1d",
"result": "matched",
"score": 0.9256071887745998
},
"is_live": true,
"status": "success"
},
"errors": null
}
Failure codes
If the data.status is "failure", the "errors" field will tell you why it failed.
| Error code | Description |
|---|---|
image_has_no_face | the input image has no faces |
image_has_no_faces | the input image has no faces. (same with the above) |
image_has_multiple_faces | the input image has multiple faces |
image_too_blur | the input image is too blur |
image_too_dark | the input image is too dark |
image_too_bright | the input image is too bright (glare) |
bad_quality_card_image | the input image is bad quality |
not_qualified | the input image is bad quality |
not_white_background | the image was not taken with a white background |
face_too_dark | the face is too dark |
face_too_bright | the face is too bright |
face_too_small | the face is too small |
face_too_big | the face is too big |
right | the face is turned right |
left | the face is turned left |
open_eye,closed_eye | the face has eye(s) closed |
closed_eye,open_eye | the face has eye(s) closed |
open_eye,sunglasses | the face has sunglasses |
sunglasses,open_eye | the face has sunglasses |
closed_eye,closed_eye | the face has eye(s) closed |
closed_eye,sunglasses | the face has sunglasses |
sunglasses,closed_eye | the face has sunglasses |
sunglasses,sunglasses | the face has sunglasses |
In case of any other errors, the data field will be empty, and the server sends one of following HTTP status code with error code:
| 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 | 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 in Memory Cache and DB. |
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 |
The codes above are the ones documented for this endpoint. Response errors on the Overview lists the codes for the eKYC Core surface as a whole — the two lists do not match on every endpoint.