# Face Authentication Check

## Run a face authentication check

To run a Face Authentication Check, you must [create a check ](https://docs.complycube.com/documentation/api-reference/core-resources/checks/create-a-check)with `type` set to `face_authentication_check`.

This check can only be performed on a [client](https://docs.complycube.com/documentation/api-reference/core-resources/clients) of type `person`. Furthermore, the provided client must have been enrolled previously.

[Learn more about Face Authentication Checks](https://app.gitbook.com/s/KyFKMqftsmT6qln9zo5y/biometric-and-liveness-verification/face-authentication-check).

{% hint style="info" %}
Get in touch with your Account Manager or [contact us](https://www.complycube.com/sales) to enable this service.
{% endhint %}

## Check request

<table><thead><tr><th width="241">Attribute</th><th width="96.4">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>clientId</code></td><td>string</td><td>The ID of the client associated with this check. (<strong>Required</strong>)</td></tr><tr><td><code>type</code></td><td>string</td><td>This must be set to <code>face_authentication_check</code>. (<strong>Required</strong>)</td></tr><tr><td><code>livePhotoId</code></td><td>string</td><td>The ID of the live photo. (<strong>Required</strong>)</td></tr></tbody></table>

### Example request

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST https://api.complycube.com/v1/checks \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
          "clientId":"CLIENT_ID",
          "livePhotoId":"LIVE_PHOTO_ID",
          "type": "face_authentication_check"
        }'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const check = await complycube.check.create("CLIENT_ID", {
        livePhotoId: "LIVE_PHOTO_ID",
        type: "face_authentication_check"
});
```

{% endtab %}

{% tab title="Python" %}

```python
check = cc_api.check.create(
    'CLIENT_ID',
    'face_authentication_check', 
    livePhotoId='LIVE_PHOTO_ID'
)
```

{% endtab %}

{% tab title="PHP" %}

```php
$result = $ccapi->checks()->create(
    'CLIENT_ID',
    [
        'type' => 'face_authentication_check',
        'livePhotoId' => 'LIVE_PHOTO_ID'
    ]
);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
var checkRequest = new CheckRequest {
  clientId = "CLIENT_ID",
  livePhotoId = "LIVE_PHOTO_ID",
  type = "face_authentication_check"
};

var check = await checkApi.CreateAsync(checkRequest);
```

{% endtab %}
{% endtabs %}

## Result object

The `result` object is only returned when the status of the check is `complete` . It has two components - `outcome` and `breakdown`.

### Outcome

The outcome attribute represents the overall check result. Returned values include:

1. `clear`: Indicates the face on the provided live photo matches one of the client's previously enrolled faces, and hence the client's face authentication is successful.
2. `attention`: Indicates the face on the live photo does not match any of the client's previously enrolled faces, hence requiring attention.

### Breakdown

The breakdown comprises the following objects:

#### `faceAuthentication` object

The face authentication results. It has the following constituents:

* `facialSimilarity`: Indicates whether the face on the live photo matches a client's enrolled face.
* `breakdown`: Breakdown related to face authentication.
  * `facesMatched`: If the live photo matches an enrolled face, this attribute will be returned. It contains the following:
    * `livePhotoId`: The ID of the live photo corresponding to the enrolled face that matched.&#x20;
    * `liveVideoId`: The ID of the live video corresponding to the enrolled face that matched.
    * `facialSimilarityScore`: Indicates the similarity level of the face on the live photo provided against the enrolled face. The score will be 100 for a perfect match.
  * `enrolledFaces`: This contains details about previously enrolled faces for a given client. It comprises of the following:&#x20;
    * `livePhotoIds`: An array of live photo IDs used for enrolling the client's face.
    * `liveVideoIds`: An array of live video IDs used for enrolling the client's face.

## Sample Response

```javascript
{
    "id": "6231d54079f59b1530fc76e3",
    "entityName": "John Doe",
    "type": "face_authentication_check",
    "clientId": "6230d4ab58ed4a434afbf2cc",
    "livePhotoId": "6231d137095afa000955ffc2",
    "status": "complete",
    "result": {
        "outcome": "clear",
        "breakdown": {
            "faceAuthentication": {
                "facialSimilarity": "clear",
                "breakdown": {
                    "facesMatched": [
                        {
                            "livePhotoId": "6230d4f928e6ae00091747f9",
                            "facialSimilarityScore": 100
                        }
                    ],
                    "enrolledFaces": {
                        "livePhotoIds": [
                            "6230d4f928e6ae00091747f9",
                            "6230d4f928e6ae00091747fa"
                        ]
                    }
                }
            }
        }
    },
    "updatedAt": "2022-03-01T12:17:06.046Z",
    "createdAt": "2022-03-01T12:17:04.809Z"
}
```
