Face · Standard API · eKYC Core

Index faces video

POST/v1/index_faces_video

Indexes a frame from a video that passes portrait sanity into a collection, and returns the indexed image id together with the video id.

Request

MethodPOST
Path/v1/index_faces_video
Content-Typeapplication/json
Auth requiredYes — HMAC signing

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

NameTypeRequiredDescription
videoVideoDataRequiredvideo to index face. Should use video has the face
collectionstringOptionalindex faces to this collection. case-sensitive
  • If you use base64, label and metadata, omit parameter id.
  • If you use id (result id is returned from Upload File API), omit parameter base64, label and metadata.
  • If not set collection, default collection will be used.
JSON
{
    "video": {
        "id": string,
        "base64": string,
        "label": string,
        "metadata": string_json,
    },
    "collection": string,
}

Which each video's parameters contains:

keytyperequireddescription
idstringOptionalID of video is returned from API Upload
base64stringOptionalbase64 encoded text of video data
labelstringOptionallabel of the video 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}"

Sample request

curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/index_faces_video \
-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 \
'
{
    "video": {
        "id": "a4facba3-334b-41fb-97e3-4766cb70ae29"
    }
}
'

Response

data.image.id is the frame that was indexed and data.video_id the video it came from. 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.

JSON
{
    "data": {
        "request_id": string,
        "image": {
          "id": string, // id of the image
          "transformed_image_id": string // optional, just in case the image is transformed
        },
        "video_id": string, // id of the input video
        "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:

JSON
{
    "data": {
        "status": "success",
        "image": {
          "id": "a4facba3-334b-41fb-97e3-4766cb70ae29"
        },
        "video_id": "c679b398-8dc3-4112-ab37-71b66f6d2e04",
        "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 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.
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
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

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.