Train agent (deprecated)

POST/v2/agents/{agentId}/train

Deprecated endpoint that queues all sources of an agent for training. Use source endpoints and Auto-retrain instead.

Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.

Warning: This endpoint is deprecated. Sources train when you create or update them with Create source and Update source. For scheduled retraining, use Toggle auto retrain. New code should not call this endpoint.

Queues every source of an agent for training in one call. Existing scripts keep working, but the replacements above give you control per source and a schedule instead of a manual trigger.

Request

POST /v2/agents/{agentId}/train

Path parameters:

Name Type Required Description
agentId string Yes The ID of the agent, starting with agt_.

The call has no query parameters and no body. Each source moves to the status queued, then training, then ready or failed. Read the status of each source with List sources.

Example request

curl -X POST https://api.askocto.co/v2/agents/agt_8f3k2m/train \
  -H "Authorization: Bearer $OCTO_API_KEY"
const response = await fetch("https://api.askocto.co/v2/agents/agt_8f3k2m/train", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.OCTO_API_KEY}` },
})

const result = await response.json()
console.log(`${result.sourcesQueued} sources queued`)

Example response

A successful call returns 202 Accepted. Training continues in the background.

{
  "agentId": "agt_8f3k2m",
  "sourcesQueued": 4,
  "startedAt": "2026-03-21T09:15:00Z"
}

Response fields

Name Type Description
agentId string The agent whose sources were queued.
sourcesQueued integer How many sources were put in the queue.
startedAt string When the request was accepted, as an ISO 8601 UTC time.

Errors

Status Code When
401 unauthorized The API key is missing, malformed or deleted.
404 not_found No agent has this ID in your workspace.
409 conflict The sources of this agent are already being trained.
429 rate_limited Too many requests. Wait for the number of seconds in the Retry-After header.

Something unclear or missing? Tell us and we will fix the page.