# List file

URL: https://docs.hanzo.ai/docs/openapi/code/get-code-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`

> [Code →](https://docs.hanzo.ai/docs/openapi/code) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/code/file`    |
| **Method**    | `GET`                                  |
| **Operation** | `get_code_file`                        |
| **Auth**      | `Authorization: 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.

| Field  | In    | Type   | Required | Description                                 |
| ------ | ----- | ------ | -------- | ------------------------------------------- |
| `path` | query | string | —        | Path is the file's repo-relative path.      |
| `repo` | query | string | —        | Repo is the repository the file belongs to. |

## Response

| Status    | Body             | Meaning |
| --------- | ---------------- | ------- |
| `200`     | code.fileContent | ok      |
| `default` | problem-details  | refused |

`200` body — 4 fields.

| Field     | In   | Type   | Always | Description                                        |
| --------- | ---- | ------ | ------ | -------------------------------------------------- |
| `content` | body | string | —      | Content is the file's text as the index stored it. |
| `lang`    | body | string | —      | Lang is the detected language.                     |
| `path`    | body | string | —      | Path echoes the file that was read.                |
| `repo`    | body | string | —      | Repo echoes the repository it came from.           |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo code file
```

**SDK**

**.ts**

```ts
import { Configuration, CodeApi } from 'hanzoai';

const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getCodeFile();
```

**.py**

```python
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()
```

**.go**

```go
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
}
```

**.rs**

```rust
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?;
```

**.java**

```java
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();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/code/file \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

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

```bash
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](https://docs.hanzo.ai/docs/openapi/code) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
