Skip to main content

Generate template layout

Generate, append, or edit structured ReportSection definitions from a natural-language prompt using Gemini (temperature 0.2). Pass sample verification data in previewData so the model aligns section dataPath bindings and column layouts with your actual payload structure.

In headless report builders and AI agent pipelines, use this endpoint to scaffold complete layouts ("create"), add follow-up sections onto an existing template ("append"), or refine a single section ("edit") without writing section JSON by hand. Pair this call with Preview template HTML to inspect the rendered output before persisting with Create a report template or Update a report template.

Endpoint​

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

The Smart-Agent proxy (https://ai.verifik.co) exposes the same /v2/... paths and requires your own Authorization: Bearer <VERIFIK_JWT> header.

Headers​

NameValue
Content-Typeapplication/json
Acceptapplication/json
AuthorizationBearer <VERIFIK_JWT>

Body​

NameTypeRequiredDescription
promptstringYesNatural-language instructions describing the layout to create, the sections to append, or the changes to apply in edit mode.
modestringYesGeneration mode: "create", "edit", or "append".
previewDataobjectNoSample verification JSON (for example inputData, results, batchName) used to ground generated dataPath expressions and columns.
currentSectionsobject[]NoExisting ReportSection array. Recommended in "append" mode so newly generated sections continue the existing order sequence.
selectedSectionobject / nullNoTarget ReportSection object to modify when mode is "edit". If null or omitted in "edit" mode, behavior falls back to "create".

Request​

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

async function run() {
const res = await fetch(
"https://api.verifik.co/v2/smart-report-templates/generate-layout",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
body: JSON.stringify({
prompt:
"Create a clean 2-column driver summary section followed by a table of traffic citations.",
mode: "create",
previewData: {
batchName: "Driver Onboarding",
rowIndex: 0,
inputData: {
documentType: "CC",
documentNumber: "1020304050",
},
results: {
identity: { fullName: "Mateo Rojas", status: "active" },
fines: [{ code: "C02", amount: 580000, status: "pending" }],
},
},
}),
}
);

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

run();

Response​

{
"data": [
{
"id": "sec-driver-summary",
"type": "keyValueGrid",
"order": 0,
"label": "Driver Summary",
"dataPath": "results.identity",
"columnsPerRow": 2
},
{
"id": "sec-traffic-fines",
"type": "dataTable",
"order": 1,
"label": "Traffic Citations",
"dataPath": "results.fines",
"columns": [
{ "key": "code", "label": "Code" },
{ "key": "amount", "label": "Amount" },
{ "key": "status", "label": "Status" }
]
}
]
}

Notes​

  • "create" and "append" modes return { "data": [ ...ReportSection ] } (an array), while "edit" mode with a non-null selectedSection returns { "data": { ...ReportSection } } (a single object).
  • Calling "edit" with selectedSection: null or omitting selectedSection falls back to "create" mode and returns an array.
  • This endpoint does not write to the database. Pass the returned sections into Preview template HTML to inspect the HTML or into Create a report template to save it.