Skip to main content

创建报告模板

创建一个归属于已认证客户的自定义 Smart Report 模板。仅 name 为必填项;所有品牌视觉、布局 sections、reportTheme、sampleData 以及 PDF 引擎选项均为可选,后续也可随时通过 更新报告模板 修改。

在无头与 AI 驱动流水线中,可使用此端点持久化由 生成模板布局 产出的布局、克隆并品牌化来自 列出主题起步模板 的内置起步模板,或通过代码为 SmartBatch 流水线预置特定环境的 PDF 模板。保存模板会触发异步缩略图生成,并返回 HTTP 200(而非 201),新建的文档位于 { "data": ... } 中。

端点​

POST https://api.verifik.co/v2/smart-report-templates

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

请求头​

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

请求体参数​

名称类型必填说明
namestring是模板显示名称。最多 150 个字符。
descriptionstring否模板的可读描述。最多 500 个字符。
batchConfigurationstring否关联 SmartBatch 配置的 ObjectId。
countrystring否国家标识符或标签。最多 60 个字符。
categorystring否核验领域:"citizen"、"company" 或 "vehicle"。
isActiveboolean否模板是否启用。默认为 true。
logostring否品牌 Logo URL 或 base64 Data URI。
primaryColorstring否主品牌强调色十六进制颜色。默认为 "#4F46E5"。
identityColorstring否次要/身份识别强调色十六进制颜色。默认为 "#000000"。
pageBackgroundColorstring否页面背景十六进制颜色。默认为 "#ffffff"。
headerobject否自定义页眉布局与内容配置。
footerobject否自定义页脚布局与内容配置。
legendstring否页脚说明文字或合规声明文本。最多 2000 个字符。
legendPositionstring否说明文字对齐方式:"left"、"center" 或 "right"。
termsAndConditionsstring否法律条款与条件文本。最多 4000 个字符。
termsPositionstring否条款对齐方式:"left"、"center" 或 "right"。
sectionsobject[]否定义内容区块与数据绑定的有序 ReportSection 对象数组(参见 ReportSection 属性)。
pageSizestring否PDF 纸张尺寸:"A4"、"Letter" 或 "Legal"。默认为 "A4"。
layoutVersioninteger否布局渲染器版本:1 或 2。
orientationstring否页面方向:"portrait" 或 "landscape"。默认为 "portrait"。
marginsobject否页边距对象 `{ "top": 40, "right": 40, "bottom": 40, "left": 40 }`。四边均默认为 40。
pdfEnginestring否PDF 渲染引擎:"puppeteer" 或 "pdfkit"。默认为 "puppeteer"。
showPageNumbersboolean否在渲染后的 PDF 上显示页码。
pageNumberPositionstring否页码位置:"top-left"、"top-center"、"top-right"、"bottom-left"、"bottom-center" 或 "bottom-right"。
pageNumberDividerboolean / string否页码分隔符配置。
watermarkobject否水印叠加设置。
securityobject否PDF 加密设置 `{ "enabled": true, "password": "..." }`。
signatureobject否签名区块配置。
logoSettingsobject否Logo 尺寸与摆放配置。
sheetImagesobject[]否嵌入的模板图片资源。最多 12 项。
customFontsobject[]否自定义字体声明(Google Fonts、外部 URL 或上传文件)。最多 6 项。
headerLogosobject[]否显示在页眉中的附加 Logo。最多 16 项。
bodyTopPaddingnumber否应用于文档正文的顶部内边距,范围 0 到 600。
sampleDataobject否示例核验负载(inputData、results、batchName、rowIndex),用作预览和示例下载的默认兜底数据集。
endpointDesignobject否特定于端点的展示元数据。
reportThemestring / object否主题预设 ID("premium_dark"、"light_cards"、"editorial"、"dashboard")或完整的主题配置对象(参见 主题配置)。

ReportSection 属性​

sections 中的每个元素描述报告中的一个区块。常见属性包括 id、type、order、dataPath、label、staticContent、columns、columnsPerRow、keyOverrides、valueRules、chartKind、style、condition 与 frame。

支持的 type 取值包括:

  • 核心布局:header、text、table、field、image、divider、spacer、shape
  • 结构化区块:dataTable、card、badge、keyValueGrid、repeater、reportBlocks、themeBlock
  • 主题化核验区块:coverPage、scoreGauge、categoryBreakdown、checkTable、findings、sources、sourceCards

主题配置​

reportTheme 既可接受预设字符串("premium_dark"、"light_cards"、"editorial"、"dashboard"),也可接受包含以下字段的对象:

{ id, scoreScale, scoreEnabled, scoreProfile, locale, density, eyebrow, coverTitle, headlines, legalNote, showVerifiedBadge, showWeights, showDeductions, showFields, showHowItWorks, blocks, tokens }

当迁移已在 预览模板 HTML 测试过的负载时,请在保存前将顶层预览辅助字段(scoreScale、themeTokens、scoreSettings)移入 reportTheme(reportTheme.scoreScale、reportTheme.tokens、reportTheme.scoreEnabled 与 reportTheme.scoreProfile)。

请求示例​

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

async function run() {
const res = await fetch("https://api.verifik.co/v2/smart-report-templates", {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
body: JSON.stringify({
name: "Colombia Driver Onboarding Report",
description: "Themed driver verification report for fleet onboarding",
country: "CO",
category: "citizen",
isActive: true,
pageSize: "A4",
layoutVersion: 2,
orientation: "portrait",
margins: { top: 40, right: 40, bottom: 40, left: 40 },
pdfEngine: "puppeteer",
primaryColor: "#4F46E5",
identityColor: "#111827",
pageBackgroundColor: "#ffffff",
showPageNumbers: true,
pageNumberPosition: "bottom-right",
reportTheme: {
id: "light_cards",
scoreEnabled: true,
scoreProfile: "cabify_driver",
scoreScale: "percent",
locale: "en",
showVerifiedBadge: true,
},
sections: [
{
id: "sec-header",
type: "header",
order: 0,
label: "Driver Verification Report",
},
{
id: "sec-score",
type: "scoreGauge",
order: 1,
label: "Verification Score",
},
{
id: "sec-subject",
type: "keyValueGrid",
order: 2,
label: "Subject Details",
dataPath: "inputData",
columnsPerRow: 2,
},
],
}),
});

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

run();

响应示例​

{
"data": {
"_id": "67c1f94b2d8a1c0012a4b301",
"client": "507f1f77bcf86cd799439013",
"name": "Colombia Driver Onboarding Report",
"description": "Themed driver verification report for fleet onboarding",
"country": "CO",
"category": "citizen",
"isActive": true,
"pageSize": "A4",
"layoutVersion": 2,
"orientation": "portrait",
"margins": {
"top": 40,
"right": 40,
"bottom": 40,
"left": 40
},
"pdfEngine": "puppeteer",
"primaryColor": "#4F46E5",
"identityColor": "#111827",
"pageBackgroundColor": "#ffffff",
"showPageNumbers": true,
"pageNumberPosition": "bottom-right",
"reportTheme": {
"id": "light_cards",
"scoreEnabled": true,
"scoreProfile": "cabify_driver",
"scoreScale": "percent",
"locale": "en",
"showVerifiedBadge": true
},
"sections": [
{
"id": "sec-header",
"type": "header",
"order": 0,
"label": "Driver Verification Report"
},
{
"id": "sec-score",
"type": "scoreGauge",
"order": 1,
"label": "Verification Score"
},
{
"id": "sec-subject",
"type": "keyValueGrid",
"order": 2,
"label": "Subject Details",
"dataPath": "inputData",
"columnsPerRow": 2
}
],
"createdAt": "2026-09-10T03:32:00.000Z",
"updatedAt": "2026-09-10T03:32:00.000Z"
}
}

注意事项​

  • 创建成功返回 HTTP 200(而非 201),并在后台触发异步缩略图生成。
  • 供 预览模板 HTML 使用的顶层预览辅助字段(scoreScale、themeTokens、scoreSettings)不会作为顶层模板字段存储。在持久化模板时,请将它们放入 reportTheme(scoreScale、tokens、scoreEnabled/scoreProfile)中。
  • 请保存返回的 _id,以便渲染示例 PDF、向相关方发送预览,或将该模板绑定至自动化的 SmartBatch 任务。

相关页面​