Search knowledge

Runs a hybrid search over the caller org's own knowledge — its wiki pages, its agent memories and everything its connectors have synced.

POST /v1/knowledge/search

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

Runs a hybrid search over the caller org's own knowledge — its wiki pages, its agent memories and everything its connectors have synced. This is the RAG entry point: an agent asks "what does this org know about X" and the org's OWN knowledge answers. Two legs run and are fused by reciprocal rank: a semantic leg that embeds the query and compares it with every passage of every document in reach (a document is cut into passages of about 2000 bytes, so a fact deep in a long page is found), and a keyword leg over the org's knowledge index. The org comes from the validated principal and its passages live in its own database, so cross-tenant retrieval is impossible. A failed leg answers 200 with what the other leg found and degraded=true, never a 5xx.

Request

4 fields, body application/json (required).

FieldInTypeRequiredDescription
doctypesbodystring[]—DocTypes restricts retrieval to a subset of the indexed knowledge doctypes (kb.page, kb.memory, kb.source).
limitbodyinteger (int64)—Limit bounds the hits returned.
projectbodystring—Project narrows retrieval to one project scope.
querybodystring—Query is the natural-language question.

Response

StatusBodyMeaning
200knowledge.searchOutok
defaultproblem-detailsrefused

200 body — 9 fields.

FieldInTypeAlwaysDescription
degradedbodyboolean—Degraded is true when a leg FAILED — the query could not be embedded, or a store could not be read — and Hits are what the other leg found, possibly nothing.
hitsbodyknowledge.hit[]—Hits are the matching documents, most relevant first: the order is the two legs fused, so a document both the semantic and the keyword leg found comes before one only a single leg found.
hits[].doctypebodystring—DocType is which kind of knowledge matched, by address: kb.page (a wiki page), kb.memory (a unit of agent memory) or kb.source (a document a connector ingested).
hits[].namebodystring—Name is the document's name in the framework store — the id to read or open it with.
hits[].projectbodystring—Project is the project scope the document was saved under.
hits[].providerbodystring—Provider is the connector that ingested the document — github, slack, google or notion.
hits[].scorebodynumber (double)—Score is the cosine similarity between the query's embedding and the document's BEST-matching passage, from -1 to 1, higher being closer.
hits[].titlebodystring—Title is the document's title.
hits[].urlbodystring—URL is the document's link back into the app it was ingested from.

Failure carries the platform error shape — see Errors.

Examples

hanzo knowledge search
import { Configuration, KnowledgeApi } from 'hanzoai';

const api = new KnowledgeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postKnowledgeSearch({ doctypes: ["<doctypes>"], 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_search(doctypes=["<doctypes>"], limit=0)
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.KnowledgeAPI.PostKnowledgeSearch(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_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).postKnowledgeSearch();
curl -X POST https://api.hanzo.ai/v1/knowledge/search \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "doctypes": [
         "<doctypes>"
       ],
       "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?