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

# 获取输出文件

> 获取 Batch 输出文件的签名下载链接。

`GET /api/v1/forward/batches/{batch_id}/output`

返回 `output.jsonl` 的 OSS 预签名下载链接。Batch 必须处于终态，否则返回 `400 batch_not_ready`。

## 请求头

| Header        | 是否必填 | 说明             |
| ------------- | ---- | -------------- |
| Authorization | 是    | `Bearer <PAT>` |

## 路径参数

| 参数        | 类型     | 是否必填 | 说明        |
| --------- | ------ | ---- | --------- |
| batch\_id | string | 是    | Batch ID。 |

## 示例请求

```bash theme={null}
curl -s -X GET 'https://api.qoder.com/api/v1/forward/batches/batch_completed001/output' \
  -H "Authorization: Bearer $QODER_PAT"
```

## 示例响应

**HTTP 200 OK**

```json theme={null}
{
  "url": "https://cloud-agents-storage.oss-cn-beijing.aliyuncs.com/files%2F<user_id>%2F<file_id>%2Fcontent?Expires=1783685162&OSSAccessKeyId=<ak>&Signature=<sig>&response-content-disposition=attachment%3B%20filename%3Dbatch-batch_completed001-output.jsonl",
  "expires_at": "2026-07-10T12:06:02Z"
}
```

## 响应字段

| 字段          | 类型     | 说明                                                                                                                                |
| ----------- | ------ | --------------------------------------------------------------------------------------------------------------------------------- |
| url         | string | OSS 预签名下载链接，含 `Expires` / `OSSAccessKeyId` / `Signature` 及 `response-content-disposition`，下载文件名为 `batch-<batch_id>-output.jsonl`。 |
| expires\_at | string | 链接过期时间，RFC 3339，需在此之前完成下载。                                                                                                        |

## 错误码

| HTTP | Type                    | Code                      | 触发条件                            |
| ---- | ----------------------- | ------------------------- | ------------------------------- |
| 400  | `invalid_request_error` | `batch_not_ready`         | Batch 未处于终态。                    |
| 404  | `not_found_error`       | `batch_not_found`         | Batch 不存在、跨用户访问、或 output 文件未生成。 |
| 410  | `not_found_error`       | `file_expired`            | 输出文件超过 30 天保留期已被清理。             |
| 401  | `authentication_error`  | `authentication_required` | PAT 无效或已过期。                     |

## 注意事项

* 输出文件保留期为 30 天，超期后返回 `410 file_expired`。
* 下载文件名为 `batch-<batch_id>-output.jsonl`。
* 失败行结果在 `error.jsonl` 中，通过 Batch 详情的 `error_file_id` 获取。

## 相关

<CardGroup cols={2}>
  <Card title="查询 Batch 详情" icon="file-text" href="/zh/cloud-agents/api/forward/batches/get" />

  <Card title="列出 Batches" icon="list" href="/zh/cloud-agents/api/forward/batches/list" />
</CardGroup>
