# Replace the stored file of a FILE document in place (multipart field `file`).

`POST /api/plugins/docs/documents/{id}/file`

Authentication: no security requirement declared for this operation.

Parameters:

- `id` (path, string, required)
  Type: string

Request body: multipart/form-data (required)

Type: object

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

- `classifyWithAi` (optional)
  Type: boolean

Responses:

- 200: File replaced; the pipeline was re-enqueued.

- 409: The target document is not a FILE.

- 413: The replacement file is oversize.

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/plugins/docs/documents/string/file' \
  --form-string 'classifyWithAi=true'
```

### JavaScript

```javascript
const form = new FormData();
form.append('classifyWithAi', 'true');
const response = await fetch('http://localhost:3000/api/plugins/docs/documents/string/file', {
  method: 'POST',
  headers: {},
  body: form,
});
console.log(await response.text());
```

### Python

```python
import requests
from contextlib import ExitStack

with ExitStack() as stack:
    files = [
        ('classifyWithAi', (None, 'true')),
    ]
    response = requests.request('POST', 'http://localhost:3000/api/plugins/docs/documents/string/file', headers={}, files=files)
    print(response.text)
```
