Create retrieve
Grounds an answer in the caller's org files, table of contents first: candidate documents are found by searching their passages; a model reads their tables of contents — titles and one-line summaries — and picks the sections the answer is in; hybrid search drills into the passages of those sections; and the graph expands to the sections they link to or name the same entities as, in any file of the workspace.
POST /v1/knowledge/files/retrieve
| Address | https://api.hanzo.ai/v1/knowledge/files/retrieve |
| Method | POST |
| Operation | post_knowledge_files_retrieve |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Grounds an answer in the caller's org files, table of contents first: candidate documents are found by searching their passages; a model reads their tables of contents — titles and one-line summaries — and picks the sections the answer is in; hybrid search drills into the passages of those sections; and the graph expands to the sections they link to or name the same entities as, in any file of the workspace. Every passage cites its file › section › paragraph, so an answer can say exactly where it came from. This is what a chat runs before it answers about an attached file, and what an agent runs before it answers about a workspace.
Request
4 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
files | body | string[] | — | Files are the files the question is about — the files a chat message references. |
limit | body | integer (int64) | — | Limit bounds the passages drilled out of the chosen sections. |
project | body | string | — | Project restricts retrieval to files indexed under one project scope. |
query | body | string | — | Query is the question to answer. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | knowledge.retrieveOut | ok |
default | problem-details | refused |
200 body — 31 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
degraded | body | boolean | — | Degraded is true when a search leg failed along the way. |
passages | body | knowledge.citedPassage[] | — | Passages are the passages drilled out of those sections, then those the graph reached, each citing file › section › paragraph. |
passages[].cite | body | string | — | Cite is how an answer cites it: file › section path › ¶part. |
passages[].file | body | knowledge.fileBrief | — | |
passages[].file.bucket | body | string | — | Bucket and Key are where its bytes are: GET /v1/s3/buckets/{bucket}/objects/{key} answers a signed download URL. |
passages[].file.id | body | string | — | ID is the file's id. |
passages[].file.key | body | string | — | Key is the object's key in Bucket. |
passages[].file.name | body | string | — | Name is the file's name. |
passages[].file.type | body | string | — | Type is the file's media type. |
passages[].part | body | integer (int64) | — | Part is the passage's place in its section, from 1. |
passages[].score | body | number (double) | — | Score is the fused rank score, comparable within one response only. |
passages[].section | body | knowledge.sectionBrief | — | |
passages[].section.id | body | integer (int64) | — | ID is the section's number in its file's table of contents; 0 is the document itself. |
passages[].section.path | body | string | — | Path is the section's place in its document: the titles from the document's own down to it, joined by " › ". |
passages[].section.title | body | string | — | Title is the section's heading. |
passages[].text | body | string | — | Text is the passage: a span of its section of about 2000 bytes, never crossing into another section. |
passages[].via | body | string | — | Via is how retrieval reached it: search (it matched), toc (it is in a section the table of contents pointed at) or graph (a linked section). |
passages[].why | body | string | — | Why says, for a passage reached through the graph, which edge led there. |
picked | body | string | — | Picked says how the sections were chosen: whole when the documents were short enough to read every section, model when a model read the tables of contents, search when the sections of the best passages stood in — the documents had no headings to choose by, or no model answered. |
sections | body | knowledge.pickedSection[] | — | Sections are the sections chosen from the candidate documents' tables of contents. |
sections[].file | body | knowledge.fileBrief | — | |
sections[].file.bucket | body | string | — | Bucket and Key are where its bytes are: GET /v1/s3/buckets/{bucket}/objects/{key} answers a signed download URL. |
sections[].file.id | body | string | — | ID is the file's id. |
sections[].file.key | body | string | — | Key is the object's key in Bucket. |
sections[].file.name | body | string | — | Name is the file's name. |
sections[].file.type | body | string | — | Type is the file's media type. |
sections[].section | body | knowledge.sectionBrief | — | |
sections[].section.id | body | integer (int64) | — | ID is the section's number in its file's table of contents; 0 is the document itself. |
sections[].section.path | body | string | — | Path is the section's place in its document: the titles from the document's own down to it, joined by " › ". |
sections[].section.title | body | string | — | Title is the section's heading. |
sections[].summary | body | string | — | Summary is its one-line account. |
Failure carries the platform error shape — see Errors.
Examples
hanzo has no subcommand for this operation — the CLI serves only what cloud's live route table confirms. Use HTTP or an SDK.
import { Configuration, KnowledgeApi } from 'hanzoai';
const api = new KnowledgeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postKnowledgeFilesRetrieve({ files: ["<files>"], limit: 0 });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import KnowledgeApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = KnowledgeApi(client).post_knowledge_files_retrieve(files=["<files>"], limit=0)cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)
resp, _, err := client.KnowledgeAPI.PostKnowledgeFilesRetrieve(context.Background()).Execute()
if err != nil {
return err
}use hanzo_client::apis::{configuration::Configuration, knowledge_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = knowledge_api::post_knowledge_files_retrieve(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.KnowledgeApi;
ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));
var result = new KnowledgeApi(client).postKnowledgeFilesRetrieve();curl -X POST https://api.hanzo.ai/v1/knowledge/files/retrieve \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"files": [
"<files>"
],
"limit": 0
}'MCP reaches knowledge through the knowledge tool, which names its 9 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:
curl -X POST https://api.hanzo.ai/v1/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "describe",
"arguments": {
"op": "list_knowledge_connectors"
}
}
}'