跳转到主要内容

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/files 上传一个文件到 Qoder Cloud Agents 平台,供会话或工具使用。

请求头

头部必选说明
AuthorizationBearer <PAT>
Content-Typemultipart/form-data

请求体(multipart/form-data)

字段类型必选说明
filefile要上传的文件二进制内容
purposestring文件用途。可选值:user_uploadtool_outputskill_outputsession_resourceagent_output。不传时默认为 user_upload
metadataJSON string自定义元数据,JSON 对象格式

示例请求

curl -X POST "https://openapi.qoder.sh/api/v1/cloud/files" \
  -H "Authorization: Bearer $QODER_PAT" \
  -F "file=@./my-document.txt" \
  -F "purpose=session_resource" \
  -F 'metadata={"project":"demo"}'

示例响应

HTTP 201 Created
{
  "created_at": "2026-05-18T15:33:44Z",
  "file_id": "file_019e3bb8c1387743bf4ef115aae5acb1",
  "filename": "my-document.txt",
  "metadata": {
    "project": "demo"
  },
  "mime_type": "text/plain",
  "purpose": "session_resource",
  "size_bytes": 110,
  "status": "ready",
  "updated_at": "2026-05-18T15:33:44Z"
}

响应字段

字段类型说明
file_idstring文件唯一标识,前缀 file_
filenamestring原始文件名
size_bytesinteger文件大小(字节)
mime_typestringMIME 类型,服务端自动检测
purposestring文件用途
statusstring文件状态,上传成功后为 ready
metadataobject自定义元数据
created_atstring创建时间(ISO 8601)
updated_atstring更新时间(ISO 8601)

错误码

HTTPtype触发条件
400invalid_request_error缺少 file 字段或 purpose 值无效
401authentication_error缺少或无效的认证令牌
错误响应示例:
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Field 'file' is required."
  }
}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Field 'purpose' must be one of: user_upload, tool_output, skill_output, session_resource, agent_output."
  }
}
完整错误信封说明详见 错误参考