Skip to content
Back to blog
API tutorial integration

Generate PDFs Programmatically with the REST API

PDF Report Studio Team

Every template you build in PDF Report Studio is immediately available as an API endpoint. This means you can generate pixel-perfect PDFs from any language, any framework, and any pipeline — no browser required.

Getting your API key

API keys are created in your dashboard under Settings → API Keys. Each key is prefixed with prs_ and is scoped to your organization. Copy it immediately — it’s only shown once.

Authentication

Every request must include an Authorization header with your key:

Authorization: Bearer prs_your_key_here

Finding your template ID

Use the list endpoint to retrieve your templates and their IDs:

curl https://api.pdfreport.studio/api/templates \
  -H "Authorization: Bearer prs_your_key_here"

The response returns an array of template objects. Note the id field — you’ll use it in the render call.

Rendering a PDF

Send a POST request to /api/templates/:id/render with your data as JSON. The response is a binary PDF.

const response = await fetch(
  `https://api.pdfreport.studio/api/templates/${templateId}/render`,
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer prs_your_key_here',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      data: {
        company: "Acme Corp",
        invoice_number: "INV-2025-001",
        line_items: [
          { description: "Consulting", quantity: 8, rate: 150 },
          { description: "Design work", quantity: 4, rate: 120 },
        ],
      },
    }),
  }
);

const pdf = await response.arrayBuffer();
fs.writeFileSync('invoice.pdf', Buffer.from(pdf));

The data object must match the schema you defined for your template. If it doesn’t, the API returns a 422 with a schema_validation_failed error code telling you exactly which fields are missing or invalid.

Python example

import requests

response = requests.post(
    f"https://api.pdfreport.studio/api/templates/{template_id}/render",
    headers={
        "Authorization": "Bearer prs_your_key_here",
        "Content-Type": "application/json",
    },
    json={
        "data": {
            "company": "Acme Corp",
            "invoice_number": "INV-2025-001",
        }
    },
)

with open("invoice.pdf", "wb") as f:
    f.write(response.content)

What’s next

Back to blog