Face · Standard API · eKYC Core
Index faces
Indexes the face in an image into a collection so it can later be retrieved by Search faces, and returns the indexed image id.
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 | ImageData | Required | image to index face. Should use image has the face. if use TS SDK, use last frontal image |
enable_update_metadata | bool | Optional | Allow image.metadata to be updated. |
collection | string | Optional | index faces to this collection. case-sensitive |
type | int | Optional | type of collection |
- If you use
base64,labelandmetadata, omit parameterid. - If you use
id(resultidis returned from Upload Image API), omit parameterbase64,labelandmetadata. - If not set collection, default collection will be used.
{
"image": {
"id": string,
"base64": string,
"label": string,
"metadata": string_json,
},
"enable_update_metadata": bool,
"collection": string,
"type": int
}
Which type's parameter contains value:
| value | description |
|---|---|
3 | Matching Selfie vs Selfie |
Sample request
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/index_faces_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": "a4facba3-334b-41fb-97e3-4766cb70ae29"
}
}
'
Response
data.image.id is the image whose face was indexed. 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": {
"request_id": string,
"image": {
"id": string, // id of the image
"transformed_image_id": string // optional, just in case the image is transformed
},
"status": string, // "success" or "failure"
},
"errors": [
{
"code": string,
"message": string,
"detail": {
"field": string, // optional, which parameter is invalid.
... // any other information that can be useful for client
},
},
... // other errors
]
}
A successful index comes back like this:
{
"data": {
"status": "success",
"image": {
"id": "a4facba3-334b-41fb-97e3-4766cb70ae29"
},
"request_id": "dfdef016-e89b-4da4-ae17-5844f909c947"
}
}
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. |
404 | request_not_found_exception | The request ID is not found when polling result by id |
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.