> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 列出 Sessions

> 使用游标分页列出 Sessions。

`GET /api/v1/cloud/sessions`

列出当前账号下的 Sessions。默认不包含已归档 Session。

## 请求头

| 头部              | 必选 | 说明                  |
| --------------- | -- | ------------------- |
| `Authorization` | 是  | `Bearer $QODER_PAT` |

## 查询参数

| 参数                 | 类型             | 必填 | 说明                                                                                                        |
| ------------------ | -------------- | -- | --------------------------------------------------------------------------------------------------------- |
| `limit`            | integer        | 否  | 最大返回数量。默认 20，范围 1-100。超过 100 返回 `400 invalid_request_error`                                               |
| `page`             | string         | 否  | 上一次响应 `next_page` 返回的不透明游标                                                                                |
| `order`            | string         | 否  | 排序方向：`desc`（默认）或 `asc`                                                                                    |
| `include_archived` | boolean        | 否  | 是否包含已归档 Sessions                                                                                          |
| `statuses`         | string 或 array | 否  | 按 Session 生命周期状态过滤。允许值：`running`、`idle`、`rescheduling`、`terminated`。归档 Session 通过 `include_archived` 单独过滤 |
| `agent_id`         | string         | 否  | 按 Agent ID 过滤                                                                                             |
| `agent_version`    | integer        | 否  | 按 Agent 版本过滤                                                                                              |
| `deployment_id`    | string         | 否  | 按 Deployment ID 过滤                                                                                        |
| `memory_store_id`  | string         | 否  | 筛选挂载了指定 Memory Store 的 Sessions                                                                           |
| `created_at[gt]`   | string         | 否  | 返回创建时间晚于该 RFC 3339 时间的 Sessions                                                                           |
| `created_at[gte]`  | string         | 否  | 返回创建时间不早于该 RFC 3339 时间的 Sessions                                                                          |
| `created_at[lt]`   | string         | 否  | 返回创建时间早于该 RFC 3339 时间的 Sessions                                                                           |
| `created_at[lte]`  | string         | 否  | 返回创建时间不晚于该 RFC 3339 时间的 Sessions                                                                          |

## 示例请求

```bash theme={null}
curl -X GET "https://api.qoder.com/api/v1/cloud/sessions?limit=3&include_archived=true" \
  -H "Authorization: Bearer $QODER_PAT"
```

## 示例响应

**HTTP 200 OK**

```json theme={null}
{
  "data": [
    {
      "id": "sess_019e3bb1e8c171fd9abbb1477ffb84cc",
      "type": "session",
      "agent": {
        "id": "agent_019e390add9f7bac9b6cc806db46fcbd",
        "type": "agent",
        "version": 2,
        "name": "doc-verification-agent",
        "description": "",
        "model": {"id": "ultimate", "effective_context_window": 200000},
        "system": "You are an expert software engineer.",
        "tools": [{"enabled_tools": ["Bash", "Read", "Write", "Edit", "Glob", "Grep"], "type": "agent_toolset_20260401"}],
        "skills": [],
        "mcp_servers": []
      },
      "environment_id": "env_019e2590d33f711fabf42f2857cecd8a",
      "title": "API-doc-verification-session",
      "status": "idle",
      "metadata": {},
      "resources": [],
      "vault_ids": [],
      "deployment_id": null,
      "outcome_evaluations": [],
      "stats": {"active_seconds": 0, "duration_seconds": 0},
      "environment_variables": {},
      "archived_at": null,
      "created_at": "2026-05-18T15:26:15.747298Z",
      "updated_at": "2026-05-18T15:26:15.747298Z"
    }
  ],
  "first_id": "sess_019e3bb1e8c171fd9abbb1477ffb84cc",
  "has_more": false,
  "last_id": "sess_019e3bb1e8c171fd9abbb1477ffb84cc",
  "next_page": null
}
```

## 响应字段

| 字段          | 类型             | 说明                                                                |
| ----------- | -------------- | ----------------------------------------------------------------- |
| `data`      | array          | [Session 对象](/zh/cloud-agents/api/sessions/schemas#session-对象) 数组 |
| `has_more`  | boolean        | 当前结果集之后还有更多页时为 `true`                                             |
| `first_id`  | string         | 当前页第一个 Session 的 ID                                               |
| `last_id`   | string         | 当前页最后一个 Session 的 ID                                              |
| `next_page` | string \| null | 下一页的不透明游标，无更多结果时为 `null`                                          |

## 错误码

| HTTP | 类型                      | 触发条件      |
| ---- | ----------------------- | --------- |
| 400  | `invalid_request_error` | 分页或过滤参数无效 |
| 401  | `authentication_error`  | PAT 无效或过期 |

**HTTP 400 Bad Request**

```json theme={null}
{
  "type": "error",
  "request_id": "cb80235f-76a2-4ff3-9e28-5aa2da12dc14",
  "error": {
    "type": "invalid_request_error",
    "message": "Field 'limit' must be a positive integer."
  }
}
```

完整错误信封格式见 [错误参考](/zh/cloud-agents/api/conventions/errors)。

## 相关

<CardGroup cols={2}>
  <Card title="启动 Session" icon="play" href="/zh/cloud-agents/sessions">
    让 Agent 在环境中以有状态对话的方式运行。
  </Card>
</CardGroup>
