Skip to main content

通过邮件发送 Smart Report

通过电子邮件投递附带 PDF 报告的 SmartReport。你可以让 Verifik 为单行(rowIndex)或全部行(sendAll: true,最多 50 行)渲染 PDF,也可以直接提供预渲染的 printHtml、pdfBase64 或 pdfFiles 负载。

发送邮件会在 SmartReport 文档上记录 emailDelivery,并在成功时触发 smart_batch_report_sent,投递失败时触发 smart_batch_report_delivery_failed。

端点​

POST https://api.verifik.co/v2/smart-reports/{id}/send-email

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

请求头​

名称值说明
Content-Typeapplication/json请求体负载格式(上限 64 MB)。
AuthorizationBearer <VERIFIK_JWT>客户作用域 JWT(authUser.clientId)。

参数​

名称类型必填说明
idstring是SmartReport ObjectId。

请求体参数​

名称类型必填说明
recipientsstring[]是有效收件人邮箱地址数组(至少 1 个)。
subjectstring否自定义邮件主题行。
languagestring否邮件文案语言:"en" 或 "es"。默认为 "es"。
rowIndexnumber否未启用 sendAll 时,要渲染并附加的从零开始的行索引。
sendAllboolean否为 true 时最多发送 50 行(MAX_SEND_ALL_ROWS);当批次超过 1 行时,每行各自生成一个 PDF 附件。
enginestring否PDF 渲染引擎:"pdfkit" 或 "puppeteer"。
printHtmlstring否预渲染 HTML 字符串(最长 64000000 个字符),将自动转换为 PDF 并作为附件发送。
pdfBase64string否预渲染的 base64 编码 PDF 字符串(最长 64000000 个字符),直接作为附件发送。
pdfFilesobject[]否最多包含 200 个附件对象的数组({ filename, pdfBase64 }),其中每个 filename(最长 80 个字符)与 pdfBase64(最长 64000000 个字符)均为必填。

附件与批量发送规则​

  • sendAll 上限:发送批次全部行最多支持 50 行(MAX_SEND_ALL_ROWS)。超过 50 行会返回 409 Conflict(send_all_limit)并失败。当批次超过 1 行时,每一行都会作为独立的 PDF 文件附加。
  • 预渲染负载:如果你的集成已经自行渲染好定制附件,可直接传入 pdfFiles(最多 200 项)、pdfBase64 或 printHtml。损坏的 PDF 数据会返回 500(invalid_pdf),解析后附件数为零的请求会返回 409 Conflict(no_pdf_attachments)。
  • 投递结果响应:如果参数校验和 PDF 准备均成功,但邮件传输失败,该端点仍会返回 HTTP 200 OK,其中包含 "success": false、"messageId": null 与 "error" 字段,同时记录 emailDelivery 并触发 smart_batch_report_delivery_failed。

请求示例​

import axios from "axios";

const run = async () => {
const id = "6801a2b3c4d5e6f7a8b9c0d1";
const { data } = await axios.post(
`https://api.verifik.co/v2/smart-reports/${id}/send-email`,
{
recipients: ["compliance@example.com"],
subject: "Background Verification Report - Applicant 42",
language: "en",
rowIndex: 0,
engine: "puppeteer",
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
}
);

console.log(data);
};

run();

响应示例​

{
"success": true,
"message": "Email sent successfully",
"recipients": ["compliance@example.com"],
"messageId": "<message-id@example.com>"
}

错误码说明​

状态码错误码 / 类型原因
401UnauthorizedJWT 缺失或无效。
403Forbidden尝试使用共享 x402 执行;请改用你自己的每客户 JWT。
404not_found报告 ID 不存在或属于其他客户。
404template_not_found无法找到关联的模板。
409MissingParameterJoi 校验失败(例如缺少或无效的 recipients)。
409send_all_limit对超过 50 行的批次请求了 sendAll: true(MAX_SEND_ALL_ROWS)。
409no_pdf_attachments无法为本次请求解析或渲染出任何 PDF 附件。
409row_not_found所请求的 rowIndex 在批次中不存在。
422UnprocessableEntityMongoose 校验错误。
500invalid_pdf所提供的 pdfBase64 或 pdfFiles 负载不是有效的 PDF。

Webhooks 与 MCP 集成​

  • Webhooks:投递成功时自动触发 smart_batch_report_sent,投递失败时触发 smart_batch_report_delivery_failed,并在 SmartReport 上记录 emailDelivery。详见 SmartReports Webhooks。
  • MCP 等效工具:AI 智能体可通过 smart_report_send_email MCP 工具发送报告邮件。详见 MCP 与 AI 智能体。

注意事项​

  • 请务必检查 200 OK 响应体中的 success 字段,因为邮件传输错误会返回 success: false、messageId: null 与 error,而不是非 200 状态码。
  • 如果希望在单次调用中同时执行核验步骤、生成 PDF 并发送邮件,请使用 运行 Smart Report。

相关页面​