Toggle auto retrain
PUT/v2/agents/{agentId}/auto-retrain
Turn scheduled retraining of an agent's sources on or off, and choose whether it runs daily or weekly.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
Turns Auto-retrain on or off for an agent. When it is on, the agent retrains its sources on a schedule, so website pages and help center content that changed are picked up without a manual step.
Request
PUT /v2/agents/{agentId}/auto-retrain
Path parameters:
| Name | Type | Required | Description |
|---|---|---|---|
agentId |
string | Yes | The ID of the agent, starting with agt_. |
Body fields:
| Name | Type | Required | Description |
|---|---|---|---|
enabled |
boolean | Yes | true to turn Auto-retrain on, false to turn it off. |
schedule |
string | No | daily or weekly. Defaults to weekly. Ignored when enabled is false. |
The call sets the state you send, so repeating it with the same body changes nothing. Auto-retrain applies to sources that can change on their own, such as website and help center sources. Text, file and Q&A sources keep their content until you update them. Read more about sources in Data sources.
Example request
curl -X PUT https://api.askocto.co/v2/agents/agt_8f3k2m/auto-retrain \
-H "Authorization: Bearer $OCTO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "enabled": true, "schedule": "weekly" }'
const response = await fetch("https://api.askocto.co/v2/agents/agt_8f3k2m/auto-retrain", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.OCTO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ enabled: true, schedule: "weekly" }),
})
const state = await response.json()
console.log(state.nextRunAt)
Example response
A successful call returns 200 OK.
{
"agentId": "agt_8f3k2m",
"enabled": true,
"schedule": "weekly",
"nextRunAt": "2026-03-28T03:00:00Z"
}
Response fields
| Name | Type | Description |
|---|---|---|
agentId |
string | The agent this setting belongs to. |
enabled |
boolean | Whether Auto-retrain is on. |
schedule |
string or null | daily or weekly. null when Auto-retrain is off. |
nextRunAt |
string or null | When the next retraining starts, as an ISO 8601 UTC time. null when Auto-retrain is off. |
Check the result of a run with List sources, where each source shows its status.
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request |
enabled is missing or not a boolean, or schedule has an unknown value. |
| 401 | unauthorized |
The API key is missing, malformed or deleted. |
| 404 | not_found |
No agent has this ID in your workspace. |
| 429 | rate_limited |
Too many requests. Wait for the number of seconds in the Retry-After header. |