> For the complete documentation index, see [llms.txt](https://docs.kairos.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kairos.com/documentation/full-api-reference/liveness-verification.md).

# Liveness Verification

## Introduction

This API allows you to perform liveness verification using a selfie image. It analyzes the provided image and returns information about the detected face, including its liveness score.

### Authentication

To access the API, you need to include the following headers in your request:

* `app_id`: Your application's unique identifier.
* `app_key`: Your application's authentication key.

#### Postman Collection

Open the [Kairos Postman Collection](https://www.postman.com/martian-shuttle-95013/kairos-public/collection/0cj8cw1/kairos-idv-apis) to explore and test our APIs.

#### Submit Verification Request

Submit a verification request by providing a selfie image.

* **URL**: `https://idv-eu.kairos.com/v0.2/liveness-verification`
* **Method**: `POST`
* **Headers**:
  * `Content-Type`: `multipart/form-data`
  * `app-id`: Your API application ID.
  * `app-key`: Your API application key.
* **Body**:
  * `selfie` (File) - The selfie image file for liveness verification.&#x20;
  * `threshold` (Numeric Value) - A numeric value (between 0 and 1) representing the threshold for liveness verification. The API will consider a face as live if its liveness score is greater than or equal to this threshold.

**Image Size Requirements**:

* `selfie` — minimum 300 px, recommended > 900 px, maximum 5000 px.

**Sample Request**

To make a liveness verification request, you can use the following examples:

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

```
var request = require('request');
var fs = require('fs');
var options = {
  'method': 'POST',
  'url': 'https://idv-eu.kairos.com/v0.2/liveness-verification',
  'headers': {
    'app_id': 'put_app_id_here',
    'app_key': 'put_app_key_here'
  },
  formData: {
    'selfie': {
      'value': fs.createReadStream('/path/to/selfie_image'),
      'options': {
        'filename': 'selfie.jpg'
      }
    },
    'threshold': '0.6'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://idv-eu.kairos.com/v0.2/liveness-verification"
files=[
    ('selfie',('file',open('/path/to/selfie_image','rb')))
]
headers = {
    'app_id': 'put_app_id_here',
    'app_key': 'put_app_key_here'
}

# Add threshold parameter
payload = {
    'threshold': 0.6
}

response = requests.request("POST", url, headers=headers, files=files, data=payload)

```

{% endtab %}

{% tab title="cURL" %}

```sh
curl -X POST --location 'https://idv-eu.kairos.com/v0.2/liveness-verification' \
--header 'app_id: put_app_id_here' \
--header 'app_key: put_app_key_here' \
--form 'selfie=@"/path/to/selfie_image"' \
--form 'threshold=0.6'
```

{% endtab %}
{% endtabs %}

Replace app\_id, app\_key, and selfie with your actual credentials and the path to your selfie image.

#### Response

* **Status Code:** 200 (OK)
* **Response Headers:**
  * `Content-Type` — Media type of the response. Always `application/json`.
  * `Content-Length` — Size of the response body in bytes.
  * `X-Request-ID` — A unique identifier assigned to each request.&#x20;
  * `X-Content-Type-Options: nosniff` — Prevents MIME type sniffing on the response.
  * `X-Frame-Options: DENY` — Prevents the response from being embedded in a frame or iframe.
  * `Strict-Transport-Security: max-age=86400; includeSubDomains` — Enforces HTTPS-only connections.
* **Response Body:**

```json
{
  "api_req_uid": "c6bb825f-871c-4323-8c06-8e5fd3517747",
  "processed_at": "2024-04-01 20:05:17",
  "requested_at": "2024-04-01 20:05:17",
  "response_code": 2,
  "response_data": {
    "faces_liveness": 0.0,
    "faces_predicted": [
      {
        "confidence": 0.9885,
        "delta": {
          "x": 18.9982,
          "y": 25.3957
        },
        "top_left": {
          "x": 38.0577,
          "y": 4.0824
        }
      }
    ],
    "img": {
      "height": 71,
      "width": 95
    }
  }
}
```

### Other Responses

* **5xx**: Server errors may occur, and the server will respond with an appropriate 5xx status code. In this case, please check your request and try again later.
* **4xx**: Authentication failures may result in a 4xx status code. Make sure you have provided valid `app_id` and `app_key` in the request headers.
* **403**: If limits are exceeded, you may receive a 403 Forbidden status code indicating that you have reached a usage limit. Check your account limits and consider upgrading your plan if needed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kairos.com/documentation/full-api-reference/liveness-verification.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
