> 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.11/rest-api/knowledge-base/upload-document.md).

# Upload document

{% 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,
    "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

***

## 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,
  "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,
    "csv_delimiter": "comma",
    "image_min_size_ratio": 0.3,
    "tags": ["683633c22173dda..."]
}'
```

{% endtab %}
{% endtabs %}


---

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://40factory.gitbook.io/wilson/3.11/rest-api/knowledge-base/upload-document.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
