Add Knowledge Document

Knowledge

Add Knowledge Document

Adds a web page (url) or pasted text to what the agent knows. A page is fetched and indexed before this answers, so a slow site is a slow request; passages says how much was indexed. A page that cannot be read is answered 422 with the reason and the failed document it left behind, which you can delete. Files are uploaded in the console. A build key may do this.

POST/agents/{id}/knowledge

Path parameters

idstringrequired
The agent's id (ag_…).

Headers

Katexs-Workspacestring
Developers only: the customer workspace this request acts in — its org_… id from POST /customers. Leave it out to act in your own workspace. Refused with 404 (Workspace not found.) when the id is unknown, is not one of your customers, or is not an org_… id; 410 when that customer was deleted (restore it with POST /customers/{id}/restore until it is erased); 403 when the key belongs to one customer workspace (it cannot act as another); 400 when your workspace is not a developer workspace. /customers/* and GET /customers/usage are your own workspace's and refuse the header with 400: call them without it.

Request body

urlstring (uri)
A web page to fetch and index. Must start with http:// or https://.
textstring
Text to index, up to 200,000 characters. Trimmed.
titlestring
A title for text; cut to 200 characters. Left out, it is Pasted text. Ignored with url, whose title comes from the page.

Example request

bash
curl -X POST "https://app.katexs.com/api/v1/agents/{id}/knowledge" \
  -H "Authorization: Bearer $KATEXS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Sky Towers price list",
  "text": "A 2 BHK at Sky Towers starts at 82 lakh. A 3 BHK starts at 1.1 crore. Possession is December 2027."
}'

Responses

StatusDescription
201The document, indexed and ready to cite.
400Neither or both of url and text, text too long, or url not http(s).
401The key is missing, wrong or revoked. The answer is always the same, whichever it is.
403The key's access level (read-only or build) does not allow this request, the plan does not include it, or a customer's key named another workspace in Katexs-Workspace. code says which: key_scope_read, key_scope_build, workspace_header_forbidden, or forbidden.
404No such agent in your workspace.
410The customer named in Katexs-Workspace was deleted. POST /customers/{id}/restore brings it back until its erase date.
422The page or text could not be indexed. document is the failed document left on the agent, when one was written — delete it or fix the page and add it again.
429Over a per-minute limit. Wait for Retry-After seconds. code and limit say which limit: rate_limit_resources (240 requests a minute for the workspace), rate_limit_family (2,400 across a developer's customers), rate_limit_calls, rate_limit_messages, rate_limit_codes, rate_limit_code_recipient, concurrent_calls or number_daily_limit.

Response fields

idstringrequired
The document's id.
titlestringrequired
Its title: the one you sent, the page's own, or Pasted text.
typestringrequired
Where it came from. One of: url, text.
sourcestringrequired
The address for a url, pasted for text.
statusstringrequired
Always ready on success. One of: ready.
errornullrequired
Always null on success.
createdAtstring (date-time)required
When it was added.
passagesintegerrequired
How many passages were indexed. Range: 1–.
201 response
{
  "id": "doc_f7413c2a-9d0e-4b6f-8a21-3e5c7d9b1f04",
  "title": "Sky Towers price list",
  "type": "text",
  "source": "pasted",
  "status": "ready",
  "error": null,
  "createdAt": "2026-10-06T09:41:58.307Z",
  "passages": 3
}

Last updated November 2026 · Found a problem? Email support@katexs.com