Skip to main content

下载 Smart Report PDF

以二进制流形式下载 SmartReport 的已渲染 PDF 文件(Content-Type: application/pdf)。当你的后端、门户或集成需要原始 PDF 字节而非 生成 Smart Report PDF 返回的 base64 JSON 信封时,请使用此端点。

可选的 rowIndex 查询参数用于选择要渲染或下载关联 SmartBatch 中的哪一行。如果省略 rowIndex,端点会依次回退到 SmartReport 上的 dataSnapshot.rowIndex 以及默认值 0。

端点​

GET https://api.verifik.co/v2/smart-reports/{id}/download

使用你自己的每客户 Authorization: Bearer <VERIFIK_JWT>,也可通过 Smart-Agent 代理地址 https://ai.verifik.co/v2/smart-reports/{id}/download 访问此端点。共享 x402 执行会被拦截并返回 403 Forbidden。

请求头​

名称值说明
Acceptapplication/pdf二进制 PDF 响应流。
AuthorizationBearer <VERIFIK_JWT>客户作用域 JWT(authUser.clientId)。

参数​

名称位置类型必填说明
idpathstring是SmartReport ObjectId。
rowIndexquerynumber否要下载的从零开始的行索引。省略时依次回退至 dataSnapshot.rowIndex 和 0。

请求示例​

由于此端点返回的是原始二进制 PDF 字节而非 JSON,请将你的 HTTP 客户端配置为读取二进制缓冲区而不是解析 JSON。

import fs from "fs";
import axios from "axios";

const run = async () => {
const id = "6801a2b3c4d5e6f7a8b9c0d1";
const response = await axios.get(`https://api.verifik.co/v2/smart-reports/${id}/download`, {
params: { rowIndex: 0 },
responseType: "arraybuffer",
headers: {
Accept: "application/pdf",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
});

fs.writeFileSync("report.pdf", Buffer.from(response.data));
console.log(`Saved report.pdf (${response.data.byteLength} bytes)`);
};

run();

响应示例​

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="Consulta_1.pdf"
Content-Length: 148320

%PDF-1.4
... (binary PDF stream) ...

响应头(200 OK)​

响应头值 / 格式说明
Content-Typeapplication/pdf二进制 PDF MIME 类型。
Content-Dispositionattachment; filename="Consulta_<rowIndex+1>.pdf"使用从 1 开始的行号作为附件文件名(例如 rowIndex: 0 对应 Consulta_1.pdf)。
Content-Length整数字节长度流式返回的 PDF 精确字节大小。

错误码说明​

状态码错误码 / 类型原因
401UnauthorizedJWT 缺失或无效。
403Forbidden尝试使用共享 x402 执行;请改用你自己的每客户 JWT。
404not_found报告 ID 不存在或属于其他客户。
404template_not_found无法找到关联的模板。
409MissingParameter查询参数或路径参数未通过 Joi 校验。
409row_not_found解析得到的 rowIndex 在批次中不存在。
422UnprocessableEntityMongoose 校验错误。

Webhooks 与 MCP 集成​

相关页面​