PDF Generation
Generate Multiple PDFs (Batch)
Generate multiple PDFs from different templates in a single API call with detailed result tracking
POST
/
api
/
generate-pdfs-batch
Generate Multiple PDFs (Batch)
curl --request POST \
--url https://api.curatepdf.com/api/generate-pdfs-batch \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
[
{
"templateId": "template_123",
"data": {
"name": "John Doe",
"company": "Acme Corp"
},
"filename": "document1.pdf"
},
{
"templateId": "template_456",
"data": {
"name": "Jane Smith",
"department": "Marketing"
},
"filename": "document2.pdf"
}
]
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
templateId: 'template_123',
data: {name: 'John Doe', company: 'Acme Corp'},
filename: 'document1.pdf'
},
{
templateId: 'template_456',
data: {name: 'Jane Smith', department: 'Marketing'},
filename: 'document2.pdf'
}
])
};
fetch('https://api.curatepdf.com/api/generate-pdfs-batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.curatepdf.com/api/generate-pdfs-batch"
payload = [
{
"templateId": "template_123",
"data": {
"name": "John Doe",
"company": "Acme Corp"
},
"filename": "document1.pdf"
},
{
"templateId": "template_456",
"data": {
"name": "Jane Smith",
"department": "Marketing"
},
"filename": "document2.pdf"
}
]
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.curatepdf.com/api/generate-pdfs-batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'templateId' => 'template_123',
'data' => [
'name' => 'John Doe',
'company' => 'Acme Corp'
],
'filename' => 'document1.pdf'
],
[
'templateId' => 'template_456',
'data' => [
'name' => 'Jane Smith',
'department' => 'Marketing'
],
'filename' => 'document2.pdf'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.curatepdf.com/api/generate-pdfs-batch")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n {\n \"templateId\": \"template_123\",\n \"data\": {\n \"name\": \"John Doe\",\n \"company\": \"Acme Corp\"\n },\n \"filename\": \"document1.pdf\"\n },\n {\n \"templateId\": \"template_456\",\n \"data\": {\n \"name\": \"Jane Smith\",\n \"department\": \"Marketing\"\n },\n \"filename\": \"document2.pdf\"\n }\n]")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.curatepdf.com/api/generate-pdfs-batch"
payload := strings.NewReader("[\n {\n \"templateId\": \"template_123\",\n \"data\": {\n \"name\": \"John Doe\",\n \"company\": \"Acme Corp\"\n },\n \"filename\": \"document1.pdf\"\n },\n {\n \"templateId\": \"template_456\",\n \"data\": {\n \"name\": \"Jane Smith\",\n \"department\": \"Marketing\"\n },\n \"filename\": \"document2.pdf\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"success": true,
"message": "Batch PDF generation completed: 2 successful, 0 failed",
"results": [
{
"index": 0,
"success": true,
"data": {
"filePath": "user_123/document1.pdf",
"downloadUrl": "https://storage.example.com/document1.pdf",
"expiresAt": "2024-01-15T23:59:59.000Z",
"filename": "document1.pdf",
"size": 123456
},
"error": {
"code": "TEMPLATE_NOT_FOUND",
"message": "Template not found"
}
}
],
"summary": {
"total": 2,
"successful": 2,
"failed": 0
}
}Overview
The Generate PDFs Batch endpoint allows you to create multiple PDF documents from different templates in a single API call. This is perfect for scenarios where you need to generate many documents at once, such as bulk invoice processing, mass certificate generation, or report batching.Each PDF in the batch is processed individually with detailed success/failure tracking. Partial success is supported - some PDFs can succeed while others fail.
Key Features
Bulk Processing
Multiple TemplatesGenerate PDFs from different templates in a single request, each with unique data and filenames.
Detailed Results
Individual TrackingGet detailed success/failure status for each PDF with specific error messages and download URLs.
Partial Success
Resilient ProcessingIf some PDFs fail, successful ones are still generated and available for download.
Efficiency
Optimized PerformanceProcess multiple PDFs in a single request.
Request Structure
The request body is a direct array of PDF generation requests. Each item has the same structure as the single PDF endpoint.Basic Batch Request
[
{
"templateId": "invoice_template_123",
"data": {
"customerName": "John Smith",
"invoiceNumber": "INV-001",
"amount": 1299.99
},
"filename": "invoice-001.pdf"
},
{
"templateId": "receipt_template_456",
"data": {
"customerName": "Jane Doe",
"receiptNumber": "REC-001",
"total": 45.99
},
"filename": "receipt-001.pdf"
}
]
Mixed Template Batch
[
{
"templateId": "certificate_template",
"data": {
"studentName": "Alice Johnson",
"courseName": "Advanced JavaScript",
"completionDate": "2024-01-15",
"grade": "A+"
},
"filename": "certificate-alice-javascript.pdf"
},
{
"templateId": "invoice_template",
"data": {
"company": "Acme Corp",
"invoiceNumber": "INV-2024-001",
"items": [
{
"name": "Consulting",
"amount": 5000.00
}
]
},
"filename": "invoice-acme-001.pdf"
},
{
"templateId": "report_template",
"data": {
"reportTitle": "Q1 Sales Report",
"quarter": "Q1 2024",
"totalSales": 125000
},
"filename": "q1-sales-report.pdf"
}
]
Response Structure
The response includes detailed results for each PDF generation attempt, plus summary statistics.Successful Batch Response
{
"success": true,
"message": "Batch PDF generation completed: 2 successful, 0 failed",
"results": [
{
"index": 0,
"success": true,
"data": {
"filePath": "user_123/invoice-001.pdf",
"downloadUrl": "https://storage.example.com/invoice-001.pdf?token=xyz",
"expiresAt": "2024-01-15T23:59:59.000Z",
"filename": "invoice-001.pdf",
"size": 45678
}
},
{
"index": 1,
"success": true,
"data": {
"filePath": "user_123/receipt-001.pdf",
"downloadUrl": "https://storage.example.com/receipt-001.pdf?token=abc",
"expiresAt": "2024-01-15T23:59:59.000Z",
"filename": "receipt-001.pdf",
"size": 23456
}
}
],
"summary": {
"total": 2,
"successful": 2,
"failed": 0
}
}
Partial Success Response
{
"success": true,
"message": "Batch PDF generation completed: 1 successful, 1 failed",
"results": [
{
"index": 0,
"success": true,
"data": {
"filePath": "user_123/invoice-001.pdf",
"downloadUrl": "https://storage.example.com/invoice-001.pdf?token=xyz",
"expiresAt": "2024-01-15T23:59:59.000Z",
"filename": "invoice-001.pdf",
"size": 45678
}
},
{
"index": 1,
"success": false,
"error": {
"code": "TEMPLATE_NOT_FOUND",
"message": "Template not found"
}
}
],
"summary": {
"total": 2,
"successful": 1,
"failed": 1
}
}
Authorizations
API key for accessing the Docurate PDF API
Body
application/json
Minimum array length:
1Example:
[
{
"templateId": "template_123",
"data": {
"name": "John Doe",
"company": "Acme Corp"
},
"filename": "document1.pdf"
},
{
"templateId": "template_456",
"data": {
"name": "Jane Smith",
"department": "Marketing"
},
"filename": "document2.pdf"
}
]
⌘I
Generate Multiple PDFs (Batch)
curl --request POST \
--url https://api.curatepdf.com/api/generate-pdfs-batch \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
[
{
"templateId": "template_123",
"data": {
"name": "John Doe",
"company": "Acme Corp"
},
"filename": "document1.pdf"
},
{
"templateId": "template_456",
"data": {
"name": "Jane Smith",
"department": "Marketing"
},
"filename": "document2.pdf"
}
]
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
templateId: 'template_123',
data: {name: 'John Doe', company: 'Acme Corp'},
filename: 'document1.pdf'
},
{
templateId: 'template_456',
data: {name: 'Jane Smith', department: 'Marketing'},
filename: 'document2.pdf'
}
])
};
fetch('https://api.curatepdf.com/api/generate-pdfs-batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.curatepdf.com/api/generate-pdfs-batch"
payload = [
{
"templateId": "template_123",
"data": {
"name": "John Doe",
"company": "Acme Corp"
},
"filename": "document1.pdf"
},
{
"templateId": "template_456",
"data": {
"name": "Jane Smith",
"department": "Marketing"
},
"filename": "document2.pdf"
}
]
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.curatepdf.com/api/generate-pdfs-batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'templateId' => 'template_123',
'data' => [
'name' => 'John Doe',
'company' => 'Acme Corp'
],
'filename' => 'document1.pdf'
],
[
'templateId' => 'template_456',
'data' => [
'name' => 'Jane Smith',
'department' => 'Marketing'
],
'filename' => 'document2.pdf'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.curatepdf.com/api/generate-pdfs-batch")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n {\n \"templateId\": \"template_123\",\n \"data\": {\n \"name\": \"John Doe\",\n \"company\": \"Acme Corp\"\n },\n \"filename\": \"document1.pdf\"\n },\n {\n \"templateId\": \"template_456\",\n \"data\": {\n \"name\": \"Jane Smith\",\n \"department\": \"Marketing\"\n },\n \"filename\": \"document2.pdf\"\n }\n]")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.curatepdf.com/api/generate-pdfs-batch"
payload := strings.NewReader("[\n {\n \"templateId\": \"template_123\",\n \"data\": {\n \"name\": \"John Doe\",\n \"company\": \"Acme Corp\"\n },\n \"filename\": \"document1.pdf\"\n },\n {\n \"templateId\": \"template_456\",\n \"data\": {\n \"name\": \"Jane Smith\",\n \"department\": \"Marketing\"\n },\n \"filename\": \"document2.pdf\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"success": true,
"message": "Batch PDF generation completed: 2 successful, 0 failed",
"results": [
{
"index": 0,
"success": true,
"data": {
"filePath": "user_123/document1.pdf",
"downloadUrl": "https://storage.example.com/document1.pdf",
"expiresAt": "2024-01-15T23:59:59.000Z",
"filename": "document1.pdf",
"size": 123456
},
"error": {
"code": "TEMPLATE_NOT_FOUND",
"message": "Template not found"
}
}
],
"summary": {
"total": 2,
"successful": 2,
"failed": 0
}
}