# Uploading documents to an applicant

This endpoint allows you to upload document and selfie images directly via API. You may want to do this to fully customise the look and feel of the verification process within your website or application.

{% hint style="warning" %}
Note: You don't need to use this endpoint if you're verifying applicants using a verification link.
{% endhint %}

Each call can only receive one document. If you're uploading double-sided documents, make sure to send `FRONT_SIDE` and `BACK_SIDE` in the docSubType parameter. Verifications won't proceed until all required document images, sides and/or selfie images are uploaded - if applicable to your chosen flow.

***

## Upload documents to your applicant

<mark style="color:green;">`POST`</mark> `/api-document-upload`

Upload documents in base64 format to your applicant, ready for processing.

| Name          | Value                 |
| ------------- | --------------------- |
| Content-Type  | `multipart/form-data` |
| Authorization | `Bearer YOUR_TOKEN`   |

**Body**

<table><thead><tr><th>Name</th><th width="165">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>applicantId</code></td><td>string</td><td>Unique applicantId generated on applicant creation <mark style="color:red;">(required)</mark></td></tr><tr><td><code>docType</code></td><td>string</td><td>Type of document being uploaded, see next page for supported documents and types <mark style="color:red;">(required)</mark></td></tr><tr><td><code>docSubType</code></td><td>string</td><td><code>FRONT_SIDE</code>, <code>BACK_SIDE</code> or null. Not required for Selfies. <mark style="color:orange;">(optional)</mark></td></tr><tr><td><code>docCountryISO</code></td><td>string</td><td>3-letter <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">country code</a>, eg. AUS<br><mark style="color:red;">(required)</mark></td></tr><tr><td><code>docFile</code></td><td>object</td><td>An object representing the file being uploaded, see details below<br><mark style="color:red;">(required)</mark></td></tr></tbody></table>

#### docFile fields

<table><thead><tr><th width="295">Name</th><th width="163">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>filename</code></td><td>string</td><td>Name of the file, including extension (jpg/jpeg/png/pdf) - eg. Photo.jpg<br><mark style="color:red;">(required)</mark></td></tr><tr><td><code>contents</code></td><td>string</td><td>File content in <a href="https://developer.mozilla.org/en-US/docs/Glossary/Base64">base64 encoded</a> format. Max Size ~50MB, recommended size &#x3C;20MB.<mark style="color:red;">(required)</mark></td></tr></tbody></table>

#### Request

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

```sh
curl --location 'https://enterprise.personr.co/api/1.1/wf/api-document-upload' \
--data '{
	"applicantId": "4242424242424x424242424242424242",
	"docType": "ID_CARD",
    "docSubType": "FRONT_SIDE", // Remove this when docType is SELFIE
	"docCountryISO": "AUS",
	"docFile": {
        "filename": "idcard_australia.jpg",
        "contents": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
    }
}'
```

{% endtab %}

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

```javascript
var axios = require('axios');
var data = '{\r\n\t"applicantId": "4242424242424x424242424242424242",\r\n\t"docType": "ID_CARD",\r\n    "docSubType": "FRONT_SIDE",\r\n\t"docCountryISO": "AUS",\r\n\t"docFile": {\r\n        "filename": "idcard_australia.jpg",\r\n        "contents": "/9j/4AAQSkZJRgABAQAAAQABAAD..."\r\n    }\r\n}';

var config = {
  method: 'post',
maxBodyLength: Infinity,
  url: 'https://enterprise.personr.co/api/1.1/wf/api-document-upload',
  headers: { },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const url = "https://enterprise.personr.co/api/1.1/wf/api-document-upload";
        
        const payload = {
            "applicantId": "4242424242424x424242424242424242",
            "docType": "ID_CARD",
            "docSubType": "FRONT_SIDE",
            "docCountryISO": "AUS",
            "docFile": {
                "filename": "idcard_australia.jpg",
                "contents": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
            }
        };
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("https://enterprise.personr.co/api/1.1/wf/api-document-upload")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request.body = "{\r\n\t\"applicantId\": \"4242424242424x424242424242424242\",\r\n\t\"docType\": \"ID_CARD\",\r\n    \"docSubType\": \"FRONT_SIDE\",\r\n\t\"docCountryISO\": \"AUS\",\r\n\t\"docFile\": {\r\n        \"filename\": \"idcard_australia.jpg\",\r\n        \"contents\": \"/9j/4AAQSkZJRgABAQAAAQABAAD...\"\r\n    }\r\n}"

response = https.request(request)
puts response.read_body
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://enterprise.personr.co/api/1.1/wf/api-document-upload"

payload = "{\r\n\t\"applicantId\": \"4242424242424x424242424242424242\",\r\n\t\"docType\": \"ID_CARD\",\r\n    \"docSubType\": \"FRONT_SIDE\",\r\n\t\"docCountryISO\": \"AUS\",\r\n\t\"docFile\": {\r\n        \"filename\": \"idcard_australia.jpg\",\r\n        \"contents\": \"/9j/4AAQSkZJRgABAQAAAQABAAD...\"\r\n    }\r\n}"
headers = {}

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

print(response.text)
```

{% endtab %}
{% endtabs %}

You must upload all required documents for your chosen Flow, otherwise the verification won't proceed. For example, if your Flow requires one identity document and a selfie, you'll need to upload the `FRONT_SIDE` and `BACK_SIDE` of the identity document and a selfie image in three separate endpoint calls.

**Response**

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

```json
{
    "applicantId": "4242424242424x424242424242424242",
    "documentType": "ID_CARD",
    "documentSubType": "FRONT_SIDE",
    "country": "AUS",
    "errors": [],
    "warnings": []
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "statusCode": 400,
    "message": "Error: Cannot read docSets - invalid docType provided."
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
Once all required documents and selfie images have been uploaded for your chosen flow, head to [requesting-to-start-the-verification-process](https://manual.personr.co/api-documentation/applicants/requesting-to-start-the-verification-process "mention") to confirm everything has been uploaded, and to start the verification check.
{% endhint %}
