> For the complete documentation index, see [llms.txt](https://manual.personr.co/api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.personr.co/api-documentation/applicants/uploading-documents-to-an-applicant.md).

# Uploading documents to an applicant

Instead of using a verification link, use this endpoint to upload document images directly via API.

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' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN' \
--data '{
	"applicantId": "4242424242424x424242424242424242",
	"docType": "ID_CARD",
	"docSubType": "FRONT_SIDE",
	"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: { 
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_TOKEN'
  },
  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..."
            }
        };

        fetch(url, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "Authorization": "Bearer YOUR_TOKEN"
            },
            body: JSON.stringify(payload)
        })
        .then(response => response.text())
        .then(text => console.log(text))
        .catch(error => console.error('Error:', error));
```

{% 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["Content-Type"] = "application/json"
request["Authorization"] = "Bearer YOUR_TOKEN"
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 = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_TOKEN'
}

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](/api-documentation/applicants/requesting-to-start-the-verification-process.md) to confirm everything has been uploaded, and to start the verification check.
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://manual.personr.co/api-documentation/applicants/uploading-documents-to-an-applicant.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
