> For the complete documentation index, see [llms.txt](https://docs.complycube.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.complycube.com/documentation/documentation/documentation-es/guias-rapidas/api-quick-guide/run-a-document-check.md).

# Realizar comprobación de documentos

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

Esta guía te muestra cómo ejecutar una comprobación de documentos usando la API de ComplyCube.

{% hint style="success" %}
Puedes probar esta verificación de inmediato usando nuestra [Colección de demostración de Postman](/documentation/documentation/documentation-es/recursos-de-integracion/postman.md#demo-collection). Es de acceso público y **no requiere una cuenta**.
{% endhint %}

### Pasos de integración <a href="#integration-steps" id="integration-steps"></a>

<figure><img src="/files/d0441fdbe331159d8a718fe9852e5e743047b567" alt=""><figcaption><p>Guía de la API de comprobación de documentos</p></figcaption></figure>

{% stepper %}
{% step %}

#### Crear un cliente <a href="#create-a-client" id="create-a-client"></a>

El primer paso para crear cualquier comprobación es añadir un **cliente** desde su servidor backend. Un cliente puede representar a una **persona** o una **empresa**.

La respuesta contendrá un `id` (el ID del cliente). Es necesario para el siguiente paso.

**Ejemplo de solicitud para crear un cliente**

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

**Respuesta de ejemplo**

```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 %}

#### Crear un documento <a href="#create-a-document" id="create-a-document"></a>

Cree un documento proporcionando el **ID del cliente** y **tipo de documento** (p. ej., pasaporte, documento nacional de identidad).

La respuesta contendrá un `id` (el ID del documento). Es necesario para el siguiente paso.

**Ejemplo de solicitud para crear un documento**

{% 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": "pasaporte",
          "issuingCountry": "GB"
        }'
```

{% endtab %}

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

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

{% endtab %}

{% tab title="Python" %}

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

{% endtab %}

{% tab title="PHP" %}

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

{% endtab %}

{% tab title=".NET" %}

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

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

{% endtab %}
{% endtabs %}

**Respuesta de ejemplo**

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

{% endstep %}

{% step %}

#### Cargar el anverso del documento de identidad

Suba una imagen codificada en BASE64 de la parte frontal del documento de identidad. Dependiendo del [tipo de documento](/documentation/product-guides/product-guide-es/verificacion-de-identidad/document-check/document-sides-per-type.md) y del país emisor, pueden requerirse ambos lados.

Las imágenes deben estar en **JPG**, **PNG**, o **PDF** formato y entre **34 KB** y **4 MB** de tamaño.

A continuación se muestra un archivo de ejemplo codificado en BASE64. Descárguelo, copie su contenido y péguelo en el `data` atributo al realizar la solicitud.

{% file src="/files/ac4a7c1f9811258019c7ae78ec44756c108fd8ab" %}
Ejemplo: cara frontal del pasaporte codificada en BASE64
{% endfile %}

**Solicitud de ejemplo para subir la imagen del anverso de un documento**

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

**Respuesta de ejemplo**

```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 %}

#### Crear una comprobación

Crea una comprobación especificando el **ID del cliente**, **ID del documento**, y el **tipo de comprobación**.

La respuesta contendrá un `id` (el ID de la comprobación). Es necesario para el siguiente paso.

**Ejemplo de solicitud para crear una comprobación**

{% 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("5eb04fcd0f3e360008035eb1", {
    documentId: "5ebd40714f23960008c81527",
    type: "document_check"
});
```

{% endtab %}

{% tab title="Python" %}

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

{% endtab %}

{% tab title="PHP" %}

```php
$result = $ccapi->checks()->create(
    '5eb04fcd0f3e360008035eb1',
    [
        '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 %}

**Respuesta de ejemplo**

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

{% endstep %}

{% step %}

#### Recuperar resultados

ComplyCube ejecutará entonces la comprobación. Puedes recuperar su [resultado y desglose detallado](/documentation/api-reference/check-types/document-check.md#result-object) a través de la API, o revisar los resultados en el Portal.

Si has [configurado webhooks](/documentation/documentation/documentation-es/recursos-de-integracion/webhooks.md), también recibirás una notificación una vez que la comprobación se haya completado.

**Ejemplo de solicitud para recuperar el resultado de la comprobación**

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

**Respuesta de ejemplo**

```json
{
  "id": "65c12a6426d2ab000814037e",
  "clientId": "5eb04fcd0f3e360008035eb1",
  "documentId": "5ebd40714f23960008c81527",
  "entityName": "John Doe",
  "type": "document_check",
  "status": "completado",
  "result": {
    "outcome": "sin incidencias",
    "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": "Carolina del Norte",
            "postalCode": "10000-0008",
            "country": "US"
          }
        }
      },
      "allExtractedData": {
        "visual": {
          "lastName": [
            "DOE"
          ],
          "firstName": [
            "JOHN"
          ],
          "dob": {
            "day": 3,
            "month": 9,
            "year": 1995
          },
          "age": 26,
          "gender": "masculino",
          "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": "masculino",
          "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": "Carolina del Norte",
          "addressCountry": "US",
          "height": "175 cm"
        }
      }
    },
    "mrzAnalysis": {
      "mrzFormat": "sin incidencias",
      "mrzChecksum": "sin incidencias"
    },
    "consistencyAnalysis": {
      "lastName": "sin incidencias",
      "firstName": "sin incidencias",
      "dob": "sin incidencias",
      "documentNumber": "sin incidencias",
      "personalNumber": "sin incidencias",
      "expirationDate": "sin incidencias",
      "issuingDate": "sin incidencias"
    },
    "contentAnalysis": {
      "dataIntegrity": "sin incidencias",
      "issuingDate": "sin incidencias",
      "expirationDate": "sin incidencias",
      "specimenCheck": "sin incidencias",
      "blackListCheck": "sin incidencias"
    },
    "formatAnalysis": {
      "modelIdentification": "sin incidencias",
      "countryModelValidity": "sin incidencias",
      "documentModelValidity": "sin incidencias",
      "photocopyDetected": "sin incidencias"
    },
    "forensicAnalysis": {
      "documentLivenessCheck": "sin incidencias",
      "tamperingDetected": "sin incidencias",
      "mrzVisualPlacement": "sin incidencias",
      "securityElements": "sin incidencias",
      "photoLocation": "sin incidencias",
      "mrzClassification": "sin incidencias",
      "breakdown": {
        "documentFrontLivenessScore": 100,
        "documentBackLivenessScore": 100
      }
    },
    "frontAndBackAnalysis": {
      "formatAnalysis": "sin incidencias",
      "dataConsistency": "sin incidencias"
    },
    "clientValidation": {
      "ageVerification": "sin incidencias",
      "clientDataConsistency": "sin incidencias"
    },
    "extractedImages": [{
      "type": "front_side",
      "data": "<BASE64_IMAGE_CONTENT>"
    }],
    "securityAndPatternAnalysis": [{
      "similarity": 100,
      "outcome": "sin incidencias",
      "narrative": "Sin incidencias",
      "actualImageData": "<BASE64_IMAGE_CONTENT>",
      "expectedImageData": "<BASE64_IMAGE_CONTENT>"
    }]
  },
  "createdAt": "2020-01-01T14:06:44.756Z",
  "updatedAt": "2020-01-01T14:06:44.756Z"
}
```

{% endstep %}
{% endstepper %}


---

# 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.complycube.com/documentation/documentation/documentation-es/guias-rapidas/api-quick-guide/run-a-document-check.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.
