# Document Upload

{% hint style="info" %}
To differentiate the document evaluation items, the `warningTags` include the `isDoc` key.\
Example:

<pre class="language-json"><code class="lang-json">{ 
    "tag": "compromised_document", 
    "passed": true, 
    <a data-footnote-ref href="#user-content-fn-1">"isDoc": true,</a> 
    "label": "Compromised Document" 
}
</code></pre>

{% endhint %}

## Upload a document

<mark style="color:blue;">`POST`</mark> `https://api.waldo.ai/document`

{% hint style="info" %}
All evaluation requests are asynchronous. \
Therefore, the response to the document check request will not be completed in real time.\
If you have set up the webhooks, your system will receive notifications automatically.\
Otherwise, your system can poll Waldo's API until the evaluation is completed.
{% endhint %}

#### Headers

| Name                                            | Type   | Description                                |
| ----------------------------------------------- | ------ | ------------------------------------------ |
| Authorization<mark style="color:red;">\*</mark> | String | The token in the format `Bearer eyJhbG...` |
| Content-Type<mark style="color:red;">\*</mark>  | String | Expected type is `multipart/form-data`     |

#### Request fields

| Name           | Type        | Description                                                                                    | Location  |
| -------------- | ----------- | ---------------------------------------------------------------------------------------------- | --------- |
| document       | binary file | Dcoument scan (`.jpg`, `png`, or `.pdf)` Maximum 10Mb size                                     | Body      |
| side           | String      | `front`or `back`                                                                               | Form data |
| customerId     | String      | Customer ID                                                                                    | Form data |
| documentType   | String      | `driving_licence`(US only), or `passport`(worldwide)                                           | Form data |
| issuingCountry | String      | Country code ([ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) standard) | Form data |

#### Response

{% tabs %}
{% tab title="200: OK Document Upload Evaluation" %}

```json
{
  "requestId": "ayclpQyi6p",
  "event": "evaluation",
  "evaluation": {
    "type": "document",
    "status": "initiated"
  },
  "customerId": "66b9fc5fcfd24a0bb512fdeb",
  "uri": "https://app.waldo.ai/customers/66b9fc5fcfd24a0bb512fdeb",
  "errors": []
}
```

{% endtab %}

{% tab title="400 Bad request" %}

```json
{
    "code": "MISSING_DATA",
    "message": "Missing data: {field name}"
}
```

{% endtab %}

{% tab title="403: Forbidden Missing authorization header" %}

```json
{
  "code": "NOT_AUTHORIZED",
  "message": "Not authorized."
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid token or expired" %}

```json
{
  "code": "INVALID_TOKEN",
  "message": "Invalid token."
}
```

{% endtab %}

{% tab title="403: Forbidden Service not authorized" %}

```json
{
  "code": "NOT_AUTHORIZED",
  "message": "You are not authorized to perform this action. Please contact support for assistance."
}
```

{% endtab %}

{% tab title="403: Forbidden Inactive API key" %}

```json
{
  "code": "API_KEY_REVOKED",
  "message": "This API key has been revoked. Please visit the Waldo AI dashboard to review your API key."
}
```

{% endtab %}
{% endtabs %}

#### Webhooks complete event notification

```json
{
  "requestId": "ayclpQyi6p",
  "event": "evaluation",
  "evaluation": {
    "type": "document",
    "status": "completed"
  },
  "validation": {
    "status": "APPROVED",
    "kyc": "PASSED",
    "fraudScore": 0.9,
    "fraudFlag": false,
    "warnings": 3,
    "warningTags": [
      {
        "tag": "ssn",
        "passed": true,
        "label": "SSN Integrity"
      },
      {
        "tag": "date_of_birth",
        "passed": true,
        "label": "Date of Birth Integrity"
      },
      {
        "tag": "legal_and_regulatory_warnings",
        "passed": true,
        "label": "Legal and Regulatory Warnings"
      },
      {
        "tag": "politically_exposed_person",
        "passed": true,
        "label": "Politically Exposed Person"
      },
      {
        "tag": "sanction",
        "passed": true,
        "label": "Sanctions List"
      },
      {
        "tag": "age_validation",
        "passed": false,
        "isDoc": true,
        "label": "Age Validation"
      },
      {
        "tag": "image_integrity",
        "passed": false,
        "isDoc": true,
        "label": "Image Integrity"
      },
      {
        "tag": "data_comparison",
        "passed": true,
        "isDoc": true,
        "label": "Data Comparison"
      },
      {
        "tag": "data_consistency",
        "passed": true,
        "isDoc": true,
        "label": "Data Consistency"
      },
      {
        "tag": "compromised_document",
        "passed": true,
        "isDoc": true,
        "label": "Compromised Document"
      },
      {
        "tag": "visual_authenticity",
        "passed": false,
        "isDoc": true,
        "label": "Visual Authenticity"
      },
      {
        "tag": "data_validation",
        "passed": true,
        "isDoc": true,
        "label": "Data Validation"
      }
    ],
    "kycBreakdown": {
      "identityBreakdown": {},
      "watchlistBreakdown": {},
      "documentBreakdown": {
        "age_validation": {
          "label": "Age Validation",
          "passed": false,
          "tags": {
            "minimum_accepted_age": {
              "label": "Minimum Accepted Age",
              "passed": false
            }
          }
        },
        "image_integrity": {
          "label": "Image Integrity",
          "passed": false,
          "tags": {
            "colour_picture": {
              "label": "Colour Picture",
              "passed": false
            },
            "image_quality": {
              "label": "Image Quality",
              "passed": false
            }
          }
        },
        "visual_authenticity": {
          "label": "Visual Authenticity",
          "passed": false,
          "tags": {
            "digital_tampering": {
              "label": "Digital Tampering",
              "passed": false
            },
            "picture_face_integrity": {
              "label": "Picture Face Integrity",
              "passed": false
            }
          }
        }
      }
    }
  },
  "customerId": "<customer-id>",
  "uri": "https://app.waldo.ai/customers/<customer-id>",
  "errors": []
}
```

[^1]: The field is specific to document features
