# List sessions

URL: https://docs.hanzo.ai/docs/openapi/agent/get-agent-sessions

> Returns the caller org's live sessions, newest first — each with its event count, its direct-child count and a one-line preview of its latest event.

`GET /v1/agent/sessions`

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

|               |                                          |
| ------------- | ---------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/agent/sessions` |
| **Method**    | `GET`                                    |
| **Operation** | `get_agent_sessions`                     |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`   |

Returns the caller org's live sessions, newest first — each with
its event count, its direct-child count and a one-line preview of its latest
event. With no filter it returns ROOT sessions only, so a dashboard shows one
row per flow rather than one per subagent; ?root= or ?parent= descends.

## Request

8 fields.

| Field     | In    | Type    | Required | Description                                                                                                                                      |
| --------- | ----- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `root`    | query | string  | —        | Root scopes the page to one subagent tree (its root session id).                                                                                 |
| `parent`  | query | string  | —        | Parent scopes the page to the direct children of one session.                                                                                    |
| `status`  | query | string  | —        | Status filters to running, paused, done or error.                                                                                                |
| `project` | query | string  | —        | Project filters to the sessions tagged with one product slug.                                                                                    |
| `room`    | query | string  | —        | Room filters to the sessions started in one collaborative room — the query a space view runs to show what has been run in it.                    |
| `kind`    | query | string  | —        | Kind filters to the sessions of one kind of run: "coding" lists coding runs, each carrying its repo, base, branch, environment and pull request. |
| `limit`   | query | integer | —        | Limit caps the page.                                                                                                                             |
| `after`   | query | string  | —        | After is the `next` of the previous page.                                                                                                        |

## Response

| Status    | Body              | Meaning |
| --------- | ----------------- | ------- |
| `200`     | agent.sessionList | ok      |
| `default` | problem-details   | refused |

`200` body — 47 fields.

| Field                           | In   | Type                  | Always | Description                                                                                                                                                                                                               |
| ------------------------------- | ---- | --------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `next`                          | body | string                | —      | Next is the cursor for the page after this one; empty on the last page.                                                                                                                                                   |
| `sessions`                      | body | agent.sessionView\[]  | —      | Sessions is the matching sessions, each with its event and child counts and a one-line preview of its latest event.                                                                                                       |
| `sessions[].account`            | body | string                | —      | Account is which subscription or API account under that provider served it.                                                                                                                                               |
| `sessions[].actor`              | body | string                | —      | Actor is WHO this session belongs to, as "org/sub" — the same identity a run is billed under.                                                                                                                             |
| `sessions[].agent`              | body | string                | —      | Agent is the label the surface running this session calls itself by ("hanzo-dev"), up to 128 characters.                                                                                                                  |
| `sessions[].base`               | body | string                | —      | Base is the branch the run started from.                                                                                                                                                                                  |
| `sessions[].branch`             | body | string                | —      | Branch is the branch the run pushes its work to, and the only one it may write.                                                                                                                                           |
| `sessions[].children`           | body | integer (int64)       | —      | Children is the DIRECT fan-out — how many sessions name this one as parent — and not the size of the subtree.                                                                                                             |
| `sessions[].createdAt`          | body | string                | —      | CreatedAt is when the row was written, same format.                                                                                                                                                                       |
| `sessions[].cwd`                | body | string                | —      | Cwd is the directory the session is working in NOW, not the one it started in: a linked shell moves around, and a card showing where `hanzo link` was run answers "which work is this" with something that was true once. |
| `sessions[].endedAt`            | body | string                | —      | EndedAt is when it reached done or error, same format.                                                                                                                                                                    |
| `sessions[].environment`        | body | string                | —      | Environment is where the run executes: "sandbox" for a Hanzo sandbox, or the id of the org's machine it was routed to (the same id Target carries).                                                                       |
| `sessions[].events`             | body | integer (int64)       | —      | Events is how many turns the session's log holds, counted at read time.                                                                                                                                                   |
| `sessions[].host`               | body | string                | —      | Execution context (mission-control): the machine/repo/cwd a card shows and the run-target a session is dispatched to.                                                                                                     |
| `sessions[].id`                 | body | string                | —      | ID is the session's handle, minted here as "sess\_" + 32 hex characters.                                                                                                                                                  |
| `sessions[].kind`               | body | string                | —      | Kind is what sort of run this session is the view of — "coding" for a coding run.                                                                                                                                         |
| `sessions[].lastEvent`          | body | agent.lastEventView   | —      |                                                                                                                                                                                                                           |
| `sessions[].lastEvent.actor`    | body | string                | —      | Actor is who produced the turn, defaulted to the calling principal when the writer named nobody.                                                                                                                          |
| `sessions[].lastEvent.at`       | body | string                | —      | At is when the turn was recorded, RFC 3339 in UTC to the second.                                                                                                                                                          |
| `sessions[].lastEvent.kind`     | body | string                | —      | Kind is what the turn was, from the log's closed six: message, tool-call, spawn, log, status, control.                                                                                                                    |
| `sessions[].lastEvent.preview`  | body | string                | —      | Preview is the first 240 bytes of the event's payload, cut without regard for the JSON inside it — it is a string to SHOW, never a value to parse.                                                                        |
| `sessions[].lastEvent.seq`      | body | integer (int64)       | —      | Seq is that event's position in the session's log — monotonic from 1, per session.                                                                                                                                        |
| `sessions[].mode`               | body | string                | —      | Mode is what the run may do to its repository: "build" edits, commits and pushes its branch; "plan" reads and answers with a plan, writing nothing.                                                                       |
| `sessions[].org`                | body | string                | —      | Org is the caller's OWN tenant, echoed so a client can build the public build URL (/builds/:org/:project) without a second call or a guess.                                                                               |
| `sessions[].parentSessionId`    | body | string                | —      | ParentSessionID is the session that spawned this one, making this a subagent of it.                                                                                                                                       |
| `sessions[].pr`                 | body | string                | —      | PR is the address of the pull request the run proposed.                                                                                                                                                                   |
| `sessions[].progress`           | body | agent.sessionProgress | —      |                                                                                                                                                                                                                           |
| `sessions[].progress.activity`  | body | string                | —      | Activity is the one line saying what the run is doing right now ("running the reaper's tests"), up to 120 characters, in the model's words.                                                                               |
| `sessions[].progress.at`        | body | string                | —      | At is when this was determined, RFC 3339 in UTC to the second.                                                                                                                                                            |
| `sessions[].progress.estimated` | body | boolean               | —      | Estimated says a MODEL produced this, from the run's transcript, and it may be wrong.                                                                                                                                     |
| `sessions[].progress.pct`       | body | integer (int64)       | —      | Pct is how much of the run is done, 0 to 100.                                                                                                                                                                             |
| `sessions[].progress.phase`     | body | string                | —      | Phase is what shape the run is in: running, blocked, done, error, or unknown when nothing has estimated it yet.                                                                                                           |
| `sessions[].project`            | body | string                | —      | The readable build: the product this session built and whether its story is public (provenance.go).                                                                                                                       |
| `sessions[].provider`           | body | string                | —      | Provider is the linked AI account's provider (claude \| codex \| hanzo \| …) that served this run.                                                                                                                        |
| `sessions[].published`          | body | boolean               | —      | Published is the author's decision to let anyone read this session's story at the public build route.                                                                                                                     |
| `sessions[].repo`               | body | string                | —      | Repo is the code the session is working on, as the surface reported it.                                                                                                                                                   |
| `sessions[].room`               | body | string                | —      | Room is the collaborative room this run was started in (HIP-0523), empty when it came from anywhere else — a CLI, a schedule, an API call.                                                                                |
| `sessions[].rootSessionId`      | body | string                | —      | RootSessionID is the top of this session's tree, inherited from the parent and shared by every node in one flow.                                                                                                          |
| `sessions[].sandbox`            | body | string                | —      | Sandbox is the id of the sandbox the run works in ("m\_" and 24 hex), the handle its terminal and its screen are opened with (/v1/sandbox/{id}/terminal, /screen).                                                        |
| `sessions[].startedAt`          | body | string                | —      | StartedAt is when the session opened, RFC 3339 in UTC to the second.                                                                                                                                                      |
| `sessions[].status`             | body | string                | —      | Status is one of exactly four: running, paused, done, error.                                                                                                                                                              |
| `sessions[].target`             | body | string                | —      | Target is the registered run-target this session is dispatched to — a machine the org claimed, resolved same-org when it was set, so it can never point at another tenant's computer.                                     |
| `sessions[].taskRunId`          | body | string                | —      | TaskRunID is that workflow's particular run.                                                                                                                                                                              |
| `sessions[].taskWorkflowId`     | body | string                | —      | TaskWorkflowID is the hanzoai/tasks durable workflow that actually EXECUTES this session — this registry is the view, control and stream layer over it.                                                                   |
| `sessions[].terminal`           | body | string                | —      | Terminal is where this session can be WATCHED — the URL the machine published for its live terminal.                                                                                                                      |
| `sessions[].title`              | body | string                | —      | Title is the human line a card shows ("ship the landing page"), up to 512 characters.                                                                                                                                     |
| `sessions[].updatedAt`          | body | string                | —      | UpdatedAt is the session's last-activity clock, same format.                                                                                                                                                              |

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

## Examples

**CLI**

```bash
hanzo agent sessions list
```

**SDK**

**.ts**

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

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

**.py**

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

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AgentApi(client).get_agent_sessions()
```

**.go**

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

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

**.rs**

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

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

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

**.java**

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

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

var result = new AgentApi(client).getAgentSessions();
```

**HTTP**

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

**MCP**

MCP reaches **agent** through the `agent` tool, which names its 38 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": "list_agents"
         }
       }
     }'
```

---

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