POST
/
api
/
generate-pdf
curl --request POST \
  --url https://api.curatepdf.com/api/generate-pdf \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "templateId": "template_123"
}'
{
  "success": true,
  "downloadUrl": "https://storage.example.com/document.pdf",
  "expiresAt": "2024-01-15T23:59:59.000Z",
  "filename": "document.pdf",
  "size": 123456
}

Overview

The Generate PDF endpoint is the core functionality of CuratePDF. It takes a template ID and dynamic data to produce a professionally formatted PDF document that’s automatically stored in secure cloud storage.

Generated PDFs are temporarily stored and accessible via secure download URLs with automatic expiration for enhanced security.

Key Features

Dynamic Data Binding

Variable Substitution

Replace template variables with real data like customer names, invoice numbers, dates, and complex objects.

Cloud Storage

Secure File Hosting

Generated PDFs are automatically uploaded to secure cloud storage with time-limited download URLs.

Custom Filenames

Flexible Naming

Specify custom filenames with dynamic content for better organization and identification.

High Performance

Fast Generation

Optimized PDF rendering engine processes documents quickly even with complex layouts.

Data Binding

Template variables are replaced with actual data during PDF generation. Variables use double curly brace syntax: {{variable_name}}.

Simple Variable Binding

{
  "customerName": "John Smith",
  "invoiceNumber": "INV-001", 
  "date": "2024-01-15",
  "amount": 1299.99,
  "currency": "USD"
}

Complex Object Binding

{
  "data": {
    "customer": {
      "name": "Acme Corporation",
      "email": "billing@acme.com",
      "address": {
        "street": "123 Business Ave",
        "city": "New York",
        "state": "NY",
        "zip": "10001"
      }
    },
    "items": [
      {
        "name": "Professional Service",
        "quantity": 10,
        "rate": 150.00,
        "total": 1500.00
      },
      {
        "name": "Consultation", 
        "quantity": 5,
        "rate": 200.00,
        "total": 1000.00
      }
    ]
  }
}

Common Use Cases

Invoice Example
const invoiceData = {
  templateId: "invoice_template_123",
  data: {
    invoiceNumber: "INV-2024-001",
    issueDate: "2024-01-15",
    dueDate: "2024-02-14",
    company: {
      name: "Your Company Inc.",
      address: "123 Business St, City, State 12345",
      phone: "(555) 123-4567",
      email: "billing@yourcompany.com"
    },
    client: {
      name: "Client Corporation", 
      address: "456 Client Ave, Client City, CC 67890",
      email: "ap@clientcorp.com"
    },
    lineItems: [
      {
        description: "Web Development Services",
        hours: 40,
        rate: 125.00,
        amount: 5000.00
      },
      {
        description: "Design Consultation",
        hours: 8, 
        rate: 150.00,
        amount: 1200.00
      }
    ],
    subtotal: 6200.00,
    tax: 496.00,
    total: 6696.00
  },
  filename: "invoice-INV-2024-001.pdf"
};

const response = await fetch('https://api.curatepdf.com/api/generate-pdf', {
  method: 'POST',
  headers: {
    'x-api-key': api_key,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(invoiceData)
});

Authorizations

x-api-key
string
header
required

API key for accessing the Docurate PDF API

Body

application/json

Response

200
application/json

PDF generated successfully

The response is of type object.