Skip to main content

发送模板示例

使用 sampleData 渲染已保存的 Smart Report 模板({id}),并将生成的 PDF 直接通过电子邮件发送给一个或多个 recipients。你也可以选择提供 printHtml 以跳过 HTML 生成步骤,或提供 pdfBase64 以直接附加预渲染的 PDF 缓冲区。

在无头 CI/CD 流水线、模板审批工作流与 AI 智能体自动化中,无需自行搭建邮件基础设施即可使用此端点将格式化后的报告预览分发给合规审阅人员或产品相关方。最高支持 64MB 的 JSON 请求体,足以容纳嵌入字体、Logo、预渲染 HTML 或 base64 PDF。

端点​

POST https://api.verifik.co/v2/smart-report-templates/{id}/send-sample

Smart-Agent 代理(https://ai.verifik.co)暴露了完全相同的 /v2/... 路径,并同样要求携带你自己的 Authorization: Bearer <VERIFIK_JWT> 请求头。

请求头​

名称值
Content-Typeapplication/json
Acceptapplication/json
AuthorizationBearer <VERIFIK_JWT>

参数​

名称类型必填说明
idstring是Smart Report 模板 ObjectId。

请求体参数​

支持最大 64MB 的 JSON 负载。

名称类型必填说明
recipientsstring[]是有效收件人邮箱地址数组(至少 1 个)。
sampleDataobject是示例负载,包含 inputData、results、batchName 和 rowIndex。
subjectstring否自定义邮件主题行。默认使用模板的 name,格式为 `Sample Report: <name>`。
languagestring否邮件文案语言:"en" 或 "es"。默认为 "es"。
printHtmlstring否可选的预渲染 HTML 文档,直接转换为 PDF,而非从模板 sections 渲染。
pdfBase64string否可选的 base64 编码 PDF 附件,无需服务端生成 PDF 即可直接发送。

请求示例​

const fetch = require("node-fetch");

async function run() {
const id = "67c1f94b2d8a1c0012a4b301";
const res = await fetch(
`https://api.verifik.co/v2/smart-report-templates/${id}/send-sample`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
body: JSON.stringify({
recipients: ["compliance@acme.example"],
subject: "Sample Report: Colombia Driver Onboarding",
language: "en",
sampleData: {
batchName: "Driver Onboarding Sample",
rowIndex: 0,
inputData: {
documentType: "CC",
documentNumber: "1020304050",
},
results: {
identity: {
fullName: "Mateo Rojas",
status: "active",
},
},
},
}),
}
);

console.log(await res.json());
}

run();

响应示例​

{
"success": true,
"message": "Sample email sent successfully",
"recipients": ["compliance@acme.example"],
"messageId": "<a1b2c3d4-5678-90ef-1234-567890abcdef@verifik.co>",
"delivery": {
"sentAt": "2026-09-10T04:15:22.000Z",
"recipients": ["compliance@acme.example"],
"subject": "Sample Report: Colombia Driver Onboarding",
"status": "sent",
"messageId": "<a1b2c3d4-5678-90ef-1234-567890abcdef@verifik.co>",
"errorMessage": null
}
}

注意事项​

  • 与其他将负载包装在 { "data": ... } 中的模板端点不同,send-sample 直接在顶层返回 success、message、recipients、messageId 和 delivery 字段。
  • 若省略 language,邮件默认使用 "es"。如需发送英文相关方通知,请传入 "en"。
  • 如需在本地保存渲染后的 PDF 而非通过邮件发送,请使用 下载模板示例。

相关页面​