> For the complete documentation index, see [llms.txt](https://40factory.gitbook.io/wilson/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://40factory.gitbook.io/wilson/3.12/rest-api/knowledge-base/upload-document.md).

# Upload document

Upload ONE document in Knowledge base.

{% hint style="warning" %}
Please, pay attention: Request with breaking changes.
{% endhint %}

## Request <a href="#request" id="request"></a>

### Url

```
POST 
https://wilson.40mat.com/apif/v2/company/<company_id>/knowledge-base
```

### Headers

<pre><code><strong>AUTH
</strong>Bearer "eyJ0eXAiOiJKV1QiLCJub25jZSI6IndUZXphSTNjdTNVYj..."
</code></pre>

### Parameters

```
No parameters are required for this endpoint.
```

### Body

```json
{
    "files": <file>,
    "path": "/folder",
    "loader_type": "STANDARD",
    "auto_description": true,
    "description": null,
    "overwrite": true,
    "csv_delimiter": "comma",
    "image_min_size_ratio": 0.3,
    "multipage_sections": true,
    "tags": ["683633c22173dda..."]
}
```

The request body is in JSON format contain following properties:

* `files` (file): Bytearray of file to be uploaded
* `path` (string): Target path
* `loader_type` (string): Loader type: `ADVANCED` or `STANDARD`
* `auto_description` (boolean): If true, description to be autogenerated
* `description` (string): Description (if not to be autogenerated)
* `overwrite` (boolean): If true, overwrite if exist a document with same filename in same path
* `csv_delimiter` (string): If file csv, usesful to detect delimiter: `comma`, `semicolon` or `tab`
* `image_min_size_ratio` (number): Minimum image size to be extracted as a percentage of the page area
* `tags` (string array): List of tags (id) to associate to document
* `multipage_sections` (boolean): If false, each PDF page is indexed as a separate chunk. Default True. Note: This option works only when `loader_type` is set to `"ADVANCED"`.

***

## Response&#x20;

```json
{
    "id": "683630c11173dda..."
}
```

The response is in JSON format contain following properties:

* `id` (string): Document id

***

## Code example

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

```python
import requests
import json

url = "https://wilson.40mat.com/apif/v2/company/<company_id>/knowledge-base"

file_name = "file_name.txt"
with open(file_path, "rb") as f:
  file_content = f.read()

files_payload = {
  "files": (file_name, file_content)
}
        
payload = {
  "path": "/folder",
  "loader_type": "STANDARD",
  "auto_description": True,
  "description": None,
  "overwrite": True,
  "csv_delimiter": "comma",
  "image_min_size_ratio": 0.3,
  "multipage_sections": True,
  "tags": ["683633c22173dda..."]
}
headers = {
  'Authorization': '••••••'
}

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

print(response.text)
```

{% endtab %}

{% tab title="cURL" %}

```powershell
curl --location 'https://wilson.40mat.com/apif/v2/company/<company_id>/knowledge-base' \
--header 'Authorization: ••••••' \
--data '{
    "files": "...",
    "path": "/folder",
    "loader_type": "STANDARD",
    "auto_description": true,
    "description": null,
    "overwrite": true,
    "multipage_sections": true,
    "csv_delimiter": "comma",
    "image_min_size_ratio": 0.3,
    "tags": ["683633c22173dda..."]
}'
```

{% endtab %}
{% endtabs %}
