Skip to main content

API Reference

Complete reference for all HTTP endpoints exposed by the PDFSamurai Docker Server.

Generate PDF

Generates a PDF from a template and returns it as binary data.

POST /generate
Content-Type: application/json

Request body

FieldTypeRequiredDescription
templateIdstringYesThe ID of the template to generate
dynamicDataObjectNoKey-value pairs to replace template placeholders
apiKeystringYesYour API key
developerKeystringYesYour developer key. See Integration — Developer keys

Response

  • 200application/pdf binary body
  • 400 — Invalid request (missing fields, invalid format)
  • 401 — Invalid or missing API key
  • 503 — Queue is full (see MAX_QUEUE_SIZE in Configuration)

Example

curl -X POST http://localhost:3000/generate \
-H "Content-Type: application/json" \
-d '{"templateId":"your-template-id","apiKey":"your-api-key","developerKey":"your-developer-key","dynamicData":{"customerName":"John Doe"}}' \
-o document.pdf

Generate PDF (base64)

Same as /generate, but returns the PDF as a base64-encoded string.

POST /generate/base64
Content-Type: application/json

Request body — same as /generate (including developerKey).

Response

  • 200application/json
{
"pdf": "base64-encoded-string"
}
  • 400, 401, 503 — same as /generate

List templates

Returns the templates available for the given API key.

GET /templates

Authentication — pass your API key and developer key via query parameters or headers:

  • Query parameters: ?apiKey=your-api-key&developerKey=your-developer-key
  • Headers: x-api-key: your-api-key and x-developer-key: your-developer-key

Response

  • 200application/json array of templates

Get dynamic data keys

Returns the dynamic data keys defined in a template.

GET /templates/:templateId/dynamic-data-keys

Authentication — same as /templates (query parameters or headers).

Response

  • 200application/json array of key names

Health check

Returns server status and worker pool information.

GET /health

Response

  • 200application/json with server and worker pool status