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.
POST /v1/sessions/{session_id}/resources
为 Session 添加文件资源。添加后,Agent 在处理消息时可以访问这些文件。
此功能为 M3 门控特性,需要先通过 Files API 上传文件获取 file_id。
请求头
| 头部 | 必选 | 说明 |
|---|
Authorization | 是 | Bearer <PAT> |
Content-Type | 是 | application/json |
路径参数
| 参数 | 类型 | 必选 | 说明 |
|---|
session_id | string | 是 | Session ID(sess_ 前缀) |
请求体
| 字段 | 类型 | 必选 | 说明 |
|---|
resources | array | 是 | 资源对象数组 |
resources[].type | string | 是 | 固定值 "file" |
resources[].file_id | string | 是 | 文件 ID(通过 Files API 上传后获得) |
示例请求
curl -X POST "https://openapi.qoder.sh/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/resources" \
-H "Authorization: Bearer $QODER_PAT" \
-H "Content-Type: application/json" \
-d '{
"resources": [
{"type": "file", "file_id": "file_abc123def456"}
]
}'
示例响应
HTTP 200 OK
返回更新后的 Session 对象(含新的 resources 列表)。
错误码
| HTTP | type | 触发条件 |
|---|
| 400 | invalid_request_error | 请求格式错误(如 type 不为 "file" 或缺少 file_id) |
| 401 | authentication_error | PAT 无效或过期 |
| 404 | not_found_error | Session 或文件不存在 |
错误响应示例:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "resources[0]: field 'type' must be 'file'."
}
}
{
"type": "error",
"error": {
"type": "not_found_error",
"message": "File 'file_fake_test_id' was not found."
}
}
完整错误信封说明详见 错误参考。