REST API

One endpoint. Everything you need.

REST API with predictable endpoints, JSON everywhere, and responses under 100ms. If your code can make an HTTP POST, it works.

Authentication

All requests must include your API key in the Authorization header as a Bearer token. Generate keys from your account dashboard.

  • Keep your API key secret — never expose it in client-side code or public repos
  • Use environment variables on your server
  • If compromised, rotate immediately from your dashboard
http
Authorization: Bearer sk_live_...

Errors

ExportToPDF uses standard HTTP status codes. All errors return JSON with a code and message field.

  • 400 — Bad request (invalid parameters)
  • 401 — Unauthorized (missing or invalid API key)
  • 404 — Template or document not found
  • 429 — Rate limit exceeded
  • 500 — Server error (we are notified automatically)
json
{
  "code": "template_not_found",
  "message": "No template with ID tpl_8xk2p exists."
}

Generate a document

POST/v1/documents/generate

The core endpoint. POST your template ID and data payload. Get a download URL or raw bytes back — typically under 100ms.

  • Returns a download_url valid for 24 hours by default
  • Pass output: "bytes" to receive raw PDF bytes in the response
  • Pass version: "staging" to test a non-live template version
python
from exporttopdf import ExportToPDF

client = ExportToPDF(api_key="sk_live_...")

doc = client.documents.generate(
    template_id="tpl_8xk2p",
    data={
        "name": "Acme Corp",
        "invoiceNumber": "INV-041",
        "total": 12400
    }
)

print(doc.download_url)  # ready in < 100ms

Rate limits

Rate limits are applied per API key. Headers in every response show your current usage.

  • Free plan: 60 requests/minute
  • Pro plan: 300 requests/minute
  • Business: custom limits available on request
http
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1711234567

Webhooks

POSTYour configured URL

Configure webhook URLs in template settings. When a PDF is generated, ExportToPDF will POST to your URL with the document metadata.

json
{
  "event": "document.generated",
  "document_id": "doc_xyz123",
  "template_id": "tpl_8xk2p",
  "download_url": "https://...",
  "generated_at": "2026-03-19T12:00:00Z"
}

Test founder quote

PGG
Pratik Ghela
CEO