Update file source
PUT/v2/agents/{agentId}/sources/{sourceId}/file
Replace the file of an existing file source with a new upload, keep its ID and queue it for training again with multipart form data.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
Replaces the file behind a file source. The source keeps its ID and its title, and training starts again with the new content. Call it when a manual or policy document has a new version, so the agent does not answer from the old one.
Send the file as multipart/form-data, as in Create file source.
Request
PUT /v2/agents/{agentId}/sources/{sourceId}/file
Path parameters:
| Name | Type | Required | Description |
|---|---|---|---|
agentId |
string | Yes | The ID of the agent, starting with agt_. |
sourceId |
string | Yes | The ID of the file source, starting with src_. |
Form fields:
| Name | Type | Required | Description |
|---|---|---|---|
file |
file | Yes | The new PDF, DOCX, TXT or CSV file. It replaces the old file completely. |
The call changes only the file. To rename the source, use Update source. The call works only on sources of type file.
Example request
curl -X PUT https://api.askocto.co/v2/agents/agt_8f3k2m/sources/src_4n7c2w/file \
-H "Authorization: Bearer $OCTO_API_KEY" \
-F "file=@./returns-policy-v2.pdf"
import { openAsBlob } from "node:fs"
const form = new FormData()
form.append("file", await openAsBlob("./returns-policy-v2.pdf"), "returns-policy-v2.pdf")
const response = await fetch(
"https://api.askocto.co/v2/agents/agt_8f3k2m/sources/src_4n7c2w/file",
{
method: "PUT",
headers: { Authorization: `Bearer ${process.env.OCTO_API_KEY}` },
body: form,
},
)
const source = await response.json()
console.log(source.status)
Example response
A successful call returns 200 OK with the source. Its status is queued.
{
"id": "src_4n7c2w",
"type": "file",
"title": "Returns policy",
"status": "queued",
"characters": 0,
"failureReason": null,
"createdAt": "2026-03-19T15:02:00Z"
}
Response fields
The response is a source object, described under Get source. characters resets to 0 until training reads the new file, and failureReason clears. A source that was failed gets a fresh attempt this way, which is the usual fix for an unreadable upload.
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request |
The file part is missing or empty, the file type is not supported, or the source is not a file source. |
| 401 | unauthorized |
The API key is missing, malformed or deleted. |
| 404 | not_found |
The agent or the source does not exist in your workspace. |
| 409 | conflict |
The source is in the status training. Wait until it is ready or failed, then upload again. |
| 429 | rate_limited |
Too many requests. Wait for the number of seconds in the Retry-After header. |