列出文件

更新时间:
复制为 MD 格式

获取当前账户下的文件列表,支持分页和按用途过滤。

请求头

头部

必选

说明

Authorization

Bearer

查询参数

参数

类型

必选

说明

purpose

string

按文件用途过滤。可选值:user_uploadtool_outputskill_outputsession_resourceagent_output

limit

integer

每页返回的最大文件数量

after

string

游标分页:返回此 file_id 之后的文件(向后翻页)

before

string

游标分页:返回此 file_id 之前的文件(向前翻页)

完整分页规范详见 分页

示例请求

# 基本列表
curl -X GET "https://api.qoder.com.cn/api/v1/cloud/files" \
  -H "Authorization: Bearer $QODER_PAT"

# 按用途过滤 + 限制数量
curl -X GET "https://api.qoder.com.cn/api/v1/cloud/files?purpose=session_resource&limit=10" \
  -H "Authorization: Bearer $QODER_PAT"

# 游标分页
curl -X GET "https://api.qoder.com.cn/api/v1/cloud/files?limit=10&after=file_019e3bb8e6c47d18" \
  -H "Authorization: Bearer $QODER_PAT"

示例响应

HTTP 200 OK

{
  "data": [
    {
      "created_at": "2026-05-18T15:33:53Z",
      "file_id": "file_019e3bb8e6c47d189212a79642136696",
      "filename": "report.txt",
      "metadata": {
        "project": "test"
      },
      "mime_type": "text/plain",
      "purpose": "session_resource",
      "size_bytes": 110,
      "status": "ready",
      "updated_at": "2026-05-18T15:33:54Z"
    }
  ],
  "first_id": "file_019e3bb8e6c47d189212a79642136696",
  "has_more": false,
  "last_id": "file_019e3bb8e6c47d189212a79642136696"
}

响应字段

字段

类型

说明

data

array

文件对象数组

first_id

string \

null

last_id

string \

null

has_more

boolean

是否还有更多数据

data 中每个文件对象的字段与上传文件响应一致。

空列表响应:

{
  "data": [],
  "first_id": null,
  "has_more": false,
  "last_id": null
}

分页说明

列表按创建时间降序排列(最新的在前)。使用游标分页遍历所有文件:

  1. 首次请求设置 limit 获取第一页

  2. 如果 has_moretrue,使用 after= 获取下一页

  3. 使用 before= 可向前翻页

错误码

HTTP

type

触发条件

401

authentication_error

缺少或无效的认证令牌

完整错误信封说明详见 错误参考