Skip to main content
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"
  }
]'
{
  "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

x-api-key
string
header
required

API key for accessing the Docurate PDF API

Body

application/json · object[]
templateId
string
required
Example:

"template_123"

data
object
Example:
{
"name": "John Doe",
"company": "Acme Corp"
}
filename
string
Example:

"document1.pdf"

Response

Batch PDF generation completed

success
boolean

Overall success if at least one PDF was generated

Example:

true

message
string
Example:

"Batch PDF generation completed: 2 successful, 0 failed"

results
object[]
summary
object