Sync Multiple PDF Generation (ZIP)
The POST /file/sync/multiple endpoint generates multiple PDF files synchronously from the specified design and multiple parameters, and returns them as a ZIP file.
Endpoint Information
- URL:
https://{workspaceId}.re-port-flow.com/v1/file/sync/multiple - Method:
POST - Authentication: Requires AppKey and SecretKey
- Timeout: 30 seconds (depends on file count)
- Request Size Limit: 20MB
Usage Examples
cURL
curl -X POST https://your-workspace-id.re-port-flow.com/v1/file/sync/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"
}
}
]
}' \
--output invoices.zip
JavaScript
const axios = require('axios');
const fs = require('fs');
async function generateMultiplePDFs(designId, contents) {
const response = await axios.post(
`https://${process.env.WORKSPACE_ID}.re-port-flow.com/v1/file/sync/multiple`,
{
designId,
version: 1,
contents
},
{
headers: {
'AppKey': process.env.APP_KEY,
'SecretKey': process.env.SECRET_KEY
},
responseType: 'arraybuffer'
}
);
// Get file mapping from X-File-Mapping header
const fileMapping = JSON.parse(response.headers['x-file-mapping'] || '{}');
console.log('Generated files:', fileMapping);
return response.data; // ZIP binary
}
// Usage example
const contents = [
{
fileName: 'invoice_001.pdf',
params: { customerName: 'John Doe', invoiceNumber: 'INV-001' }
},
{
fileName: 'invoice_002.pdf',
params: { customerName: 'Jane Smith', invoiceNumber: 'INV-002' }
}
];
const zipData = await generateMultiplePDFs('550e8400-...', contents);
fs.writeFileSync('invoices.zip', zipData);
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 (200 OK)
Response Body: ZIP file (binary)
Response Headers:
| Header | Description | Example |
|---|---|---|
Content-Type | Content type | application/zip |
Content-Disposition | File name | attachment; filename="files.zip" |
File-URL | File URL | https://re-port-flow.com/workspace-id/design/design-id/files/file-uuid |
X-File-Mapping | File mapping info (JSON) | [{"fileName":"invoice_001.pdf","fileId":"file_1"}] |
Use Cases
Bulk Monthly Invoice Generation
async function generateMonthlyInvoices(month) {
// Get invoice data for the month
const invoices = await getInvoicesByMonth(month);
// Create ContentDto array
const contents = invoices.map(invoice => ({
fileName: `invoice_${invoice.number}.pdf`,
params: invoice
}));
// Bulk generation
const zipData = await generateMultiplePDFs('invoice-template-id', contents);
// Save ZIP file
fs.writeFileSync(`invoices_${month}.zip`, zipData);
}
Next Steps
- Async Multiple PDF Generation - To avoid timeout
- File Download - How to download generated ZIP files