serverlesspdf API Reference

Integrate PDF generation into your product in minutes. A single predictable API for render and download flows.

POST /v1/documents/render

POST

Primary PDF generation method. Accepts HTML, CSS and render options. Returns a ready document or a link to it.

Request Headers
Authorization: Bearer <api_key>
Content-Type: application/json
Request Body
{
  "html": "<!doctype html><html>...</html>",
  "options": {
    "pageSize": "A4",
    "landscape": false,
    "printBackground": true,
    "margin": {
      "top": "12mm",
      "right": "12mm",
      "bottom": "12mm",
      "left": "12mm"
    }
  }
}

GET /v1/documents/:documentId/download

GET

Fetch a generated PDF document by ID. On success the route returns a redirect to a short-lived signed URL for secure downloads.

Auth options
  • Session cookie (browser)
  • Bearer API key (backend integrations)

Error format

All errors use the same structured response shape:

{
  "error": {
    "code": "QUOTA_EXCEEDED",
    "message": "Monthly limit reached",
    "requestId": "req_123abc"
  }
}