Create source

POST/v2/agents/{agentId}/sources

Add a website, a block of text or a question and answer pair to an agent as a source and queue it for training.

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

Creates a source from a web address, pasted text or an approved question and answer pair. Training starts at once. Call it to import documentation from a script, to push text from your own systems, or to add an answer you want the agent to give word for word.

To upload a PDF, DOCX, TXT or CSV file, use Create file source.

Request

POST /v2/agents/{agentId}/sources

Path parameters:

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

Body fields:

Name Type Required Description
type string Yes website, text or qa.
url string For website A page or sitemap address that starts with https:// or http://.
title string For text The name of the source. Optional for website, where it defaults to the address.
content string For text The text the agent should learn.
question string For qa The question as a customer would ask it.
answer string For qa The answer you approve.

Send only the fields of the chosen type. Each type is explained in the Sources API overview.

Example request

curl -X POST https://api.askocto.co/v2/agents/agt_8f3k2m/sources \
  -H "Authorization: Bearer $OCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "website",
    "url": "https://example.com/help",
    "title": "Help center"
  }'
const response = await fetch("https://api.askocto.co/v2/agents/agt_8f3k2m/sources", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OCTO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    type: "website",
    url: "https://example.com/help",
    title: "Help center",
  }),
})

const source = await response.json()
console.log(source.id, source.status)

Example response

A successful call returns 201 Created. The source is queued and not yet used in answers.

{
  "id": "src_91xa7d",
  "type": "website",
  "title": "Help center",
  "status": "queued",
  "url": "https://example.com/help",
  "characters": 0,
  "failureReason": null,
  "createdAt": "2026-03-14T09:45:00Z"
}

Response fields

The response is a source object. Its fields are listed under Get source. characters is 0 until training reads the content. Poll Get source until status is ready or failed. A qa source also returns question and answer.

Errors

Status Code When
400 invalid_request type is missing or is file, a field the type needs is missing, or url is not a valid address.
401 unauthorized The API key is missing, malformed or deleted.
404 not_found No agent has this ID in your workspace.
409 conflict The agent already has a website source with this url.
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.