HTTP API
Start the API with pidief serve (this is the Docker image's default command). The OpenAPI 3.1 document is served at GET /openapi.json and a reference page at GET /docs.
Every endpoint matches a CLI command with the same parameters.
Endpoints
| Endpoint | Operation | Result |
|---|---|---|
POST /v1/html | HTML to PDF | |
POST /v1/template | template + data to PDF | |
POST /v1/template/preview | template + data to HTML | HTML |
POST /v1/images | images to PDF | |
POST /v1/merge | merge | |
POST /v1/split | split | ZIP |
POST /v1/pages/select · /delete · /rotate | page operations | |
POST /v1/watermark · /v1/stamp | watermark, stamp | |
POST /v1/compress | compress | |
POST /v1/pdfa | PDF/A-2b | |
POST /v1/encrypt · /v1/decrypt | passwords | |
POST /v1/metadata | document information | |
POST /v1/info · /v1/text | info, text | JSON |
POST /v1/render | pages to images | image or ZIP |
GET /v1/jobs/{id} · /result, DELETE /v1/jobs/{id} | background jobs | JSON / result |
GET /health/live · /health/ready · /metrics | health, Prometheus |
Authentication
Send an API key in the X-Api-Key header. Keys are set with PIDIEF_API_KEYS; an empty value disables authentication and is meant for development only. See Configuration.
Request bodies
Every endpoint accepts three body types:
multipart/form-data: files as parts with a filename (relative paths are kept, for exampleimg/logo.png); parameters as separate fields or as oneoptionsJSON field.application/json:{"files":[{"name":"a.pdf","content":"<base64>"}], ...parameters}.html,templateanddata(an object) can be given directly.- A raw document (
application/pdf,image/*,text/html) with parameters in the query string.
Examples
curl -H "X-Api-Key: $KEY" -F files=@report.html -F "files=@img/logo.png;filename=img/logo.png" \
-F pageNumbers=true http://localhost:3000/v1/html -o report.pdf
curl -H "X-Api-Key: $KEY" -H 'Content-Type: application/json' http://localhost:3000/v1/template \
-d '{"template":"<h1>{{customer.name}}</h1><p>{{currency total \"EUR\"}}</p>","data":{"customer":{"name":"Example Ltd"},"total":1234.56}}' -o receipt.pdf
curl -H "X-Api-Key: $KEY" -H 'Content-Type: application/pdf' --data-binary @report.pdf \
'http://localhost:3000/v1/render?pages=1&format=webp&maxWidth=300' -o thumb.webp
Background jobs
For long work, add ?async=true. The API returns 202 with {"id":...}. Poll GET /v1/jobs/{id} for the state and fetch the output from GET /v1/jobs/{id}/result.
curl -H "X-Api-Key: $KEY" -F files=@big.html 'http://localhost:3000/v1/html?async=true'
Async results are kept in memory for PIDIEF_JOB_TTL. With several replicas, async jobs need sticky routing.
Errors
Errors are RFC 9457 application/problem+json responses with detail and requestId:
| Status | Meaning |
|---|---|
| 400 | invalid input |
| 401 | API key missing or wrong |
| 413 | request too large |
| 429 | queue full (with Retry-After) |
| 503 | no free slot in time |
| 504 | timeout |
Statelessness
The service is stateless: inputs and results stay in memory and documents are never written to disk.