이메일로 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-Type | application/json | 요청 페이로드 형식(64 MB 제한). |
Authorization | Bearer <VERIFIK_JWT> | 클라이언트 범위 JWT (authUser.clientId). |
매개변수
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
id | string | 예 | SmartReport ObjectId. |
요청 본문
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
recipients | string[] | 예 | 유효한 수신자 이메일 주소 배열(최소 1개). |
subject | string | 아니요 | 사용자 지정 이메일 제목. |
language | string | 아니요 | 이메일 본문 언어: "en" 또는 "es". 기본값 "es". |
rowIndex | number | 아니요 | sendAll이 활성화되지 않은 경우 렌더링하여 첨부할 0부터 시작하는 행 인덱스. |
sendAll | boolean | 아니요 | true일 때 최대 50행(MAX_SEND_ALL_ROWS)을 전송하며, 배치에 2개 이상의 행이 있으면 행마다 1개의 PDF를 첨부합니다. |
engine | string | 아니요 | PDF 렌더링 엔진: "pdfkit" 또는 "puppeteer". |
printHtml | string | 아니요 | 변환하여 첨부할 사전 렌더링된 HTML 문자열(최대 64000000자). |
pdfBase64 | string | 아니요 | 직접 첨부할 사전 렌더링된 base64 인코딩 PDF 문자열(최대 64000000자). |
pdfFiles | object[] | 아니요 | 최대 200개의 첨부 파일 객체({ filename, pdfBase64 }) 배열. 각 filename(최대 80자)과 pdfBase64(최대 64000000자)는 필수입니다. |
첨부 파일 및 일괄 전달 규칙
sendAll상한: 배치의 모든 행을 전송하는 기능은 최대50행(MAX_SEND_ALL_ROWS)까지 지원합니다. 50행을 초과하면409 Conflict(send_all_limit)로 실패합니다. 배치에 2개 이상의 행이 있으면 각 행이 별도의 PDF 파일로 첨부됩니다.- 사전 렌더링된 페이로드: 연동 시스템에서 이미 사용자 지정 첨부 파일을 렌더링한 경우
pdfFiles(최대200개),pdfBase64또는printHtml을 제공하세요. 손상된 PDF 데이터는500(invalid_pdf)을 반환하며, 첨부 파일이 0개로 해석되는 요청은409 Conflict(no_pdf_attachments)를 반환합니다. - 전송 결과 응답: 유효성 검사 및 PDF 준비가 성공한 후 이메일 전송 단계에서 실패하면, 이 엔드포인트는
"success": false,"messageId": null및"error"필드와 함께 HTTP200 OK를 반환하며 동시에emailDelivery를 기록하고smart_batch_report_delivery_failed를 발송합니다.
요청
- 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}/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();
<?php
$id = "6801a2b3c4d5e6f7a8b9c0d1";
$ch = curl_init("https://api.verifik.co/v2/smart-reports/" . $id . "/send-email");
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([
"recipients" => ["compliance@example.com"],
"subject" => "Background Verification Report - Applicant 42",
"language" => "en",
"rowIndex" => 0,
"engine" => "puppeteer",
]));
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}/send-email"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
payload = {
"recipients": ["compliance@example.com"],
"subject": "Background Verification Report - Applicant 42",
"language": "en",
"rowIndex": 0,
"engine": "puppeteer",
}
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{}{
"recipients": []string{"compliance@example.com"},
"subject": "Background Verification Report - Applicant 42",
"language": "en",
"rowIndex": 0,
"engine": "puppeteer",
})
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/smart-reports/"+id+"/send-email", 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/send-email" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT" \
-d '{
"recipients": ["compliance@example.com"],
"subject": "Background Verification Report - Applicant 42",
"language": "en",
"rowIndex": 0,
"engine": "puppeteer"
}'
응답
- 200 OK (전송됨)
- 200 OK (전송 실패)
- 401
- 403
- 404
- 409
- 422
- 500
{
"success": true,
"message": "Email sent successfully",
"recipients": ["compliance@example.com"],
"messageId": "<message-id@example.com>"
}
{
"success": false,
"message": "Failed to send email",
"recipients": ["compliance@example.com"],
"messageId": null,
"error": "SMTP transport rejected recipient"
}
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "Shared x402 execution is forbidden on this endpoint",
"code": "Forbidden"
}
{
"message": "not_found",
"code": "NotFound"
}
{
"message": "send_all_limit",
"code": "send_all_limit"
}
{
"message": "UnprocessableEntity",
"code": "UnprocessableEntity"
}
{
"message": "invalid_pdf",
"code": "invalid_pdf"
}
오류 코드
| 상태 | 오류 코드 / 유형 | 원인 |
|---|---|---|
401 | Unauthorized | JWT가 누락되었거나 유효하지 않음. |
403 | Forbidden | 공유 x402 실행이 시도됨. 본인의 클라이언트별 JWT를 사용하세요. |
404 | not_found | 리포트 ID가 존재하지 않거나 다른 클라이언트에 속함. |
404 | template_not_found | 연결된 템플릿을 찾을 수 없음. |
409 | MissingParameter | Joi 검증 실패(예: recipients 누락 또는 유효하지 않음). |
409 | send_all_limit | 50행(MAX_SEND_ALL_ROWS)을 초과하는 배치에 대해 sendAll: true를 요청함. |
409 | no_pdf_attachments | 요청에 대해 PDF 첨부 파일을 해석하거나 렌더링할 수 없음. |
409 | row_not_found | 요청한 rowIndex가 배치에 존재하지 않음. |
422 | UnprocessableEntity | Mongoose 유효성 검사 오류. |
500 | invalid_pdf | 전달된 pdfBase64 또는 pdfFiles 페이로드가 유효한 PDF가 아님. |
웹훅 및 MCP 연동
- 웹훅: 전송에 성공하면
smart_batch_report_sent를, 실패하면smart_batch_report_delivery_failed를 자동으로 발송하며SmartReport에emailDelivery를 기록합니다. SmartReports 웹훅을 참조하세요. - MCP 대응 도구: AI 에이전트는
smart_report_send_emailMCP 도구를 통해 리포트 이메일을 전송할 수 있습니다. MCP 및 AI 에이전트를 참조하세요.
참고 사항
- 이메일 전송 오류는 200이 아닌 상태 코드 대신
success: false,messageId: null,error와 함께200 OK를 반환하므로 항상 응답 본문의success를 확인하세요. - 단일 호출로 검증 단계 실행, PDF 생성, 이메일 전송을 한 번에 처리하려면 Smart Report 실행을 사용하세요.