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
| Field | Type | Required | Description |
|---|---|---|---|
templateId | string | Yes | The ID of the template to generate |
dynamicData | Object | No | Key-value pairs to replace template placeholders |
apiKey | string | Yes | Your API key |
developerKey | string | Yes | Your developer key. See Integration — Developer keys |
Response
- 200 —
application/pdfbinary body - 400 — Invalid request (missing fields, invalid format)
- 401 — Invalid or missing API key
- 503 — Queue is full (see
MAX_QUEUE_SIZEin 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
- 200 —
application/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-keyandx-developer-key: your-developer-key
Response
- 200 —
application/jsonarray 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
- 200 —
application/jsonarray of key names
Health check
Returns server status and worker pool information.
GET /health
Response
- 200 —
application/jsonwith server and worker pool status