# Perform Document Check

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

This guide shows you how to run a Document check using the ComplyCube API.

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

## Integration steps <a href="#create-an-applicant" id="create-an-applicant"></a>

<figure><img src="https://2950143584-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsw26JqCBnT6AEIbxAYyk%2Fuploads%2FlN8Me4Josvb5zgBzZBGm%2Fdocumentation-Document%20Check.png?alt=media&#x26;token=d21e2959-1bad-49b0-ab1b-4c0a4637c412" alt=""><figcaption><p>Document Check API Guide</p></figcaption></figure>

{% stepper %}
{% step %}

#### Create a client <a href="#create-an-applicant" id="create-an-applicant"></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**&#x20;

{% 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**

```javascript
{
    "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 document <a href="#create-an-applicant" id="create-an-applicant"></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**

```javascript
{
    "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](https://app.gitbook.com/s/KyFKMqftsmT6qln9zo5y/identity-verification/document-check/document-sides-per-type) and issuing country, both sides may be required.&#x20;

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="<https://content.gitbook.com/content/sw26JqCBnT6AEIbxAYyk/blobs/BUFZBRGtEDT0F3aMZGLx/base64-encoded-id-sample.txt>" %}
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**

```javascript
{
    "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 a check

Create a check by specifying the **Client 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",
          "documentId":"5ebd40714f23960008c81527",
          "type": "document_check"
        }'
```

{% endtab %}

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

```javascript
const check = await complycube.check.create("5eb1276d96be4a0008713af5", {
    documentId: "5ebd40714f23960008c81527",
    type: "document_check"
});
```

{% endtab %}

{% tab title="Python" %}

```python
check = cc_api.checks.create(
    "5eb1276d96be4a0008713af5", 
    "document_check", 
    documentId="5ebd40714f23960008c81527"
)
```

{% endtab %}

{% tab title="PHP" %}

```php
$result = $ccapi->checks()->create(
    '5eb1276d96be4a0008713af5',
    [
        'type' => 'document_check',
        'documentId' => '5ebd40714f23960008c81527'
    ]
);
```

{% endtab %}

{% tab title=".NET" %}

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

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

{% endtab %}
{% endtabs %}

**Example response**

```javascript
{
    "id": "65c12a6426d2ab000814037e",
    "entityName": "John Doe",
    "type": "document_check",
    "clientId": "5eb04fcd0f3e360008035eb1",
    "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](https://app.gitbook.com/s/kAhgmUKSf8CFUFVL3GEe/check-types/document-check#result-object) via the API, or review the results in the Portal.

If you have [set up webhooks](https://docs.complycube.com/documentation/integration-resources/webhooks), 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": "65c12a6426d2ab000814037e",
  "clientId": "5eb04fcd0f3e360008035eb1",
  "documentId": "5ebd40714f23960008c81527",
  "entityName": "John Doe",
  "type": "document_check",
  "status": "complete",
  "result": {
    "outcome": "clear",
    "breakdown": {
      "extractedData": {
        "documentDetails": {
          "documentType": "driving_license",
          "hasTwoSides": true,
          "issuingCountry": "GB",
          "issuingDate": {
            "day": 1,
            "month": 1,
            "year": 2015
          },
          "expirationDate": {
            "day": 1,
            "month": 1,
            "year": 2025
          },
          "documentNumber": "123456790",
          "personalNumber": "123456790"
        },
        "holderDetails": {
          "lastName": [
            "DOE"
          ],
          "firstName": [
            "JOHN"
          ],
          "dob": {
            "day": 3,
            "month": 9,
            "year": 1995
          },
          "address": {
            "addressText": "110 MAPLE ROAD, SAMPLE CITY, NC 10000-0008",
            "line": "110 MAPLE ROAD",
            "city": "SAMPLE CITY",
            "state": "North Carolina",
            "postalCode": "10000-0008",
            "country": "US"
          }
        }
      },
      "allExtractedData": {
        "visual": {
          "lastName": [
            "DOE"
          ],
          "firstName": [
            "JOHN"
          ],
          "dob": {
            "day": 3,
            "month": 9,
            "year": 1995
          },
          "age": 26,
          "gender": "male",
          "documentNumber": "123456790",
          "documentDiscriminator": "123456790",
          "issuingDate": {
            "day": 1,
            "month": 1,
            "year": 2015
          },
          "expirationDate": {
            "day": 1,
            "month": 1,
            "year": 2025
          },
          "addressText": "110 MAPLE ROAD, SAMPLE CITY, NC 10000-0008",
          "addressLine": "110 MAPLE ROAD",
          "addressCity": "SAMPLE CITY",
          "addressPostalCode": "10000-0008",
          "height": "175 cm"
        },
        "barcode": {
          "lastName": [
            "DOE"
          ],
          "firstName": [
            "JOHN"
          ],
          "dob": {
            "day": 3,
            "month": 9,
            "year": 1995
          },
          "gender": "male",
          "documentNumber": "123456790",
          "documentDiscriminator": "123456790",
          "issuingCountry": "US",
          "issuingDate": {
            "day": 15,
            "month": 11,
            "year": 2018
          },
          "expirationDate": {
            "day": 29,
            "month": 9,
            "year": 2026
          },
          "addressText": "110 MAPLE ROAD, SAMPLE CITY, NC 10000-0008",
          "addressLine": "110 MAPLE ROAD",
          "addressCity": "SAMPLE CITY",
          "addressPostalCode": "10000-0008",
          "addressState": "North Carolina",
          "addressCountry": "US",
          "height": "175 cm"
        }
      }
    },
    "mrzAnalysis": {
      "mrzFormat": "clear",
      "mrzChecksum": "clear"
    },
    "consistencyAnalysis": {
      "lastName": "clear",
      "firstName": "clear",
      "dob": "clear",
      "documentNumber": "clear",
      "personalNumber": "clear",
      "expirationDate": "clear",
      "issuingDate": "clear"
    },
    "contentAnalysis": {
      "dataIntegrity": "clear",
      "issuingDate": "clear",
      "expirationDate": "clear",
      "specimenCheck": "clear",
      "blackListCheck": "clear"
    },
    "formatAnalysis": {
      "modelIdentification": "clear",
      "countryModelValidity": "clear",
      "documentModelValidity": "clear",
      "photocopyDetected": "clear"
    },
    "forensicAnalysis": {
      "documentLivenessCheck": "clear",
      "tamperingDetected": "clear",
      "mrzVisualPlacement": "clear",
      "securityElements": "clear",
      "photoLocation": "clear",
      "mrzClassification": "clear",
      "breakdown": {
        "documentFrontLivenessScore": 100,
        "documentBackLivenessScore": 100
      }
    },
    "frontAndBackAnalysis": {
      "formatAnalysis": "clear",
      "dataConsistency": "clear"
    },
    "clientValidation": {
      "ageVerification": "clear",
      "clientDataConsistency": "clear"
    },
    "extractedImages": [{
      "type": "front_side",
      "data": "<BASE64_IMAGE_CONTENT>"
    }],
    "securityAndPatternAnalysis": [{
      "similarity": 100,
      "outcome": "clear",
      "narrative": "Clear",
      "actualImageData": "<BASE64_IMAGE_CONTENT>",
      "expectedImageData": "<BASE64_IMAGE_CONTENT>"
    }]
  },
  "createdAt": "2020-01-01T14:06:44.756Z",
  "updatedAt": "2020-01-01T14:06:91.913Z"
}
```

{% endstep %}
{% endstepper %}
