(re)indexes a repository for the caller's org, incrementally: files whose…
(re)indexes a repository for the caller's org, incrementally: files whose content hash is unchanged are skipped, so re-sending a whole tree is cheap.
POST /v1/code/index
| Address | https://api.hanzo.ai/v1/code/index |
| Method | POST |
| Operation | post_code_index |
| Auth | Authorization: Bearer $HANZO_API_KEY |
(re)indexes a repository for the caller's org, incrementally: files whose
content hash is unchanged are skipped, so re-sending a whole tree is cheap.
Each file is parsed for symbols, split at AST boundaries and — when the
semantic tier is available — embedded, which is what makes it searchable across
all three retrieval tiers. Pass prune to also DELETE indexed files absent
from the request, which turns the call into a full sync; without it the call is
an upsert. The index is written to the caller org's own physically separate
database.
Request
5 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
files | body | fileInput[] | — | Files is the full set of files to index. Required and non-empty; max 20000 files, 1 MiB per file and 1 GiB in total. |
files[].content | body | string | — | Content is the file's full text. |
files[].path | body | string | — | Path is the file's repo-relative path, e.g. |
prune | body | boolean | — | Prune deletes indexed files that are NOT in this request — which makes the call a full sync of the repo rather than an upsert. |
repo | body | string | — | Repo is the repository label to index under. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | indexResult | ok |
200 body — 9 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
chunks | body | integer | — | Chunks is how many AST-boundary chunks the repo holds after this pass. |
files | body | integer | — | Files is how many files the repo holds after this pass. |
indexed | body | integer | — | Indexed is how many files were parsed and written on this pass. |
pruned | body | integer | — | Pruned is how many stored files were deleted because prune was set and they were absent from the request. |
repo | body | string | — | Repo is the repository that was indexed. |
semantic | body | boolean | — | Semantic reports whether the semantic tier was available for this pass. |
skipped | body | integer | — | Skipped is how many files were unchanged by content hash and left alone. |
symbols | body | integer | — | Symbols is how many symbol definitions the repo holds after this pass. |
vectors | body | integer | — | Vectors is how many of those chunks carry an embedding. |
Failure carries the platform error shape — see Errors.
Examples
hanzo code indeximport { Configuration, CodeApi } from 'hanzoai';
const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postCodeIndex({ files: [{"content":"<content>","path":"<path>"}], prune: false });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import CodeApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = CodeApi(client).post_code_index(files=[{"content":"<content>","path":"<path>"}], prune=False)cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.CodeAPI.PostCodeIndex(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, code_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = code_api::post_code_index(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CodeApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new CodeApi(client).postCodeIndex();curl -X POST https://api.hanzo.ai/v1/code/index \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"files": [
{
"content": "<content>",
"path": "<path>"
}
],
"prune": false
}'The door reaches code through the code tool, which names its 7 operations with its own verbs — this one among them, under a name only the door 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": "get_code_ask"
}
}
}'How is this guide?