List file

Returns the INDEXED content of one file — read_file over the chunks the search tiers hold, for pulling up code an agent just found.

GET /v1/code/file

Addresshttps://api.hanzo.ai/v1/code/file
MethodGET
Operationget_code_file
AuthAuthorization: Bearer $HANZO_API_KEY

Returns the INDEXED content of one file — read_file over the chunks the search tiers hold, for pulling up code an agent just found. It is NOT byte-verbatim: the git object plane is the source of record for exact bytes, history and blame. A file absent from the index is a 404, so an agent can tell "not indexed" from "empty file".

Request

2 fields.

FieldInTypeRequiredDescription
pathquerystring—Path is the file's repo-relative path.
repoquerystring—Repo is the repository the file belongs to.

Response

StatusBodyMeaning
200code.fileContentok
defaultproblem-detailsrefused

200 body — 4 fields.

FieldInTypeAlwaysDescription
contentbodystring—Content is the file's text as the index stored it.
langbodystring—Lang is the detected language.
pathbodystring—Path echoes the file that was read.
repobodystring—Repo echoes the repository it came from.

Failure carries the platform error shape — see Errors.

Examples

hanzo code file
import { Configuration, CodeApi } from 'hanzoai';

const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getCodeFile();
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).get_code_file()
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.CodeAPI.GetCodeFile(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::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::get_code_file(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CodeApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new CodeApi(client).getCodeFile();
curl https://api.hanzo.ai/v1/code/file \
  -H "Authorization: Bearer $HANZO_API_KEY"

Tool code, op get_code_file — POST the JSON-RPC envelope to https://api.hanzo.ai/v1/mcp.

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "code",
         "arguments": {
           "op": "get_code_file",
           "input": {}
         }
       }
     }'

Code API · All Hanzo APIs · Interactive reference

Was this page useful?