• Overview
  • eKYC Platform
  • Face Authentication
  • Vision Score
  • Behavioral Biometric (BehavioIQ)
  • SIM Verification
  • Mule Account Database
  • eKYC Core
  • Demo Apps
TrustVision API Documentation

Face Authentication API

Face Authentication lets a customer register their face once, then re-authenticate against that registration for subsequent logins or transactions. The typical lifecycle is: register a customer's face (face_auth_register), authenticate against it on future sessions (face_auth), check whether a customer is already registered (face_auth_user), and unregister or unlock the account when needed.

Request face authentication registration

1. Request

MethodPathContent-TypeAuth Required
POST/v1/face_auth_registerapplication/jsonYes

Request Body:

JSON
{
    "cus_user_id": string,
    "faces": [
        {
            "id": string,
            "base64": string,
            "label": string,
            "metadata": string_json,
        }
    ],
    "gesture_faces":[
        {
            "gesture": string,
            "images": [
                {
                        "id": string,
                        "base64": string,
                        "label": string,
                        "metadata": string_json,
                    },
                    {
                        "id": string,
                        "base64": string,
                        "label": string,
                        "metadata": string_json,
                    }
            ],
        }
    ],
    "videos": [
        {
            "id": string,
            "metadata": string_json,
            "frames": [
                {
                    "base64": string,
                    "label": string,
                    "index": int,
                    "metadata": string_json,
                },
                {
                    "base64": string,
                    "label": string,
                    "index": int,
                    "metadata": string_json,
                },
                // other frames
            ],
        },
        {
            "id": string,
            "metadata": string_json,
            "frames": [
                {
                    "base64": string,
                    "label": string,
                    "index": int,
                    "metadata": string_json,
                },
                {
                    "base64": string,
                    "label": string,
                    "index": int,
                    "metadata": string_json,
                },
                // other frames
            ],
        },
        ... // other videos
    ],
    "gesture_videos": [
        {
            "gesture": string,
            "videos": [
                {
                    "id": string,
                    "metadata": string_json,
                    "frames": [
                        {
                            "base64": string,
                            "label": string,
                            "index": int,
                            "metadata": string_json,
                        },
                        {
                            "base64": string,
                            "label": string,
                            "index": int,
                            "metadata": string_json,
                        },
                        // other frames
                    ],
                },
                ... // other videos
            ]
        },
        ... // other gesture videos
    ],
    "face_in_id_card": {
        "id": string,
        "base64": string,
        "label": string,
        "metadata": string_json,
    },
    "device_id": string,
    "app_id": string,
    "lat": float,
    "lng": float,
    "face_type": string,
    "selfie_type": string,
    "history_return_count": int,
    "history_return_status": string,
    "metadata": json_object,
    "face_priority": string
}

Where

NameTypeRequiredDescriptionMax Length
cus_user_idstringYesuser id of customer256
faces[]imageNoimages of the selfie50
gesture_faces[]gesture_imageNoarray of gestures contain images50
videos[]videoNoarray of videos selfie50
gesture_videos[]gesture_videoNoarray of videos gesture50
face_in_id_cardimageNoimage of the face in id_card
device_idstringNodevice id of user256
app_idstringNoapp id of customer128
latfloatNolatitude of device
lngfloatNolongitude of device
face_typestringNotype of face input (selfie, id_card)
selfie_typestringNospecify the characteristic of authentication type eg. Light, Standard, Edge, Advanced, NFC64
history_return_countintNonumber of history registration records to return
history_return_statusstringNostatus of history registration records to return (success, failure or all)
metadatajson_objectNoany key-value metadata to store with this customer
face_prioritystringNotype of face (selfie or id_card) to prioritize when perform face authen (override default setting)

Which each image's parameters contains:

NameTypeRequiredDescription
idstringNoID of image is returned from API Upload
base64stringNobase64 encoded text of image data
labelstringNolabel of the image as described at Label table
metadatastring_jsonNokey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"

Which each gesture_image's parameters contains:

NameTypeRequiredDescription
gesturestringYesspecify a gesture value as below table. Example left, right, up or down
images[]imageYesan array of images for each gesture

Which gesture parameter contains value:

GesturesDescription
leftthe face turns left
rightthe face turns left
upthe face up
downthe face down

Which each video's parameters contains:

NameTypeRequiredDescription
idstringNoID of video is returned from API Upload
metadatastring_jsonNokey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"
frames[]FrameDataNolist of video frames to be uploaded

Which FrameData's parameters contains:

NameTypeRequiredDescription
base64stringNobase64 encoded text of image data
labelstringNolabel of the image as described at Label table
indexintNothe index of this frame in the video
metadatastring_jsonNokey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"

Which each gesture_video's parameters contains:

NameTypeRequiredDescription
gesturestringYesspecify a gesture value as below table. Example left, right, up or down
videos[]videoYesan array of videos for each gesture

Which selfie_type parameter is defined as below table values

selfie_typeDescription
id_cardPortrait image in Chip NFC of CCCD

Note:

  • The parameter face_in_id_card or faces is required. you have to specify at least one
  • For parameter type image, if you use id (result id is returned from Upload Image API), omit parameter base64, label and metadata. If you use base64, label and metadata, omit parameter id.
  • For parameter type video, if you use id (result id is returned from Upload File API), omit parameter frames, metadata. If you use frames, metadata, omit parameter id.
  • If parameter face_type is not specified, the default value is selfie.
  • If you want to register face from ID card (e.g. face extracted while reading NFC of Citizen ID Card), you have to either:
    • Pass the face to faces param and specify face_type and selfie_type as id_card.
    • Or pass the face to face_in_id_card (no need to specify face_type or selfie_type).
  • To register both face from ID card and selfie, please pass the selfie face to faces param and the face from ID card to face_in_id_card param.

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.

Authentication mechanism is described in Authentication.

Sample Request

bash
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/face_auth_register \
-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 \
'
{
    "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
    "faces": [
        {
            "id": "a4facba3-334b-41fb-97e3-4766cb70ae29"
        },
        {
            "id": "c5a2a405-f152-4248-b746-3af76b241ef7"
        },
        {
            "id": "5d0345f7-da7c-44e8-bd6c-a8c08c806227"
        }
    ],
    "gesture_faces": [
        {
            "gesture": "left",
            "images": [
                {
                    "id": "d849a3ce-d209-4605-99a7-3d369234fd5e"
                }
            ]
        },
        {
            "gesture": "up",
            "images": [
                {
                    "id": "551fc06a-14fd-44dc-8838-abe895007c36"
                }
            ]
        },
        {
            "gesture": "right",
            "images": [
                {
                    "id": "536d2457-bfc0-4249-85f2-8c4053bdec58"
                }
            ]
        }
    ],
    "videos": [
        {
            "id": "61801fcd-b109-49f7-b871-ae82c2a666cc",
        },
        {
            "id": "1f93d229-7f1c-44f9-a85b-1be4c2d4be41",
        }
    ],
    "face_type": "selfie",
    "metadata": {
        "key1": {
          "key11": "value11",
          "key12": "value12"
        },
        "key2": "value2"
    }
}
'

2. Response

The response will be a JSON with following format:

JSON
{
    "data": {
        "status": string, // "success" or "failure"
        "request_id": string, // return request id to the client and can use request-id to check logs.
        "user_metadata": json_object, // return user metadata
        "register_id": string, // id of this registration request
        "histories": [
            {
                "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 registration request
                "device_id": string, // device id input for this registration request
                "app_id": string, // app id input for this registration request
                "latitude": float, // latitude input for this registration request
                "longitude": float, // longitude input for this registration request
                "created_at": string, // time of this registration request
                "auth_action": string, // "register"
                "status": string, // "success" or "failure"
                "result": string, // detail result of this registration request
                "metadata": json_object, // metadata input for this registration request
                "face_type": string, // type of face input for this registration request ("selfie", "id_card")
            },
            ... // other history
        ]
    },
    "errors": [
        {
            "code": string,
            "message": string,
            "detail": {
                "field": string, // optional, which parameter is invalid.
                ... // any other information that can be useful for client
            },
        },
        ... // other errors
    ]
}

The expiry_date of selfie face will be returned in user_metadata field as expiry_date_face in RFC3339 format.

In case the request processing has been finished successfully, 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.

If the data.status is "failure", the "errors" field will tell you why it failed.

error codedescription
face_auth_user_deactivatedthe user is deactivated

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:

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.
400incorrect_number_of_facesSelfie or original image have more than 1 faces.
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

Sample Response

JSON
{
    "data": {
        "status": "success",
        "request_id": "cfc7b8d5-f2e2-437b-80e5-d600dfad26e2",
        "user_metadata": {
            "key1": "value1",
            "key2": 2,
            "expiry_date_face": "2023-12-27T03:33:06.307977Z",
        },
        "register_id": "d4f99f9b-4862-437f-a9c9-608e050d06c6",
        "histories": [
            {
                "id": "f1ca6795-cbd4-4eec-821f-b4ac646db627",
                "client_id": "0ef0f7e9-7f2f-4767-84b8-f76da7701c46",
                "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
                "face_auth_id": "",
                "id_card_face_id": "4f959f4a-f5de-4b50-8724-224e709d06c2",
                "live_face_id": "009161c9-9c89-4573-8119-8f513de4449c",
                "created_at": "2023-12-27T03:33:06.307977Z",
                "auth_action": "register",
                "status": "success",
                "result": "",
                "face_type": "selfie"
            },
            {
                "id": "8c23af95-aaa0-4448-bfba-68acce31236e",
                "client_id": "0ef0f7e9-7f2f-4767-84b8-f76da7701c46",
                "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
                "face_auth_id": "",
                "id_card_face_id": "4f959f4a-f5de-4b50-8724-224e709d06c2",
                "live_face_id": "009161c9-9c89-4573-8119-8f513de4449c",
                "created_at": "2023-12-21T07:24:19.829484Z",
                "auth_action": "register",
                "status": "failure",
                "result": "image is not liveness",
                "face_type": "id_card"
            }
        ]
    }
}

Request face authentication

1. Request

MethodPathContent-TypeAuth Required
POST/v1/face_authapplication/jsonYes

Request Body:

JSON
{
    "cus_user_id": string,
    "client_transaction_id": string,
    "faces": [
        {
            "id": string,
            "base64": string,
            "label": string,
            "metadata": string_json,
        }
    ],
    "gesture_faces":[
        {
            "gesture": string,
            "images": [
                {
                        "id": string,
                        "base64": string,
                        "label": string,
                        "metadata": string_json,
                    },
                    {
                        "id": string,
                        "base64": string,
                        "label": string,
                        "metadata": string_json,
                    }
            ],
        }
    ],
    "videos": [
        {
            "id": string,
            "metadata": string_json,
            "frames": [
                {
                    "base64": string,
                    "label": string,
                    "index": int,
                    "metadata": string_json,
                },
                {
                    "base64": string,
                    "label": string,
                    "index": int,
                    "metadata": string_json,
                },
                // other frames
            ],
        },
        {
            "id": string,
            "metadata": string_json,
            "frames": [
                {
                    "base64": string,
                    "label": string,
                    "index": int,
                    "metadata": string_json,
                },
                {
                    "base64": string,
                    "label": string,
                    "index": int,
                    "metadata": string_json,
                },
                // other frames
            ],
        },
        ...
    ],
    "gesture_videos": [
        {
            "gesture": string,
            "videos": [
                {
                    "id": string,
                    "metadata": string_json,
                    "frames": [
                        {
                            "base64": string,
                            "label": string,
                            "index": int,
                            "metadata": string_json,
                        },
                        {
                            "base64": string,
                            "label": string,
                            "index": int,
                            "metadata": string_json,
                        },
                        // other frames
                    ],
                },
                ... // other videos
            ]
        },
        ... // other gesture videos
    ],
    "device_id": string,
    "app_id": string,
    "lat": float,
    "lng": float,
    "auth_type": string,
    "selfie_type": string,
    "history_return_count": int,
    "history_return_status": string,
    "metadata": json_object
}

Where

NameTypeRequiredDescriptionMax Length
cus_user_idstringYesuser id of customer256
faces[]imageYesimages of the selfie50
gesture_faces[]gesture_imageNoarray of gestures contain images50
videos[]videoNoarray of videos selfie50
gesture_videos[]gesture_videoNoarray of videos gesture50
device_idstringNodevice id of user256
app_idstringNoapp id of customer128
latfloatNolatitude of device
lngfloatNolongitude of device
auth_typestringNospecify different authentication type (or different use-cases)64
client_transaction_idstringNoclient transaction ID
selfie_typestringNospecify the characteristic of authentication type eg. Light, Standard, Edge, Advanced64
history_return_countintNonumber of history authenticate records to return
history_return_statusstringNostatus of history authenticate records to return (success, failure or all)
metadatajson_objectNoany key-value metadata to store with this login time

Which each image's parameters contains:

NameTypeRequiredDescription
idstringNoID of image is returned from API Upload
base64stringNobase64 encoded text of image data
labelstringNolabel of the image as described at Label table
metadatastring_jsonNokey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"

Which each gesture_image's parameters contains:

NameTypeRequiredDescription
gesturestringYesspecify a gesture value as below table. Example left, right, up or down
images[]imageYesan array of images for each gesture

Which gesture parameter contains value:

GesturesDescription
leftthe face turns left
rightthe face turns left
upthe face up
downthe face down

Which each video's parameters contains:

NameTypeRequiredDescription
idstringNoID of video is returned from API Upload
metadatastring_jsonNokey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"
frames[]FrameDataNolist of video frames to be uploaded

Which FrameData's parameters contains:

NameTypeRequiredDescription
base64stringNobase64 encoded text of image data
labelstringNolabel of the image as described at Label table
indexintNothe index of this frame in the video
metadatastring_jsonNokey-value string, key should be string, value should be string, int, float, bool. Example "{\"id\":\"123456789\",\"type\":1}"

Which each gesture_video's parameters contains:

NameTypeRequiredDescription
gesturestringYesspecify a gesture value as below table. Example left, right, up or down
videos[]videoYesan array of videos for each gesture

Define flow based on parameters

The auth_type parameter is defined for each use-case differently

auth_typedescription
reset_passwordAuthenticate to reset password flow
loginUse face to replace text password
paymentAuthenticate payment
transferAuthenticate transfer
transfer_type_AAuthenticate transfer type A
transfer_type_BAuthenticate transfer type B
transfer_type_CAuthenticate transfer type C
transfer_type_DAuthenticate transfer type D
...You can define any authentication type based on your business

The selfie_type parameter is defined as below table values

selfie_typeDescription
lightLight Authen
passiveStandard Authen
activeAdvanced Authen use active liveness (gestures)
flashAdvanced Authen uses full flash liveness
flash_8Edge Authen uses flash liveness with 8 frames
flash_16Edge Authen uses flash liveness with 16 frames
flash_32Advanced Authen uses flash liveness with 32 frames
flash_edgeEdge Authen uses flash liveness with minimum time
flash_advancedAdvanced Authen uses full flash liveness

Note:

  • For parameter type image, if you use id (result id is returned from Upload Image API), omit parameter base64, label and metadata. If you use base64, label and metadata, omit parameter id.
  • For parameter type video, if you use id (result id is returned from Upload File API), omit parameter frames, metadata. If you use frames, metadata, omit parameter id.

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.

Authentication mechanism is described in Authentication.

Sample Request

bash
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/face_auth \
-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 \
'
{
    "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
    "faces": [
        {
            "id": "a4facba3-334b-41fb-97e3-4766cb70ae29"
        },
        {
            "id": "c5a2a405-f152-4248-b746-3af76b241ef7"
        },
        {
            "id": "5d0345f7-da7c-44e8-bd6c-a8c08c806227"
        }
    ],
    "gesture_faces": [
        {
            "gesture": "left",
            "images": [
                {
                    "id": "d849a3ce-d209-4605-99a7-3d369234fd5e"
                }
            ]
        },
        {
            "gesture": "up",
            "images": [
                {
                    "id": "551fc06a-14fd-44dc-8838-abe895007c36"
                }
            ]
        },
        {
            "gesture": "right",
            "images": [
                {
                    "id": "536d2457-bfc0-4249-85f2-8c4053bdec58"
                }
            ]
        }
    ],
    "videos": [
        {
            "id": "61801fcd-b109-49f7-b871-ae82c2a666cc",
        },
        {
            "id": "1f93d229-7f1c-44f9-a85b-1be4c2d4be41",
        }
    ],
    "metadata": {
        "key1": {
          "key11": "value11",
          "key12": "value12"
        },
        "key2": "value2"
    }
}
'

2. Response

The response will be a JSON with following format:

JSON
{
    "data": {
        "status": string, // "success" or "failure"
        "auth_check": {
            "score": float, // how likely that face1 and face2 are matched (0-1)
            "result": string // "matched", "unmatched"
        },
        "request_id": string, // return request id to the client and can use request-id to check logs.
        "user_metadata": json_object, // return user metadata
        "validate_faces_result": {
            "sanity_verdict": string, // portrait_sanity check result, if field not exist or value is "", it means portrait_sanity check is not performed
            "is_live": bool, // liveness check result, if field not exist or value is null, it means liveness check is not performed
            "sanity_check: {...}, // full sanity check response
            "liveness_check: {...} // full liveness check response
        },
        "auth_id": string, // id of this authentication request
        "histories": [
            {
                "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 login request
                "device_id": string, // device id input for this login request
                "app_id": string, // app id input for this login request
                "latitude": float, // latitude input for this login request
                "longitude": float, // longitude input for this login request
                "created_at": string, // time of this login request
                "auth_action": string, // "login"
                "status": string, // "success" or "failure"
                "result": string, // detail result of this login request
                "metadata": json_object, // metadata input for this login request
                "face_type": string, // type of face used to compare against the input face to authenticate ("selfie", "id_card")
            },
            ... // other history
        ]
    },
    "errors": [
        {
            "code": string,
            "message": string,
            "detail": {
                "field": string, // optional, which parameter is invalid.
                ... // any other information that can be useful for client
            },
        },
        ... // other errors
    ]
}

The expiry_date of selfie face will be returned in user_metadata field as expiry_date_face in RFC3339 format.

In case the request processing has been finished successfully, 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.

fieldsdescription
auth_checkhave result (matched/unmatched) and score

If the data.status is "failure", the "errors" field will tell you why it failed.

error codedescription
image_too_blurthe input image is too blur
image_too_darkthe input image is too dark
image_too_brightthe input image is too bright (glare)
image_has_no_facesthe input image has no faces
image_non_livenessthe input image is not liveness
face_auth_user_deactivatedthe user is deactivated
face_auth_user_unregisteredthe user is unregistered from face_auth service
face_auth_user_lockedthe user is locked from face_auth service

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:

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.
400incorrect_number_of_facesSelfie or original image have more than 1 faces.
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
404face_auth_user_not_found_exceptionThe user of face_auth service not found.
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

Sample Response

JSON
{
    "data": {
        "status": "success",
        "auth_check": {
            "score": 0.9999999862517992,
            "result": "matched"
        },
        "request_id": "cfc7b8d5-f2e2-437b-80e5-d600dfad26e2",
        "user_metadata": {
            "key1": "value1",
            "key2": 2,
            "expiry_date_face": "2023-12-27T03:33:06.307977Z",
        },
        "validate_faces_result": {
            "sanity_verdict": "good",
            "is_live": true,
            "sanity_check": {
                "portrait_sanity": {
                    "score": 1,
                    "verdict": "good"
                },
                "request_id": "9f89377f-4bb4-4ecb-884c-f46f1d7d6099",
                "status": "success"
            },
            "liveness_check": {
                "images": null,
                "is_live": true,
                "request_id": "baee3d03-8af4-421b-8968-a0f6172b4df8",
                "score": 1,
                "status": "success"
            }
        },
        "auth_id": "d4f99f9b-4862-437f-a9c9-608e050d06c6",
        "histories": [
            {
                "id": "f1ca6795-cbd4-4eec-821f-b4ac646db627",
                "client_id": "0ef0f7e9-7f2f-4767-84b8-f76da7701c46",
                "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
                "face_auth_id": "887249dc-681c-4231-aff9-67734833aca7",
                "id_card_face_id": "4f959f4a-f5de-4b50-8724-224e709d06c2",
                "live_face_id": "009161c9-9c89-4573-8119-8f513de4449c",
                "created_at": "2023-12-27T03:33:06.307977Z",
                "auth_action": "login",
                "status": "success",
                "result": "",
                "face_type": "selfie"
            },
            {
                "id": "8c23af95-aaa0-4448-bfba-68acce31236e",
                "client_id": "0ef0f7e9-7f2f-4767-84b8-f76da7701c46",
                "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
                "face_auth_id": "",
                "id_card_face_id": "4f959f4a-f5de-4b50-8724-224e709d06c2",
                "live_face_id": "009161c9-9c89-4573-8119-8f513de4449c",
                "created_at": "2023-12-21T07:24:19.829484Z",
                "auth_action": "login",
                "status": "failure",
                "result": "image is not liveness",
                "face_type": "id_card"
            }
        ]
    }
}

Request check user of face authentication

This API checks whether a cus_user_id has been registered to the face_authentication system.

1. Request

MethodPathContent-TypeAuth Required
POST/v1/face_auth_userapplication/jsonYes

Request Body:

JSON
{
    "cus_user_id": string
}

Where

NameTypeRequiredDescription
cus_user_idstringYesuser id of customer

Authentication mechanism is described in Authentication.

Sample Request

bash
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/face_auth_user \
-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 \
'
{
    "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3"
}
'

2. Response

The response will be a JSON with following format:

JSON
{
    "data": {
        "status": string, // "success" or "failure"
        "verdict" : string, // "registered" or "not_registered"
        "face_types": [string], // list of face types that user has registered (if verdict is "registered")
        "histories": [ // list of registration history if verdict is "registered"
            {
                "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 login request
                "device_id": string, // device id input for this login request
                "app_id": string, // app id input for this login request
                "latitude": float, // latitude input for this login request
                "longitude": float, // longitude input for this login request
                "created_at": string, // time of this login request
                "auth_action": string, // "register"
                "status": string, // "success" or "failure"
                "result": string, // detail result of this login request
                "metadata": json_object, // metadata input for this login request
                "face_type": string, // type of face used to compare against the input face to authenticate ("selfie", "id_card")
            },
            ... // other history
        ],
        "metadata": {
            ... // key-value if exists
        },
    },
    "errors": [
        {
            "code": string,
            "message": string,
            "detail": {
                "field": string, // optional, which parameter is invalid.
                ... // any other information that can be useful for client
            },
        },
        ... // other errors
    ]
}

The expiry_date of selfie face will be returned in metadata field as expiry_date_face in RFC3339 format.

In case the request processing has been finished successfully, 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.

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 the following HTTP status codes with an 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.
400incorrect_number_of_facesSelfie or original image have more than 1 faces.
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
404face_auth_user_not_found_exceptionThe user of face_auth service not found.
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

Sample Response

JSON
{
    "data": {
        "status": "success",
        "verdict": "registered",
        "face_types": ["selfie", "id_card"],
        "histories": [
            {
                "id": "f1ca6795-cbd4-4eec-821f-b4ac646db627",
                "client_id": "0ef0f7e9-7f2f-4767-84b8-f76da7701c46",
                "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
                "face_auth_id": "887249dc-681c-4231-aff9-67734833aca7",
                "id_card_face_id": "4f959f4a-f5de-4b50-8724-224e709d06c2",
                "live_face_id": "009161c9-9c89-4573-8119-8f513de4449c",
                "created_at": "2023-12-27T03:33:06.307977Z",
                "auth_action": "register",
                "status": "success",
                "result": "",
                "face_type": "selfie"
            },
            {
                "id": "8c23af95-aaa0-4448-bfba-68acce31236e",
                "client_id": "0ef0f7e9-7f2f-4767-84b8-f76da7701c46",
                "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
                "face_auth_id": "",
                "id_card_face_id": "4f959f4a-f5de-4b50-8724-224e709d06c2",
                "live_face_id": "009161c9-9c89-4573-8119-8f513de4449c",
                "created_at": "2023-12-21T07:24:19.829484Z",
                "auth_action": "register",
                "status": "failure",
                "result": "image is not liveness",
                "face_type": "id_card"
            }
        ],
        "metadata": {
          "key": "value",
          "expiry_date_face": "2023-12-27T03:33:06.307977Z",
        }
    }
}

Request face authentication unregistration

1. Request

MethodPathContent-TypeAuth Required
POST/v1/face_auth_unregisterapplication/jsonYes

Request Body:

JSON
{
    "cus_user_id": string,
    "device_id": string,
    "app_id": string,
    "lat": float,
    "lng": float,
}

Where

NameTypeRequiredDescriptionMax Length
cus_user_idstringYesuser id of customer256
device_idstringNodevice id of user256
app_idstringNoapp id of customer128
latfloatNolatitude of device
lngfloatNolongitude of device

Authentication mechanism is described in Authentication.

Sample Request

bash
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/face_auth_unregister \
-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 \
'
{
    "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
}
'

2. Response

The response will be a JSON with following format:

JSON
{
    "data": {
        "status": string, // "success" or "failure"
        "unregister_id": string, // id of this unregistration request
        "face_auth_user": { // user information after unregistration
            "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
        }
    },
    "errors": [
        {
            "code": string,
            "message": string,
            "detail": {
                "field": string, // optional, which parameter is invalid.
                ... // any other information that can be useful for client
            },
        },
        ... // other errors
    ]
}

In case the request processing has been finished successfully, 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.

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 the following HTTP status codes with an 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.
400incorrect_number_of_facesSelfie or original image have more than 1 faces.
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
404face_auth_user_not_found_exceptionThe user of face_auth service not found.
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

Sample Response

JSON
{
    "data": {
        "status": "success",
        "unregister_id": "d4f99f9b-4862-437f-a9c9-608e050d06c6",
        "face_auth_user": {
            "id": "f1ca6795-cbd4-4eec-821f-b4ac646db627",
            "client_id": "0ef0f7e9-7f2f-4767-84b8-f76da7701c46",
            "access_key_id": "c7d97b7c-f73d-4d62-973e-6eb3e0557ddf",
            "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
            "face_auth_id": "",
            "id_card_face_id": "4f959f4a-f5de-4b50-8724-224e709d06c2",
            "live_face_id": "009161c9-9c89-4573-8119-8f513de4449c",
            "device_id": "",
            "app_id": "",
            "latitude": 1.0,
            "longitude": 2.0,
            "metadata": {
              "key1": "value1",
              "key2": 2
            },
            "is_deactivated": false,
            "is_unregistered": true,
            "created_at": "2023-12-27T03:33:06.307977Z",
            "updated_at": "2023-12-28T03:33:06.307977Z",
        }
    }
}

Request face authentication unlock

1. Request

MethodPathContent-TypeAuth Required
POST/v1/face_auth_unlockapplication/jsonYes

Request Body:

JSON
{
    "cus_user_id": string,
}

Where

NameTypeRequiredDescriptionMax Length
cus_user_idstringYesuser id of customer256

Authentication mechanism is described in Authentication.

Sample Request

bash
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/face_auth_unlock \
-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 \
'
{
    "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
}
'

2. Response

The response will be a JSON with following format:

JSON
{
    "data": {
        "status": string, // "success" or "failure"
        "unlock_id": string, // id of this unlock request
        "face_auth_user": { // user information after unlock
            "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
        }
    },
    "errors": [
        {
            "code": string,
            "message": string,
            "detail": {
                "field": string, // optional, which parameter is invalid.
                ... // any other information that can be useful for client
            },
        },
        ... // other errors
    ]
}

In case the request processing has been finished successfully, 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.

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 the following HTTP status codes with an 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.
400incorrect_number_of_facesSelfie or original image have more than 1 faces.
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
404face_auth_user_not_found_exceptionThe user of face_auth service not found.
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

Sample Response

JSON
{
    "data": {
        "status": "success",
        "unlock_id": "d4f99f9b-4862-437f-a9c9-608e050d06c6",
        "face_auth_user": {
            "id": "f1ca6795-cbd4-4eec-821f-b4ac646db627",
            "client_id": "0ef0f7e9-7f2f-4767-84b8-f76da7701c46",
            "access_key_id": "c7d97b7c-f73d-4d62-973e-6eb3e0557ddf",
            "cus_user_id": "3b4bf7b6-088b-4931-9279-9259f5c34fe3",
            "face_auth_id": "",
            "id_card_face_id": "4f959f4a-f5de-4b50-8724-224e709d06c2",
            "live_face_id": "009161c9-9c89-4573-8119-8f513de4449c",
            "device_id": "",
            "app_id": "",
            "latitude": 1.0,
            "longitude": 2.0,
            "metadata": {
              "key1": "value1",
              "key2": 2
            },
            "is_deactivated": false,
            "is_unregistered": true,
            "created_at": "2023-12-27T03:33:06.307977Z",
            "updated_at": "2023-12-28T03:33:06.307977Z",
        }
    }
}