# Uploading documents to an entity

This endpoint allows you to upload entity documents 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 entities using a verification link.
{% endhint %}

Each call can only receive one document. Make sure to send the necessary data in the docSubType parameter.

***

## Upload documents to your applicant

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

Upload a document to an entity, 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>docSubType</code></td><td>string</td><td>The corporate document type - see next page for the different types.<mark style="color:orange;">(optional)</mark></td></tr><tr><td><code>docFile</code></td><td>string</td><td>An accessible URL representing the file being uploaded.<br><mark style="color:red;">(required)</mark></td></tr></tbody></table>

#### Request

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

```sh
curl -X POST https://enterprise.personr.co/api/1.1/wf/api-entity-document-upload \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -F "applicantId=4242424242424x424242424242424242" \
    -F "docSubType=Certificate of incorporation" \
    -F "docFile=https://your_document_url.pdf" \
```

{% endtab %}

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

```javascript
var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');

var formData = new FormData();

formData.append('applicantId', '4242424242424x424242424242424242');
formData.append('docSubType', 'Certificate of incorporation');
formData.append('docFile', fs.createReadStream('/path/to/your/file.pdf'), 'your_document.pdf');

var config = {
  method: 'post',
  url: 'https://enterprise.personr.co/api/1.1/wf/api-entity-document-upload',
  headers: { 
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    ...formData.getHeaders(), 
  },
  data: formData,
  maxBodyLength: 'Infinity',
  maxContentLength: 'Infinity'
};

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-entity-document-upload";

const payload = {
    applicantId: "4242424242424x424242424242424242",
    docSubType: "Certificate of incorporation",
    docFile: {
        filename: "/path/to/your/file.pdf",
    }
};

    method: "POST",
    headers: {
        "Content-Type": "application/json"
    },
    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-entity-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\"docSubType\": \"Certificate of incorporation\",\r\n\t\"docFile\": {\r\n\"filename\": \"/path/to/your/file.pdf\",\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-entity-document-upload"

payload = "{\r\n\t\"applicantId\": \"4242424242424x424242424242424242\",\r\n\t\"docSubType\": \"Certificate of incorporation\",\r\n\t\"docFile\": {\r\n\"filename\": \"/path/to/your/file.pdf\",\r\n  }\r\n}"
headers = {}

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

print(response.text)
```

{% endtab %}
{% endtabs %}

**Response**

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

```json
{
    "applicantId": "4242424242424x424242424242424242",
    "documentSubType": "Certificate of incorporation"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "statusCode": 400,
    "message": "Error: invalid applicantId"
}
```

{% endtab %}
{% endtabs %}

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