Skip to main content

Smart Report PDF 다운로드

SmartReport의 렌더링된 PDF 파일을 바이너리 스트림(Content-Type: application/pdf)으로 다운로드합니다. 백엔드, 포털 또는 연동 시스템에서 Smart Report PDF 생성이 반환하는 base64 JSON 엔벨로프 대신 원시 PDF 바이트가 필요할 때 이 엔드포인트를 사용하세요.

선택적 rowIndex 쿼리 매개변수는 연결된 SmartBatch에서 렌더링하거나 다운로드할 행을 선택합니다. rowIndex를 생략하면 SmartReport의 dataSnapshot.rowIndex로 폴백한 뒤 0으로 폴백합니다.

엔드포인트​

GET https://api.verifik.co/v2/smart-reports/{id}/download

이 엔드포인트는 본인의 클라이언트별 Authorization: Bearer <VERIFIK_JWT>를 사용하여 Smart-Agent 프록시(https://ai.verifik.co/v2/smart-reports/{id}/download)를 통해서도 호출할 수 있습니다. 공유 x402 실행은 403 Forbidden으로 차단됩니다.

헤더​

이름값설명
Acceptapplication/pdf바이너리 PDF 응답 스트림.
AuthorizationBearer <VERIFIK_JWT>클라이언트 범위 JWT (authUser.clientId).

매개변수​

이름위치타입필수설명
idpathstring예SmartReport ObjectId.
rowIndexquerynumber아니요다운로드할 0부터 시작하는 행 인덱스. dataSnapshot.rowIndex로 폴백한 뒤 0으로 폴백합니다.

요청​

이 엔드포인트는 JSON 대신 원시 바이너리 PDF 바이트를 스트리밍하므로, HTTP 클라이언트가 JSON을 파싱하지 않고 바이너리 버퍼를 읽도록 구성하세요.

import fs from "fs";
import axios from "axios";

const run = async () => {
const id = "6801a2b3c4d5e6f7a8b9c0d1";
const response = await axios.get(`https://api.verifik.co/v2/smart-reports/${id}/download`, {
params: { rowIndex: 0 },
responseType: "arraybuffer",
headers: {
Accept: "application/pdf",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
});

fs.writeFileSync("report.pdf", Buffer.from(response.data));
console.log(`Saved report.pdf (${response.data.byteLength} bytes)`);
};

run();

응답​

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="Consulta_1.pdf"
Content-Length: 148320

%PDF-1.4
... (binary PDF stream) ...

응답 헤더 (200 OK)​

헤더값 / 형식설명
Content-Typeapplication/pdf바이너리 PDF MIME 타입.
Content-Dispositionattachment; filename="Consulta_<rowIndex+1>.pdf"1부터 시작하는 행 번호를 사용하는 첨부 파일 이름(예: rowIndex: 0인 경우 Consulta_1.pdf).
Content-Length정수 바이트 길이스트리밍되는 PDF의 정확한 바이트 크기.

오류 코드​

상태오류 코드 / 유형원인
401UnauthorizedJWT가 누락되었거나 유효하지 않음.
403Forbidden공유 x402 실행이 시도됨. 본인의 클라이언트별 JWT를 사용하세요.
404not_found리포트 ID가 존재하지 않거나 다른 클라이언트에 속함.
404template_not_found연결된 템플릿을 찾을 수 없음.
409MissingParameter쿼리 또는 경로 매개변수에서 Joi 검증 실패.
409row_not_found해석된 rowIndex가 배치에 존재하지 않음.
422UnprocessableEntityMongoose 유효성 검사 오류.

웹훅 및 MCP 연동​

관련 문서​