템플릿 레이아웃 생성
Gemini(temperature 0.2)를 사용하여 자연어 prompt로부터 구조화된 ReportSection 정의를 생성, 추가 또는 편집합니다. 모델이 섹션의 dataPath 바인딩과 열 레이아웃을 실제 페이로드 구조에 맞출 수 있도록 previewData에 샘플 검증 데이터를 전달하세요.
헤드리스 리포트 빌더 및 AI 에이전트 파이프라인에서는 섹션 JSON을 수동으로 작성하지 않고도 전체 레이아웃을 스캐폴딩하거나("create"), 기존 템플릿에 후속 섹션을 추가하거나("append"), 단일 섹션을 다듬을 때("edit") 이 엔드포인트를 사용하세요. 리포트 템플릿 생성 또는 리포트 템플릿 수정으로 저장하기 전에 템플릿 HTML 미리보기와 함께 호출하여 렌더링된 출력을 확인할 수 있습니다.
엔드포인트
POST https://api.verifik.co/v2/smart-report-templates/generate-layout
Smart-Agent 프록시(https://ai.verifik.co)도 동일한 /v2/... 경로를 제공하며 본인의 Authorization: Bearer <VERIFIK_JWT> 헤더가 필요합니다.
헤더
| 이름 | 값 |
|---|---|
| Content-Type | application/json |
| Accept | application/json |
| Authorization | Bearer <VERIFIK_JWT> |
요청 본문
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
prompt | string | 예 | 생성할 레이아웃, 추가할 섹션 또는 edit 모드에서 적용할 변경 사항을 설명하는 자연어 지침. |
mode | string | 예 | 생성 모드: "create", "edit" 또는 "append". |
previewData | object | 아니요 | 생성된 dataPath 표현식과 열을 실제 데이터에 맞추기 위한 샘플 검증 JSON(예: inputData, results, batchName). |
currentSections | object[] | 아니요 | 기존 ReportSection 배열. 새로 생성된 섹션이 기존 order 시퀀스를 이어갈 수 있도록 "append" 모드에서 권장됩니다. |
selectedSection | object / null | 아니요 | mode가 "edit"일 때 수정할 대상 ReportSection 객체. "edit" 모드에서 null이거나 생략되면 "create" 모드로 폴백합니다. |
요청
- Node.js
- PHP
- Python
- Go
- cURL
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();
<?php
$payload = [
"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"],
],
],
],
];
$ch = curl_init("https://api.verifik.co/v2/smart-report-templates/generate-layout");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Accept: application/json",
"Authorization: Bearer " . getenv("VERIFIK_JWT"),
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);
import os
import requests
url = "https://api.verifik.co/v2/smart-report-templates/generate-layout"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
payload = {
"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"}],
},
},
}
r = requests.post(url, json=payload, headers=headers)
print(r.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]interface{}{
"prompt": "Create a clean 2-column driver summary section followed by a table of traffic citations.",
"mode": "create",
"previewData": map[string]interface{}{
"batchName": "Driver Onboarding",
"rowIndex": 0,
"inputData": map[string]interface{}{
"documentType": "CC",
"documentNumber": "1020304050",
},
"results": map[string]interface{}{
"identity": map[string]interface{}{"fullName": "Mateo Rojas", "status": "active"},
"fines": []map[string]interface{}{
{"code": "C02", "amount": 580000, "status": "pending"},
},
},
},
})
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/smart-report-templates/generate-layout", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFIK_JWT"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var out map[string]interface{}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out)
}
curl -X POST "https://api.verifik.co/v2/smart-report-templates/generate-layout" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT" \
-d '{
"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" }]
}
}
}'
응답
- 200 (create / append)
- 200 (edit)
- 401
- 409
- 500
{
"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" }
]
}
]
}
{
"data": {
"id": "sec-driver-summary",
"type": "keyValueGrid",
"order": 0,
"label": "Driver Identity Summary",
"dataPath": "results.identity",
"columnsPerRow": 3
}
}
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "\"prompt\" is required",
"code": "MissingParameter"
}
{
"message": "Failed to generate valid report layout from AI response",
"code": "InternalServerError"
}
참고 사항
"create"및"append"모드는{ "data": [ ...ReportSection ] }(배열)을 반환하는 반면,null이 아닌selectedSection이 있는"edit"모드는{ "data": { ...ReportSection } }(단일 객체)를 반환합니다.selectedSection: null로"edit"를 호출하거나selectedSection을 생략하면"create"모드로 폴백하여 배열을 반환합니다.- 이 엔드포인트는 데이터베이스에 쓰지 않습니다. 반환된
sections를 템플릿 HTML 미리보기에 전달하여 HTML을 확인하거나 리포트 템플릿 생성에 전달하여 저장하세요.