# List sessions

> A repository's sessions, most recently heard from first, up to 100: state active (heard from in the last 15 minutes), idle or ended; issue or pull for those on one, attached or tied to it any other way; path for those that touched a file (or any under a folder ending in /).

<div class="g1t-endpoint"><span class="g1t-method" data-method="get">GET</span><code>/repos/{owner}/{name}/sessions</code></div>

Subagents are left out unless `subagents` is true, which lists each tree whole. Each says how many `subagents` it started. Anyone who can read the repository may.

- **Authentication:** Optional. Public data can be read without a token; send one to see what is private.
- **MCP tool:** [`session`](/reference/mcp/#session) with `action` `list`, and the same inputs
- **Scope:** An access token needs [`pull_requests:read`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | string | Yes | The workspace that owns the repository. |
| `name` | string | Yes | The repository's name. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `state` | string | No | Only sessions in this state. One of `active`, `idle`, `ended`. |
| `issue` | integer | No | Only sessions on this issue: attached, or tied to it any other way. |
| `pull` | integer | No | Only sessions on this pull request: attached, or tied to it any other way. |
| `path` | string | No | Only sessions that touched this file, or any under it when it ends in `/`. |
| `subagents` | boolean | No | List subagents too, each tree whole. Left out, only the sessions at the top. |

## Example request

```sh
curl "https://api.g1t.sh/repos/flagon-io/hello/sessions?state=active&issue=12" \
  -H "Authorization: Bearer $G1T_TOKEN"
```

## Example response

A successful request answers `200` with:

```json
[
  {
    "id": "ses_01m4b2c3d4e5f6g7h8j9k0m1n2",
    "repo_id": "rep_01m3m5q6p0e2qaw6mmjahk0qrr",
    "issue": 12,
    "pull": 14,
    "branch": "greet-caller",
    "actor": {
      "id": "usr_01kkntcg1eeb98j62xjm7eh09p",
      "username": "syntaqx"
    },
    "harness": "claude_code",
    "harness_session_id": "5b0c1f9e-3d2a-4e8b-9f61-0c7d2a9e4b13",
    "title": "Make the greeting name the caller",
    "state": "active",
    "head_commit": "9f2c4e1a7b3d5f60812a4c6e8b0d2f4a6c8e0b13",
    "started_at": "2026-10-12T14:02:11.204Z",
    "last_seen_at": "2026-10-12T14:31:40.518Z",
    "ended_at": null,
    "end_reason": null
  }
]
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#errors).

| Status | Code | When |
| --- | --- | --- |
| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
| 403 | `forbidden` | The token is valid but not allowed to do this, such as a member-only change, or a token without the scope it needs. |
| 404 | `not_found` | It does not exist, or you cannot see it. |
| 422 | `invalid` | The input is not valid. `message` says which field and why. |
