# Perform Identity Check

## Overview <a href="#overview" id="overview"></a>

This guide shows you how to run an Identity Check using the ComplyCube API.

{% hint style="success" %}
You can try this check right away using our [Demo Postman Collection](/documentation/integration-resources/postman.md#demo-collection). It’s publicly accessible and **requires no account**.
{% endhint %}

## Integration steps <a href="#integration-steps" id="integration-steps"></a>

<figure><img src="/files/sKnyTFBkHi6tsOOSQJBF" alt=""><figcaption><p>Identity Check API Guide</p></figcaption></figure>

{% stepper %}
{% step %}

#### Create a client <a href="#create-a-client" id="create-a-client"></a>

The first step in creating any check is to add a **client** from your backend server. A client can represent either a **person** or a **company**.

The response will contain an `id` (the Client ID). It is required for the next step.

**Example request for creating a client**

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

```bash
curl -X POST https://api.complycube.com/v1/clients \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
          "type": "person",
          "email": "john.doe@example.com",
          "personDetails":{
               "firstName": "John",
               "lastName" :"Doe",
               "dob": "1990-01-01"
          }
        }'
```

{% endtab %}

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

```javascript
const { ComplyCube } = require("@complycube/api");

const complycube = new ComplyCube({ apiKey: "<YOUR_API_KEY>" });

const client = await complycube.client.create({
  type: "person",
  email: "john.doe@example.com",
  personDetails: {
    firstName: "John",
    lastName: "Doe",
    dob: "1990-01-01"
  }
});
```

{% endtab %}

{% tab title="Python" %}

```python
from complycube import ComplyCubeClient

cc_api = ComplyCubeClient(api_key='<YOUR API KEY>')

new_client = {
    'type':'person',
    'email':'john.doe@example.com',
    'personDetails': {
        'firstName':'John',
        'lastName':'Doe',
        'dob':'1990-01-01'
    }
}

client = cc_api.clients.create(**new_client)
```

{% endtab %}

{% tab title="PHP" %}

```php
use ComplyCube\ComplyCubeClient;

$ccapi = new ComplyCubeClient('<YOUR_API_KEY>');

$result = $ccapi->clients()->create([
    'type' => 'person',
    'email' => 'john.doe@example.com',
    'personDetails' => [
        'firstName' => 'John',
        'lastName' => 'Doe',
        'dob' => '1990-01-01'
    ]
]);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using ComplyCube.Net;
using ComplyCube.Net.Resources.Clients;

var clientApi = new ClientApi(new ComplyCubeClient("<YOUR_API_KEY>"));

var newclient = new ClientRequest {
  type = "person",
    email = "john.doe@example.com",
    personDetails = new PersonDetails {
      firstName = "John",
        lastName = "Doe",
        dob = "1990-01-01"
    }
}

var client = await clientApi.CreateAsync(newclient);
```

{% endtab %}
{% endtabs %}

**Example response**

```json
{
    "id": "5eb04fcd0f3e360008035eb1",
    "type": "person",
    "email": "john.doe@example.com",
    "personDetails": {
        "firstName": "John",
        "lastName": "Doe",
        "dob": "1990-01-01"
    },
    "createdAt": "2025-01-04T17:24:29.146Z",
    "updatedAt": "2025-01-04T17:24:29.146Z"
}
```

{% endstep %}

{% step %}

#### Create a live photo

Upload a BASE64-encoded selfie image of the customer. The image must be in **JPG** or **PNG** and between **34 KB** and **4 MB** in size.

Below is a sample BASE64-encoded selfie image. Download it, and copy its content. Then paste into the `data` attribute when making the request.

The response will contain an `id` (the Live Photo ID). It is required later.

{% file src="/files/-M7mkOYNzzw-N0EDXgnu" %}
Sample - BASE64 encoded selfie
{% endfile %}

**Example request for uploading the live photo**

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

```bash
curl -X POST https://api.complycube.com/v1/livePhotos \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
          "clientId":"5eb04fcd0f3e360008035eb1",
          "data": "<BASE64_DATA_CONTENT>"
        }'
```

{% endtab %}

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

```javascript
const livePhoto = await complycube.livePhoto.upload("5eb04fcd0f3e360008035eb1", {
    data: "<BASE64_DATA_CONTENT>"
});
```

{% endtab %}

{% tab title="Python" %}

```python
livePhoto = cc_api.livephotos.upload('5eb04fcd0f3e360008035eb1', 
                                     data='<BASE64_DATA_CONTENT>')
```

{% endtab %}

{% tab title="PHP" %}

```php
$img = $ccapi->livephotos()->upload('5eb04fcd0f3e360008035eb1',
                                   ['data' => '<BASE64_DATA_CONTENT>']);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
var livePhotoRequest = new LivePhotoRequest
                    {
                        clientId = "5eb04fcd0f3e360008035eb1",
                        data= "<BASE64_DATA_CONTENT>"
                    };

var livePhoto = await livePhotoApi.UploadAsync(livePhotoRequest);
```

{% endtab %}
{% endtabs %}

**Example response**

```json
{
    "id": "5eb1b5f231778a0008d1c3f6",
    "clientId": "5eb04fcd0f3e360008035eb1",
    "downloadLink": "/livePhotos/5eb1b5f231778a0008d1c3f6/download",
    "contentType": "images/jpg",
    "size": 44896,
    "createdAt": "2025-01-01T14:06:44.756Z",
    "updatedAt": "2025-01-01T14:06:44.756Z"
}
```

{% endstep %}

{% step %}

#### Create a document <a href="#create-a-document" id="create-a-document"></a>

Create a document by providing the **Client ID** and **document type** (e.g. passport, national ID).

The response will contain an `id` (the Document ID). It is required for the next step.

**Example request for creating a document**

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

```bash
curl -X POST https://api.complycube.com/v1/documents \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
          "clientId":"5eb04fcd0f3e360008035eb1",
          "type": "passport",
          "issuingCountry": "GB"
        }'
```

{% endtab %}

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

```javascript
const document = await complycube.document.create("5eb04fcd0f3e360008035eb1", {
  type: "passport",
  issuingCountry: "GB"
});
```

{% endtab %}

{% tab title="Python" %}

```python
document = cc_api.documents.create(
    "5eb04fcd0f3e360008035eb1",
    type="passport",
    issuingCountry="GB"
)
```

{% endtab %}

{% tab title="PHP" %}

```php
$doc = $ccapi->documents()->create(
    '5eb04fcd0f3e360008035eb1',
    [
        'type' => 'passport',
        'issuingCountry' => 'GB'
    ]
);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
var docRequest = new DocumentRequest {
  clientId = "5eb04fcd0f3e360008035eb1",
  type = "passport",
  issuingCountry = "GB"
};

var document = await docApi.CreateAsync(docRequest);
```

{% endtab %}
{% endtabs %}

**Example response**

```json
{
    "id": "5ebd40714f23960008c81527",
    "type": "passport",
    "issuingCountry": "GB",
    "createdAt": "2025-01-04T17:25:21.116Z",
    "updatedAt": "2025-01-04T17:25:21.116Z"
}
```

{% endstep %}

{% step %}

#### Upload front side of ID

Upload a BASE64-encoded image of the front of the ID document. Depending on the [document type](/documentation/product-guides/identity-verification/document-check/document-sides-per-type.md) and issuing country, both sides may be required.

Images must be in **JPG**, **PNG**, or **PDF** format and between **34 KB** and **4 MB** in size.

Below is a sample BASE64-encoded file. Download it, copy its contents, and paste them into the `data` attribute when making the request.

{% file src="/files/-M7JT2lVicOTyiYsyi0k" %}
Sample - BASE64 encoded front-side of passport
{% endfile %}

**Example request for uploading the front-side image of a document**

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

```bash
 curl -X POST https://api.complycube.com/v1/documents/5ebd40714f23960008c81527/upload/front \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
         "fileName": "front-test.jpg",
         "data": "<BASE64_DATA_CONTENT>"
        }'
```

{% endtab %}

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

```javascript
const frontImage = await complycube.document.upload("5ebd40714f23960008c81527", {
    fileName: "front-test.jpg",
    data: "<BASE64_DATA_CONTENT>"
}, "front");
```

{% endtab %}

{% tab title="Python" %}

```python
front_image = cc_api.documents.upload(
    "5ebd40714f23960008c81527",
    "front",
    fileName="front-test.jpg",
    data="<BASE64_DATA_CONTENT>",
)
```

{% endtab %}

{% tab title="PHP" %}

```php
$up = $ccapi->documents()->upload(
    '5ebd40714f23960008c81527', 
    'front', 
    [
        'fileName' => 'front-test.jpg',
        'data' => '<BASE64_DATA_CONTENT>'
    ]
);
```

{% endtab %}

{% tab title=".NET" %}
{% code fullWidth="false" %}

```csharp
var docFront = new ImageRequest {
  fileName = "front-test.jpg",
  data = "<BASE64_DATA_CONTENT>"
};

var img = await docApi.UploadImageAsync(
    "5ebd40714f23960008c81527", 
    "front", 
    docFront
);
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Example response**

```json
{
    "id": "5eb169302d868c0008828591",
    "fileName": "front-test.jpg",
    "documentSide": "front",
    "downloadLink": "/documents/5ebd40714f23960008c81527/images/5eb169302d868c0008828591/download",
    "contentType": "image/jpg",
    "size": 72716,
    "createdAt": "2025-01-04T17:25:21.116Z",
    "updatedAt": "2025-01-04T17:25:21.116Z"
}
```

{% endstep %}

{% step %}

#### Create an Identity Check

Create an Identity Check by specifying the **Client ID**, **Live Photo ID**, **Document ID**, and the **check type**.

The response will contain an `id` (the Check ID). It is required for the next step.

**Example request for creating a check**

{% 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":"5eb04fcd0f3e360008035eb1",
          "livePhotoId":"5eb1b5f231778a0008d1c3f6",
          "documentId":"5ebd40714f23960008c81527",
          "type": "identity_check"
        }'
```

{% endtab %}

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

```javascript
const check = await complycube.check.create("5eb04fcd0f3e360008035eb1", {
        livePhotoId: "5eb1b5f231778a0008d1c3f6",
        documentId: "5ebd40714f23960008c81527",
        type: "identity_check"
});
```

{% endtab %}

{% tab title="Python" %}

```python
check = cc_api.checks.create('5eb04fcd0f3e360008035eb1', 
                                'identity_check', 
                                livePhotoId='5eb1b5f231778a0008d1c3f6',
                                documentId='5ebd40714f23960008c81527')
```

{% endtab %}

{% tab title="PHP" %}

```php
$result = $ccapi->checks()->create('5eb04fcd0f3e360008035eb1',
                                   ['type' => 'identity_check',
                                   'livePhotoId' => '5eb1b5f231778a0008d1c3f6',
                                   'documentId' => '5ebd40714f23960008c81527']);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
var checkRequest = new CheckRequest
                    {
                        clientId = "5eb04fcd0f3e360008035eb1",
                        documentId = "5ebd40714f23960008c81527",
                        livePhotoId = "5eb1b5f231778a0008d1c3f6",
                        type = "identity_check"
                    };

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

{% endtab %}
{% endtabs %}

**Example response**

The response will contain an `id` (the Check ID). It is required for the next step.

```json
{
    "id": "65c12a6426d2ab000814037e",
    "entityName": "John Doe",
    "type": "identity_check",
    "clientId": "5eb04fcd0f3e360008035eb1",
    "livePhotoId": "5eb1b5f231778a0008d1c3f6",
    "documentId": "5ebd40714f23960008c81527",
    "status": "pending",
    "createdAt": "2025-01-04T17:25:21.116Z",
    "updatedAt": "2025-01-04T17:25:21.116Z"
}
```

{% endstep %}

{% step %}

#### Retrieve results

ComplyCube will then run the check. You can retrieve its [outcome and detailed breakdown](/documentation/api-reference/check-types/identity-check.md#result-object) via the API, or review the results in the Portal.

If you have [set up webhooks](/documentation/integration-resources/webhooks.md), you’ll also receive a notification once the check is complete.

**Example request for retrieving the check outcome**

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

```bash
curl -X GET https://api.complycube.com/v1/checks/5ebd40714f23960008c81527 \
     -H 'Authorization: <YOUR_API_KEY>'
```

{% endtab %}

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

```javascript
const check = await complycube.check.get("5ebd40714f23960008c81527");
```

{% endtab %}

{% tab title="Python" %}

```python
check = cc_api.checks.get('5ebd40714f23960008c81527')
```

{% endtab %}

{% tab title="PHP" %}

```php
$check = $ccapi->checks()->get('5ebd40714f23960008c81527');
```

{% endtab %}

{% tab title=".NET" %}

```csharp
var check = await checkApi.GetAsync("5ebd40714f23960008c81527");
```

{% endtab %}
{% endtabs %}

**Example response**

```json
{
   "id": "5e94b88a01bce00008c86f06",
   "entityName": "John Doe",
   "type": "identity_check",
   "clientId": "5e94b75d01bce00008c86f02",
   "documentId": "5e94b87b01bce00008c86f03",
   "livePhotoId": "5e94b88901bce00008c86f05",
   "status": "complete",
   "result": {
      "outcome": "clear",
      "breakdown": {
         "faceAnalysis": {
            "faceDetection": "clear",
            "facialSimilarity": "clear",
            "breakdown": {
               "facialSimilarityScore": 100
            }
         },
         "authenticityAnalysis": {
            "spoofedImageAnalysis": "clear",
            "livenessCheck": "clear",
            "breakdown": {
               "livenessCheckScore": 100
            }
         },
         "integrityAnalysis": {
            "faceDetection": "clear"
         }
      }
   },
   "createdAt": "2025-01-04T17:25:21.116Z",
   "updatedAt": "2025-01-04T17:25:21.116Z"
}
```

{% endstep %}
{% endstepper %}


---

# Agent Instructions: 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:

```
GET https://docs.complycube.com/documentation/quick-guides/api-quick-guide/run-an-identity-check.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
