# Upload 1–10 FILE documents (multipart field `files`).

`POST /api/plugins/docs/documents/upload`

Authentication: no security requirement declared for this operation.

Request body: multipart/form-data (required)

Type: object

Schema: [UploadDocumentsDTO](https://sourcey-gauzy.pages.dev/api-reference/models/uploaddocumentsdto/index.md)

- `tenant` (optional)
  Type: object

- `tenantId` (optional)
  Type: string

- `organization` (required)
  Type: object

- `organizationId` (required)
  Type: string

- `sentTo` (optional)
  Type: string

- `parentId` (optional)
  Type: string

- `visibility` (optional)
  Type: string
  
  enum: ["ORGANIZATION","PRIVATE"]

- `categoryIds` (optional)
  Type: array
  
  Items:
    Type: string

- `tagIds` (optional)
  Type: array
  
  Items:
    Type: string

- `importToKnowledge` (optional)
  Type: boolean

- `classifyWithAi` (optional)
  Type: boolean

- `source` (optional)
  Type: string
  
  enum: ["UPLOAD","EDITOR","CHAT","EMAIL","INTEGRATION","SYSTEM","IMPORT"]

Responses:

- 201: Per-file upload results returned.

- 400: Every file in the batch was rejected.

- 413: Every file in the batch is oversize.

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/plugins/docs/documents/upload' \
  --form-string 'tenant={}' \
  --form-string 'tenantId=string' \
  --form-string 'organization={}' \
  --form-string 'organizationId=string' \
  --form-string 'sentTo=string' \
  --form-string 'parentId=string' \
  --form-string 'visibility=ORGANIZATION' \
  --form-string 'categoryIds=string' \
  --form-string 'tagIds=string' \
  --form-string 'importToKnowledge=true' \
  --form-string 'classifyWithAi=true' \
  --form-string 'source=UPLOAD'
```

### JavaScript

```javascript
const form = new FormData();
form.append('tenant', '{}');
form.append('tenantId', 'string');
form.append('organization', '{}');
form.append('organizationId', 'string');
form.append('sentTo', 'string');
form.append('parentId', 'string');
form.append('visibility', 'ORGANIZATION');
form.append('categoryIds', 'string');
form.append('tagIds', 'string');
form.append('importToKnowledge', 'true');
form.append('classifyWithAi', 'true');
form.append('source', 'UPLOAD');
const response = await fetch('http://localhost:3000/api/plugins/docs/documents/upload', {
  method: 'POST',
  headers: {},
  body: form,
});
console.log(await response.text());
```

### Python

```python
import requests
from contextlib import ExitStack

with ExitStack() as stack:
    files = [
        ('tenant', (None, '{}')),
        ('tenantId', (None, 'string')),
        ('organization', (None, '{}')),
        ('organizationId', (None, 'string')),
        ('sentTo', (None, 'string')),
        ('parentId', (None, 'string')),
        ('visibility', (None, 'ORGANIZATION')),
        ('categoryIds', (None, 'string')),
        ('tagIds', (None, 'string')),
        ('importToKnowledge', (None, 'true')),
        ('classifyWithAi', (None, 'true')),
        ('source', (None, 'UPLOAD')),
    ]
    response = requests.request('POST', 'http://localhost:3000/api/plugins/docs/documents/upload', headers={}, files=files)
    print(response.text)
```
