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

Addresshttps://api.hanzo.ai/v1/knowledge/files/retrieve
MethodPOST
Operationpost_knowledge_files_retrieve
AuthAuthorization: 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).

FieldInTypeRequiredDescription
filesbodystring[]—Files are the files the question is about — the files a chat message references.
limitbodyinteger (int64)—Limit bounds the passages drilled out of the chosen sections.
projectbodystring—Project restricts retrieval to files indexed under one project scope.
querybodystring—Query is the question to answer.

Response

StatusBodyMeaning
200knowledge.retrieveOutok
defaultproblem-detailsrefused

200 body — 31 fields.

FieldInTypeAlwaysDescription
degradedbodyboolean—Degraded is true when a search leg failed along the way.
passagesbodyknowledge.citedPassage[]—Passages are the passages drilled out of those sections, then those the graph reached, each citing file › section › paragraph.
passages[].citebodystring—Cite is how an answer cites it: file › section path › ¶part.
passages[].filebodyknowledge.fileBrief—
passages[].file.bucketbodystring—Bucket and Key are where its bytes are: GET /v1/s3/buckets/{bucket}/objects/{key} answers a signed download URL.
passages[].file.idbodystring—ID is the file's id.
passages[].file.keybodystring—Key is the object's key in Bucket.
passages[].file.namebodystring—Name is the file's name.
passages[].file.typebodystring—Type is the file's media type.
passages[].partbodyinteger (int64)—Part is the passage's place in its section, from 1.
passages[].scorebodynumber (double)—Score is the fused rank score, comparable within one response only.
passages[].sectionbodyknowledge.sectionBrief—
passages[].section.idbodyinteger (int64)—ID is the section's number in its file's table of contents; 0 is the document itself.
passages[].section.pathbodystring—Path is the section's place in its document: the titles from the document's own down to it, joined by " › ".
passages[].section.titlebodystring—Title is the section's heading.
passages[].textbodystring—Text is the passage: a span of its section of about 2000 bytes, never crossing into another section.
passages[].viabodystring—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[].whybodystring—Why says, for a passage reached through the graph, which edge led there.
pickedbodystring—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.
sectionsbodyknowledge.pickedSection[]—Sections are the sections chosen from the candidate documents' tables of contents.
sections[].filebodyknowledge.fileBrief—
sections[].file.bucketbodystring—Bucket and Key are where its bytes are: GET /v1/s3/buckets/{bucket}/objects/{key} answers a signed download URL.
sections[].file.idbodystring—ID is the file's id.
sections[].file.keybodystring—Key is the object's key in Bucket.
sections[].file.namebodystring—Name is the file's name.
sections[].file.typebodystring—Type is the file's media type.
sections[].sectionbodyknowledge.sectionBrief—
sections[].section.idbodyinteger (int64)—ID is the section's number in its file's table of contents; 0 is the document itself.
sections[].section.pathbodystring—Path is the section's place in its document: the titles from the document's own down to it, joined by " › ".
sections[].section.titlebodystring—Title is the section's heading.
sections[].summarybodystring—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"
         }
       }
     }'

Knowledge API · All Hanzo APIs · Interactive reference

Was this page useful?