Face · Standard API · eKYC Core
Verify portrait
Checks the sanity of a portrait image and returns a verdict — good, or the first quality issue found — with a confidence score.
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.
| Name | Type | Required | Description |
|---|---|---|---|
image | string | Required | portrait image. if use TS SDK, use last frontal image |
selfie_type | string | Optional | Specify the characteristic of a disabled face or liveness mode eg. disabled eye, passive, active, flash |
- If you use
base64,labelandmetadata, omit parameterid. - If you use
id(resultidis returned from Upload Image API), omit parameterbase64,labelandmetadata.
{
"image": {
"id": string,
"base64": string,
"label": string,
"metadata": string_json,
},
"selfie_type": string,
}
Which image's parameters contains:
| key | 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}" |
The selfie_type parameter
selfie_type names the liveness mode the capture used, and is defined as one of the table values below.
| selfie_type | description |
|---|---|
id_card | Portrait image in Chip NFC of CCCD |
light | Light Authen |
passive | Standard Authen |
active | Advanced Authen use active liveness (gestures) |
flash | Advanced Authen uses full flash liveness |
flash_8 | Edge Authen uses flash liveness with 8 frames |
flash_16 | Edge Authen uses flash liveness with 16 frames |
flash_32 | Advanced Authen uses flash liveness with 32 frames |
flash_edge | Edge Authen uses flash liveness with minimum time |
flash_advanced | Advanced Authen uses full flash liveness |
Sample request
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/verify_portrait_sanity_sync \
-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 \
'
{
"image": {
"id": "7db00808-0416-45cf-a5cb-3b6dfbd7bb74"
}
}
'
Response
data.portrait_sanity carries the verdict and a score between 0 and 1 for how much confidence there is in it. 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"
"portrait_sanity": { // only return the first issue found if any
"verdict": string, // "good" or some alerts, see below.
"score": float, // range 0-1, how much confidence about the verdict
},
"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
]
}
Possible data.portrait_sanity.verdict is good or one of the following values corresponding to each check:
| verdict | supported countries |
|---|---|
image_too_blur | vietnam, india, philippines |
image_too_dark | vietnam, india, philippines |
image_too_bright | vietnam, india, philippines |
face_too_dark | vietnam, india, philippines |
face_too_bright | vietnam, india, philippines |
image_has_no_faces | vietnam, india, philippines |
image_has_multiple_faces | vietnam, india, philippines |
not_white_background | india |
right | vietnam, india, philippines |
left | vietnam, india, philippines |
not_qualified | vietnam, india, philippines |
open_eye,closed_eye | vietnam, india, philippines |
closed_eye,open_eye | vietnam, india, philippines |
open_eye,sunglasses | vietnam, india, philippines |
sunglasses,open_eye | vietnam, india, philippines |
closed_eye,closed_eye | vietnam, india, philippines |
closed_eye,sunglasses | vietnam, india, philippines |
sunglasses,closed_eye | vietnam, india, philippines |
face_too_small | vietnam, india, philippines |
face_too_big | vietnam, india, philippines |
A portrait that passes every check comes back like this:
{
"data": {
"image": {
"id": "4368143d-9066-4f3d-ab22-4e0b6dd9b274"
},
"portrait_sanity": {
"score": 1,
"verdict": "good"
},
"status": "success"
}
}
Failure codes
If the data.status is "failure", the "errors" field will tell you why it failed.
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 | request_time_too_skewed | The X-TV-Timestamp header is expired, need a newer one. |
404 | image_not_found_exception | The image ID is not found in 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.