Async Multiple PDF Generation (ZIP)
The POST /file/async/multiple endpoint generates multiple PDF files asynchronously from the specified design and multiple parameters, and saves them as a ZIP file.
Endpoint Information
- URL:
https://{workspaceId}.re-port-flow.com/v1/file/async/multiple - Method:
POST - Authentication: Requires AppKey and SecretKey
- Timeout: None (async processing)
- Request Size Limit: 20MB
Usage Examples
cURL
curl -X POST https://your-workspace-id.re-port-flow.com/v1/file/async/multiple \
-H "AppKey: your-app-key" \
-H "SecretKey: your-secret-key" \
-H "Content-Type: application/json" \
-d '{
"designId": "550e8400-e29b-41d4-a716-446655440000",
"version": 1,
"contents": [
{
"fileName": "invoice_001.pdf",
"params": { "customerName": "John Doe", "invoiceNumber": "INV-001" }
},
{
"fileName": "invoice_002.pdf",
"params": { "customerName": "Jane Smith", "invoiceNumber": "INV-002" }
}
]
}'
Response example:
{
"url": "https://re-port-flow.com/workspace-id/design/550e8400-e29b-41d4-a716-446655440000/files/file-uuid",
"fileId": "batch_abc123",
"files": [
{ "fileName": "invoice_001.pdf", "fileId": "file_001" },
{ "fileName": "invoice_002.pdf", "fileId": "file_002" }
]
}
JavaScript
async function generateMultiplePDFsAsync(designId, contents) {
// 1. Async generation request
const response = await axios.post(
`https://${process.env.WORKSPACE_ID}.re-port-flow.com/v1/file/async/multiple`,
{
designId,
version: 1,
contents
},
{
headers: {
'AppKey': process.env.APP_KEY,
'SecretKey': process.env.SECRET_KEY
}
}
);
const { url, fileId, files } = response.data;
console.log('ZIP generation started:', { url, fileId, files });
// 2. Download ZIP from URL
const zipResponse = await axios.get(url, {
responseType: 'arraybuffer'
});
return {
data: zipResponse.data,
url,
fileId,
files
};
}
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
designId | string (UUID) | ✓ | Design ID |
version | integer | ✓ | Version number |
contents | array | ✓ | Array of ContentDto (minimum 1 item) |
contents[].fileName | string | ✓ | File name |
contents[].params | object | ✓ | Parameters (check structure via Design Parameters API) |
Response
Success (202 Accepted)
{
"url": "https://re-port-flow.com/workspace-id/design/550e8400-e29b-41d4-a716-446655440000/files/file-uuid",
"fileId": "batch_abc123",
"files": [
{ "fileName": "invoice_001.pdf", "fileId": "file_001" },
{ "fileName": "invoice_002.pdf", "fileId": "file_002" }
]
}
| Field | Type | Description |
|---|---|---|
url | string (URI) | Generated ZIP file URL |
fileId | string | Batch ID (ID for entire ZIP) |
files | array | Information for each PDF file |
files[].fileName | string | PDF file name |
files[].fileId | string | Individual file ID |
Use Cases
Bulk Invoice Generation
async function generateBulkInvoices(invoices) {
const batchSize = 100; // Process 100 at a time
const batches = chunkArray(invoices, batchSize);
const results = [];
for (const [index, batch] of batches.entries()) {
console.log(`Processing batch ${index + 1}/${batches.length}...`);
const contents = batch.map(invoice => ({
fileName: `invoice_${invoice.number}.pdf`,
params: invoice
}));
const result = await generateMultiplePDFsAsync('template-id', contents);
results.push(result);
// Rate limiting
if (index < batches.length - 1) {
await sleep(1000);
}
}
return results;
}
Next Steps
- Bulk ZIP Download - How to download generated ZIP files
- Async Workflows - Best practices for bulk generation