テンプレートサンプルをダウンロードする
保存済みの Smart Report テンプレート({id})をバイナリ PDF ファイルにレンダリングし、HTTP レスポンスで直接ストリーミング配信します(Content-Type: application/pdf)。リクエストボディに sampleData を指定するか、省略してテンプレートに保存されている sampleData にフォールバックするか、事前レンダリング済みの printHtml を渡すことができます。
ヘッドレスパイプラインや CI 検証スイートでは、テンプレートの HTML をプレビューするで反復調整した後にこのエンドポイントを使用し、本番の SmartBatch 実行へ昇格させる前に Chromium または PDFKit による実際の改ページ、カスタムフォント、透かし、ヘッダー/フッター、ページ余白をディスク上で確認できます。最大 64MB までの JSON リクエストボディに対応しています。
エンドポイント
POST https://api.verifik.co/v2/smart-report-templates/{id}/download-sample
Smart-Agent プロキシ(https://ai.verifik.co)でも同じ /v2/... パスが公開されており、ご自身の Authorization: Bearer <VERIFIK_JWT> ヘッダーが必要です。
ヘッダー
| 名前 | 値 |
|---|---|
| Content-Type | application/json |
| Accept | application/json |
| Authorization | Bearer <VERIFIK_JWT> |
注記: 200 レスポンスの場合、サーバーは Content-Type: application/pdf と Content-Disposition: attachment; filename="SmartReport_TemplateSample_<id>.pdf" を返します。エラーレスポンス(401、404、409)は JSON を返します。
パラメータ
| 名前 | 型 | 必須 | 説明 |
|---|---|---|---|
id | string | はい | Smart Report テンプレートの ObjectId。 |
リクエストボディ
最大 64MB までの JSON ペイロードに対応しています。ボディフィールドはすべて任意です。
| 名前 | 型 | 必須 | 説明 |
|---|---|---|---|
sampleData | object | いいえ | サンプルペイロード(inputData、results、batchName、rowIndex)。省略した場合は template.sampleData にフォールバックします。 |
printHtml | string | いいえ | PDF へ直接レンダリングする任意の事前レンダリング済み HTML 文字列。 |
リクエスト
成功レスポンスは JSON ではなく生のバイナリ PDF バイト列を返すため、HTTP クライアントをバイナリ出力向けに設定してください(Node.js では responseType: "arraybuffer" / Buffer、PHP/Python/Go では生のレスポンスバイト列、cURL では -o sample.pdf)。
- Node.js
- PHP
- Python
- Go
- cURL
const fs = require("fs");
const axios = require("axios");
async function run() {
const id = "67c1f94b2d8a1c0012a4b301";
const res = await axios.post(
`https://api.verifik.co/v2/smart-report-templates/${id}/download-sample`,
{
sampleData: {
batchName: "Driver Onboarding Sample",
rowIndex: 0,
inputData: {
documentType: "CC",
documentNumber: "1020304050",
},
results: {
identity: {
fullName: "Mateo Rojas",
status: "active",
},
},
},
},
{
responseType: "arraybuffer",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
}
);
const pdfBuffer = Buffer.from(res.data);
fs.writeFileSync("sample.pdf", pdfBuffer);
console.log(`Saved sample.pdf (${pdfBuffer.length} bytes)`);
}
run();
<?php
$id = "67c1f94b2d8a1c0012a4b301";
$payload = [
"sampleData" => [
"batchName" => "Driver Onboarding Sample",
"rowIndex" => 0,
"inputData" => [
"documentType" => "CC",
"documentNumber" => "1020304050",
],
"results" => [
"identity" => [
"fullName" => "Mateo Rojas",
"status" => "active",
],
],
],
];
$ch = curl_init("https://api.verifik.co/v2/smart-report-templates/" . $id . "/download-sample");
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);
$binary = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
fwrite(STDERR, "Request failed ($status): $binary\n");
exit(1);
}
file_put_contents("sample.pdf", $binary);
echo "Saved sample.pdf (" . strlen($binary) . " bytes)\n";
import os
import requests
template_id = "67c1f94b2d8a1c0012a4b301"
url = f"https://api.verifik.co/v2/smart-report-templates/{template_id}/download-sample"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
payload = {
"sampleData": {
"batchName": "Driver Onboarding Sample",
"rowIndex": 0,
"inputData": {
"documentType": "CC",
"documentNumber": "1020304050",
},
"results": {
"identity": {
"fullName": "Mateo Rojas",
"status": "active",
}
},
}
}
r = requests.post(url, json=payload, headers=headers)
r.raise_for_status()
with open("sample.pdf", "wb") as f:
f.write(r.content)
print(f"Saved sample.pdf ({len(r.content)} bytes)")
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
func main() {
id := "67c1f94b2d8a1c0012a4b301"
body, _ := json.Marshal(map[string]interface{}{
"sampleData": map[string]interface{}{
"batchName": "Driver Onboarding Sample",
"rowIndex": 0,
"inputData": map[string]interface{}{
"documentType": "CC",
"documentNumber": "1020304050",
},
"results": map[string]interface{}{
"identity": map[string]interface{}{
"fullName": "Mateo Rojas",
"status": "active",
},
},
},
})
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/smart-report-templates/"+id+"/download-sample", 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()
if resp.StatusCode != http.StatusOK {
errBytes, _ := io.ReadAll(resp.Body)
panic(fmt.Sprintf("status %d: %s", resp.StatusCode, string(errBytes)))
}
outFile, err := os.Create("sample.pdf")
if err != nil {
panic(err)
}
defer outFile.Close()
n, err := io.Copy(outFile, resp.Body)
if err != nil {
panic(err)
}
fmt.Printf("Saved sample.pdf (%d bytes)\n", n)
}
curl -X POST "https://api.verifik.co/v2/smart-report-templates/67c1f94b2d8a1c0012a4b301/download-sample" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT" \
-f -o sample.pdf \
-d '{
"sampleData": {
"batchName": "Driver Onboarding Sample",
"rowIndex": 0,
"inputData": {
"documentType": "CC",
"documentNumber": "1020304050"
},
"results": {
"identity": {
"fullName": "Mateo Rojas",
"status": "active"
}
}
}
}'
レスポンス
- 200 (バイナリ PDF)
- 401
- 404
- 409
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="SmartReport_TemplateSample_67c1f94b2d8a1c0012a4b301.pdf"
<binary PDF byte stream>
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "Template not found",
"code": "template_not_found"
}
{
"message": "\"sampleData\" must be an object",
"code": "MissingParameter"
}
補足
- このエンドポイントからの
200レスポンスに対してres.json()を呼び出さないでください。レスポンスをバイナリバッファ(arraybuffer/bytes/io.Copy)として読み取り、ディスクまたはオブジェクトストレージへ書き込んでください。 sampleDataとprintHtmlをどちらも省略した場合(例:{}を送信)、テンプレート自体に保存されているsampleDataが使用されます。- フル PDF を生成せずにレイアウトをすばやく反復確認するには、テンプレートの HTML をプレビューするをご利用ください。