メインコンテンツまでスキップ

複数PDF非同期生成

POST /file/async/multiple エンドポイントは、指定されたデザインと複数のパラメータから複数のPDFファイルを非同期的に生成します。

エンドポイント情報

  • URL: https://api.re-port-flow.com/v1/file/async/multiple
  • メソッド: POST
  • 認証: appkey ヘッダーが必要
  • タイムアウト: なし(非同期処理)
  • リクエストサイズ上限: 50MB(Base64エンコード後、実質約37MB相当)

使用例

cURL

curl -X POST https://api.re-port-flow.com/v1/file/async/multiple \
-H "appkey: your-application-key" \
-H "Content-Type: application/json" \
-d '{
"designId": "550e8400-e29b-41d4-a716-446655440000",
"version": 1,
"contents": [
{
"fileName": "invoice_001.pdf",
"shareType": "workspace",
"passcodeEnabled": false,
"params": { "customerName": "山田太郎", "invoiceNumber": "INV-001" }
},
{
"fileName": "invoice_002.pdf",
"shareType": "workspace",
"passcodeEnabled": false,
"params": { "customerName": "佐藤花子", "invoiceNumber": "INV-002" }
}
]
}'

リクエストパラメータ

フィールド必須説明
designIdstring (UUID)デザインID
versionintegerバージョン番号
contentsarrayContentDtoの配列(最小1件)
contents[].fileNamestringファイル名(/ \\ : * ? " < > | および制御文字以外は使用可能。配列内で一意であること(大文字・小文字は区別しない))
contents[].shareTypestring-共有タイプ(workspace / invited / public、デフォルト: workspace
contents[].passcodeEnabledboolean-パスコード保護(デフォルト: false
contents[].passthroughobject-レスポンスの files[].passthrough に透過する任意のメタデータ(例: { "pageId": "abc123" }
contents[].paramsobjectパラメータ(デザインパラメータ取得APIで構造を確認可能)

レスポンス

成功時 (202 Accepted)

{
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"url": "https://api.re-port-flow.com/v1/file/download/{requestId}",
"files": [
{
"fileName": "invoice_001.pdf",
"fileId": "aaa111",
"passthrough": { "pageId": "abc123" },
"share": {
"shareType": "workspace",
"url": "https://app.re-port-flow.com/file/{requestId}/aaa111",
"passcodeEnabled": false
}
},
{
"fileName": "invoice_002.pdf",
"fileId": "bbb222",
"share": {
"shareType": "workspace",
"url": "https://app.re-port-flow.com/file/{requestId}/bbb222",
"passcodeEnabled": false
}
}
]
}
フィールド説明
requestIdstring (UUID)リクエストID(ZIPダウンロードエンドポイントで使用)
urlstring (URI)ZIPダウンロードURL
filesarray各PDFファイルの情報
files[].fileNamestringPDFファイル名
files[].fileIdstring個別ファイルID(個別ダウンロードエンドポイントで使用)
files[].passthroughobjectリクエスト時に指定した contents[].passthrough の値(指定時のみ)
files[].share.shareTypestring共有タイプ(workspace / invited / public
files[].share.urlstringファイル表示URL
files[].share.passcodeEnabledbooleanパスコード有効フラグ
files[].share.passcodestringサーバー生成パスコード(passcodeEnabled=true かつ生成直後のみ)

エラー時

単一PDF同期生成と同様のエラーレスポンスに加え、以下のエラーが返される場合があります。

400 Bad Request(fileName 重複)

{
"statusCode": 400,
"message": [
"contents 内の fileName が重複しています(大文字・小文字は区別されません)。各ファイルには一意の名前を指定してください。"
],
"error": "Bad Request"
}

原因: contents 配列内に同じ fileName(大文字・小文字の違いのみを含む)が複数存在する

ユースケース

大量請求書の一括生成

async function generateBulkInvoices(invoices) {
const batchSize = 100;
const batches = chunkArray(invoices, batchSize);
const results = [];

for (const [index, batch] of batches.entries()) {
console.log(`バッチ ${index + 1}/${batches.length} 処理中...`);

const contents = batch.map(invoice => ({
fileName: `invoice_${invoice.number}.pdf`,
shareType: 'workspace',
passcodeEnabled: false,
params: invoice
}));

const response = await axios.post(
'https://api.re-port-flow.com/v1/file/async/multiple',
{ designId: 'template-id', version: 1, contents },
{ headers: { 'appkey': process.env.APP_KEY } }
);

results.push(response.data);

if (index < batches.length - 1) {
await new Promise(resolve => setTimeout(resolve, 1000));
}
}

return results;
}

次のステップ