# Get files

URL: https://docs.hanzo.ai/docs/openapi/exec/get-exec-files-by-sid

> Lists the files in an execution session.

`GET /v1/exec/files/{sid}`

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

|               |                                            |
| ------------- | ------------------------------------------ |
| **Address**   | `https://api.hanzo.ai/v1/exec/files/{sid}` |
| **Method**    | `GET`                                      |
| **Operation** | `get_exec_files_by_sid`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`     |

Lists the files in an execution session.

Everything the session's sandbox holds — the uploads a run can read and the
artifacts it produced — each then fetched from GET /v1/exec/download.

The answer is a BARE JSON ARRAY of {name, lastModified}, where `name` is the
same {session\_id}/{fileId} identifier download takes, because that is what the
client matches on. The obvious typed shape, `{files: […]}`, would have been a
silent wire change: the request still succeeds and `response.data.find(...)`
finds nothing, which reads as a session holding no files.

It lists with one recursive `find`, the same traversal the artifact sweep
makes, so a nested artifact a run reports in its reply is listed here too: one
traversal of the directory, one answer about what a session holds.

## Request

1 field.

| Field | In   | Type   | Required | Description                                                     |
| ----- | ---- | ------ | -------- | --------------------------------------------------------------- |
| `sid` | path | string | yes      | SID is the session identifier — the sandbox this listing is of. |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | exec.listing\[] | ok      |
| `default` | problem-details | refused |

`200` body — 2 fields.

| Field             | In   | Type   | Always | Description                                                                                                                                         |
| ----------------- | ---- | ------ | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `[].lastModified` | body | string | —      | LastModified is when the BYTES last changed, as RFC 3339 in UTC to the second — `2026-01-02T03:04:05Z`, the sandbox's own `date -u -r` on the file. |
| `[].name`         | body | string | —      | Name is the file's IDENTIFIER, `&#123;session_id&#125;/&#123;fileId&#125;` whole — never the bare filename, and never URL-escaped.                  |

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

## Examples

**CLI**

```bash
hanzo exec files get <sid>
```

**SDK**

**.ts**

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

const api = new ExecApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getExecFilesBySid({ sid: 'sid' });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import ExecApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = ExecApi(client).get_exec_files_by_sid(sid='sid')
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.ExecAPI.GetExecFilesBySid(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, exec_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = exec_api::get_exec_files_by_sid(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.ExecApi;

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

var result = new ExecApi(client).getExecFilesBySid();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/exec/files/<sid> \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **exec** through the `exec` tool, which names its 2 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
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_exec_file"
         }
       }
     }'
```

---

[Exec API](https://docs.hanzo.ai/docs/openapi/exec) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
