Smart Report PDF 생성
기존 SmartReport에 대해 "puppeteer" 또는 "pdfkit"을 사용하여 PDF를 렌더링하고, 선택적으로 verificationScore를 계산하며, downloadUrl 및 htmlUrl과 함께 base64로 인코딩된 PDF 버퍼를 수신합니다.
성공 시 이 엔드포인트는 리포트를 status: "generated"로 표시하고, 점수 계산이 활성화된 경우 verificationScoreSummary를 저장하며, smart_batch_report_generated 웹훅을 발송합니다. PDF 생성이 실패하면 리포트는 status: "failed"로 표시되고 smart_batch_report_generation_failed 웹훅이 발송됩니다.
엔드포인트
POST https://api.verifik.co/v2/smart-reports/{id}/generate
이 엔드포인트는 사용자 지정 printHtml 문서를 수용하기 위해 최대 64 MB의 JSON 페이로드를 허용합니다. 또한 본인의 클라이언트별 Authorization: Bearer <VERIFIK_JWT>를 사용하여 Smart-Agent 프록시(https://ai.verifik.co/v2/smart-reports/{id}/generate)를 통해서도 호출할 수 있습니다. 공유 x402 실행은 403 Forbidden으로 차단됩니다.
헤더
| 이름 | 값 | 설명 |
|---|---|---|
Content-Type | application/json | 요청 페이로드 형식(64 MB 제한). |
Authorization | Bearer <VERIFIK_JWT> | 클라이언트 범위 JWT (authUser.clientId). |
매개변수
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
id | string | 예 | SmartReport ObjectId. |
요청 본문
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
engine | string | 아니요 | PDF 렌더링 엔진: "pdfkit" 또는 "puppeteer". |
rowIndex | number | 아니요 | 연결된 SmartBatch에서 0부터 시작하는 행 인덱스. 기본값은 행 0입니다. |
printHtml | string | 아니요 | <html을 포함하는 비테마 템플릿에 사용되는 전체 HTML 문자열(최대 64000000자). |
score | boolean | 아니요 | verificationScore 계산 및 리포트에 verificationScoreSummary 저장 여부. |
scoreProfile | string | 아니요 | score 활성화 시 사용되는 점수 프로필 식별자. 최대 64자. |
렌더링 및 점수 계산 동작
- 기본 행 선택:
rowIndex를 생략하면 기본값으로 행0이 생성됩니다. 범위를 벗어난 행을 요청하면409 Conflict(row_not_found)가 반환됩니다. - 사용자 지정 HTML (
printHtml): 전체<html마크업을 제공하는 비테마 템플릿으로 작업할 때는printHtml(최대64000000자)을 전달하세요. - 검증 점수 계산:
score: true(및 선택적으로scoreProfile)를 설정하면verificationScore를 계산해 응답 최상위 레벨에 반환하고SmartReport에verificationScoreSummary를 저장합니다. 알 수 없는 프로필은409 Conflict(unknown_score_profile)로 실패합니다.
요청
- Node.js
- PHP
- Python
- Go
- cURL
import axios from "axios";
const run = async () => {
const id = "6801a2b3c4d5e6f7a8b9c0d1";
const { data } = await axios.post(
`https://api.verifik.co/v2/smart-reports/${id}/generate`,
{
engine: "puppeteer",
rowIndex: 0,
score: true,
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
}
);
console.log({
status: data.data.status,
pdfSize: data.pdf.size,
downloadUrl: data.pdf.downloadUrl,
});
};
run();
<?php
$id = "6801a2b3c4d5e6f7a8b9c0d1";
$ch = curl_init("https://api.verifik.co/v2/smart-reports/" . $id . "/generate");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . getenv("VERIFIK_JWT"),
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"engine" => "puppeteer",
"rowIndex" => 0,
"score" => true,
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import os
import requests
report_id = "6801a2b3c4d5e6f7a8b9c0d1"
url = f"https://api.verifik.co/v2/smart-reports/{report_id}/generate"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
payload = {
"engine": "puppeteer",
"rowIndex": 0,
"score": True,
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
id := "6801a2b3c4d5e6f7a8b9c0d1"
body, _ := json.Marshal(map[string]interface{}{
"engine": "puppeteer",
"rowIndex": 0,
"score": true,
})
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/smart-reports/"+id+"/generate", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFIK_JWT"))
resp, _ := http.DefaultClient.Do(req)
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-reports/6801a2b3c4d5e6f7a8b9c0d1/generate" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT" \
-d '{
"engine": "puppeteer",
"rowIndex": 0,
"score": true
}'
응답
- 200 OK
- 401
- 403
- 404
- 409
- 422
- 500
{
"data": {
"_id": "6801a2b3c4d5e6f7a8b9c0d1",
"template": "6801a2b3c4d5e6f7a8b9c0d2",
"smartBatch": "6801a2b3c4d5e6f7a8b9c0d3",
"name": "Background Check - Applicant 42",
"status": "generated",
"pdfEngine": "puppeteer",
"pdfSize": 148320,
"generationDurationMs": 1840,
"generatedAt": "2026-11-24T20:00:04.000Z",
"verificationScoreSummary": {},
"rowIndex": 0,
"externalRefId": "applicant-42"
},
"pdf": {
"buffer": "JVBERi0xLjQK...",
"size": 148320,
"engine": "puppeteer",
"generationDurationMs": 1840,
"downloadUrl": "/v2/smart-reports/6801a2b3c4d5e6f7a8b9c0d1/download",
"htmlUrl": "/v2/smart-reports/6801a2b3c4d5e6f7a8b9c0d1/html"
},
"verificationScore": {}
}
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "Shared x402 execution is forbidden on this endpoint",
"code": "Forbidden"
}
{
"message": "template_not_found",
"code": "NotFound"
}
{
"message": "row_not_found",
"code": "row_not_found"
}
{
"message": "UnprocessableEntity",
"code": "UnprocessableEntity"
}
{
"message": "InternalServerError",
"code": "InternalServerError"
}
오류 코드
| 상태 | 오류 코드 / 유형 | 원인 |
|---|---|---|
401 | Unauthorized | JWT가 누락되었거나 유효하지 않음. |
403 | Forbidden | 공유 x402 실행이 시도됨. 본인의 클라이언트별 JWT를 사용하세요. |
404 | not_found | 리포트 ID가 존재하지 않거나 다른 클라이언트에 속함. |
404 | template_not_found | 연결된 템플릿을 찾을 수 없음. |
404 | batch_not_found | 연결된 SmartBatch를 찾을 수 없음. |
409 | MissingParameter | 하나 이상의 필드에서 Joi 검증 실패. |
409 | row_not_found | 요청한 rowIndex가 배치에 존재하지 않음. |
409 | unknown_score_profile | 요청한 scoreProfile이 인식되지 않음. |
422 | UnprocessableEntity | Mongoose 유효성 검사 오류. |
500 | InternalServerError | PDF 렌더링 또는 내부 처리 실패(리포트를 "failed"로 표시하고 smart_batch_report_generation_failed 발송). |
웹훅 및 MCP 연동
- 웹훅: PDF 생성에 성공하면
smart_batch_report_generated를 발송하고, 렌더링 오류가 발생하면status를"failed"로 업데이트한 뒤smart_batch_report_generation_failed를 발송합니다. SmartReports 웹훅을 참조하세요. - MCP 대응 도구: AI 에이전트는
smart_report_generate_pdfMCP 도구를 통해 리포트 PDF를 직접 렌더링할 수 있습니다. MCP 및 AI 에이전트를 참조하세요.
참고 사항
pdf.buffer에는 JSON 응답 안에 base64로 인코딩된 PDF 바이트가 직접 포함됩니다. 바이너리 PDF 스트림을 원하면 Smart Report PDF 다운로드를 호출하세요.score가 활성화된 경우 응답에verificationScore가 포함됩니다.