API reference
Replace a file
PUT /v1/knowledge-bases/{knowledge_base_id}/documents/{document_id}
Send a new version of a file, as multipart/form-data. It keeps its id and goes back to pending; agents keep answering from the old version until the new one is indexed — and if that fails, the old one stays, and error says why. Needs knowledge:write and a live key.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
knowledge_base_id |
path | string (uuid) | Yes | |
document_id |
path | string (uuid) | Yes |
Body
Sent as multipart/form-data.
| Field | Type | Required | Description |
|---|---|---|---|
file |
string | Yes | The new version. |
Answer
202 with KnowledgeDocument.
Errors
Every error is a problem document with a stable code.
| Status | When |
|---|---|
401 |
The key is missing, mistyped, unknown, revoked or expired. |
403 |
A test key, or a key limited to some agents. |
404 |
This key reaches no such knowledge base. |
409 |
The source is being indexed right now, came from a website rather than a file, the same bytes are another source in the base, or the project is frozen. |
413 |
The file is over the size this deployment takes. |
415 |
Not a file type the base reads, or a text file that is not UTF-8. |
422 |
The file is empty, or the base holds as many sources as it may. |
429 |
Too many files sent just now. Wait for Retry-After. |
500 |
Something went wrong on our side. Quote the request_id to support. |
Examples
#!/bin/sh
# Replace a file with a new version. It keeps its id; agents answer from the old version until the new one is indexed.
curl -sS --fail-with-body -X PUT "https://api.aigently.ai/v1/knowledge-bases/6e8a0c2d-4f6b-4d8e-a0c2-4e6a8c0e2a4c/documents/7f9b1d3e-5a7c-4e9f-b1d3-5f7b9d1f3b5d" \
-H "Authorization: Bearer $AIGENTLY_API_KEY" \
-F "file=@opening-hours.md;type=text/markdown"
Try it
Sends this request to the API from your browser, with a test key. Nothing it does rings a phone.