Search files

Answers the passages of the caller's org files that match a query, each citing its file › section › paragraph: the search behind Drive's box, and the first step an agent takes across a workspace.

POST /v1/knowledge/files/search

Addresshttps://api.hanzo.ai/v1/knowledge/files/search
MethodPOST
Operationpost_knowledge_files_search
AuthAuthorization: Bearer $HANZO_API_KEY

Answers the passages of the caller's org files that match a query, each citing its file › section › paragraph: the search behind Drive's box, and the first step an agent takes across a workspace. Name file ids to search only those files; name none to search them all. A semantic leg compares the query with every embedded passage and a full-text leg finds the passages holding its words; the two are fused, so a passage both found comes first.

Request

4 fields, body application/json (required).

FieldInTypeRequiredDescription
filesbodystring[]—Files restricts the search to these file ids.
limitbodyinteger (int64)—Limit bounds the passages returned.
projectbodystring—Project restricts the search to files indexed under one project scope.
querybodystring—Query is the question or phrase.

Response

StatusBodyMeaning
200knowledge.fileSearchOutok
defaultproblem-detailsrefused

200 body — 18 fields.

FieldInTypeAlwaysDescription
degradedbodyboolean—Degraded is true when a leg failed — the query could not be embedded, or the full-text index could not be read — and Passages are what the other leg found.
passagesbodyknowledge.citedPassage[]—Passages are the matching passages, best first, at most Limit.
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.

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.postKnowledgeFilesSearch({ 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_search(files=["<files>"], limit=0)
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.KnowledgeAPI.PostKnowledgeFilesSearch(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_search(&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).postKnowledgeFilesSearch();
curl -X POST https://api.hanzo.ai/v1/knowledge/files/search \
  -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?