> ## 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.

# 获取文件元数据

> 根据文件 ID 获取单个文件的元数据。

`GET /api/v1/cloud/files/{file_id}`

获取单个 [File 对象](/zh/cloud-agents/api/files/schemas#file-对象)。`deleted` 状态的文件不会通过该接口返回。

## 请求头

| 头部              | 必选 | 说明             |
| --------------- | -- | -------------- |
| `Authorization` | 是  | `Bearer <PAT>` |

## 路径参数

| 参数        | 类型     | 必选 | 说明                  |
| --------- | ------ | -- | ------------------- |
| `file_id` | string | 是  | File ID，前缀为 `file_` |

## 示例请求

```bash theme={null}
curl -X GET "https://api.qoder.com/api/v1/cloud/files/file_019e3bb8c1387743bf4ef115aae5acb1" \
  -H "Authorization: Bearer $QODER_PAT"
```

## 示例响应

**HTTP 200 OK**

```json theme={null}
{
  "id": "file_019e3bb8c1387743bf4ef115aae5acb1",
  "type": "file",
  "filename": "qoder-test-upload.txt",
  "mime_type": "text/plain",
  "size_bytes": 110,
  "downloadable": true,
  "scope": {
    "id": "sess_019e3bb8e6c47d18",
    "type": "session"
  },
  "metadata": {
    "project": "demo"
  },
  "created_at": "2026-05-18T15:33:44Z"
}
```

## 响应字段

| 字段             | 类型             | 说明                                                             |
| -------------- | -------------- | -------------------------------------------------------------- |
| `id`           | string         | File ID，前缀为 `file_`                                            |
| `type`         | string         | 固定为 `"file"`                                                   |
| `filename`     | string         | 存储后的文件名                                                        |
| `size_bytes`   | integer        | 文件大小，单位 byte                                                   |
| `mime_type`    | string         | 上传时提供或根据文件名检测出的 MIME type                                      |
| `downloadable` | boolean        | 是否可通过 `/content` 端点下载                                          |
| `scope`        | object \| null | 文件关联到其他资源时的 scope，例如 `{ "id": "sess_...", "type": "session" }` |
| `metadata`     | object         | 上传时传入的自定义元数据对象；省略时为 `{}`                                       |
| `created_at`   | string         | UTC 创建时间，RFC 3339 格式                                           |

## 错误码

| HTTP | type                   | 触发条件                            |
| ---- | ---------------------- | ------------------------------- |
| 401  | `authentication_error` | 缺少或无效的认证令牌                      |
| 404  | `not_found_error`      | 指定 ID 的文件不存在，或文件处于 `deleted` 状态 |

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

## 相关

<CardGroup cols={2}>
  <Card title="附加与下载文件" icon="paperclip" href="/zh/cloud-agents/files">
    上传文件为 Agent 提供上下文，并下载 Agent 产出的文件。
  </Card>
</CardGroup>
