checking…
API Docs →
🔥 PDF Processing API

PDF operations,
blazing fast.

A lightweight REST API to create, read, fill, flatten and enrich PDFs — with form-field support and embedded JSON metadata via XMP.

View API Docs → Health Check

Authentication

Required headers

All endpoints (except /health and this page) require the API key. Session endpoints additionally require X-Session-Token (returned on session create). For encrypted PDFs pass X-Pdf-Key.

curl -H "X-Api-Key: your-key" \
     -H "X-Pdf-Key: pdf-password" \
     -H "X-Session-Token: <token>" \
     https://formsonfire.corncreeker.com/...

Input formats

Every endpoint accepts both multipart/form-data and application/json with base64-encoded PDFs. Encrypted PDFs are auto-decrypted via X-Pdf-Key or PDF_KEY_DEFAULT.

# multipart
file=@document.pdf

# JSON base64
"pdf": "JVBERi0x..."
"password": "optional"

Endpoints

POST /pdf/metadata

Extract metadata from a PDF — title, author, page count, creation date and more.

JSON response read-only
POST /pdf/fields

Inspect all form fields in a PDF — name, type, current value and options.

JSON response read-only
POST /pdf/fill

Fill form fields by name. Supports text, checkboxes, radio buttons and dropdowns. Optional formulas object for server-side calculations (topological sort, no eval). Optional overrideReadOnly to write XFA computed fields. Returns calculatedFields when formulas used.

fields: {…} formulas?: {…} { pdf, calculatedFields? }
POST /pdf/flatten

Flatten a filled PDF — converts form fields into static content, making the document non-editable.

{ pdf: base64 }
POST /pdf/create

Create a blank PDF, optionally with custom text content. Returns a new PDF document.

text?: "…" { pdf: base64 }
POST /pdf/merge

Merge multiple PDFs into a single document. Send multiple files or a base64 array.

pdfs: […] { pdf: base64 }
POST /pdf/generate

Generate a structured PDF form from a JSON schema — define pages, fields, layout and types declaratively.

FormSchema { pdf: base64 }
POST /pdf/set-metadata

Set PDF document metadata fields (title, author, subject, keywords, creator, producer). Partial updates supported — only provided fields are changed. Works on encrypted PDFs via auto-decrypt.

meta: {title, author, …} { pdf: base64 }
POST /pdf/embed-metadata

Embed a JSON object as XMP metadata into a PDF using a custom namespace. Non-destructive — content is untouched.

json: {…} { pdf: base64 }
POST /pdf/read-metadata

Read back the embedded JSON metadata from a PDF's XMP stream. Returns the original JSON object.

JSON response read-only
POST /pdf/signatures

Check which signature fields in a PDF are signed. Returns per-field status and an allSigned boolean. Optional ?fieldPattern= query param to match custom field names.

JSON response read-only ?fieldPattern=sig.*
POST /pdf/render/screenshot

Render a PDF page as a PNG image. Returns the image as base64. Optional ?page= query param (default: 1).

?page=1 { image: base64 }
POST /pdf/attachments/list

List all embedded file attachments in a PDF — returns filename and size for each. Attachments are separate from XMP metadata.

JSON response read-only
POST /pdf/attachments/read

Read a named embedded file attachment from a PDF. Returns the file content as base64. Required: filename.

filename: "…" { name, size, data } read-only
POST /pdf/attachments/write

Embed a file as a PDF attachment (upsert — replaces if name already exists). Mime-type is guessed from file extension. Returns updated PDF.

filename, data: base64 { pdf: base64 }
GET /health

Health check endpoint. No API key required. Returns {"status":"ok"}.

public JSON response

Session Pipeline — stateful multi-step workflow

Load a PDF once, fill in multiple steps, finalize at the end — no base64 ping-pong. Every session is tenant-isolated via a one-time X-Session-Token.

POST /session

Upload a PDF to create a new session. Returns a unique sessionId and a one-time sessionToken — keep it, it's your key to this session.

pdf: base64 { sessionId, sessionToken } 201
GET /session/:id/fields

Read all form fields from the current session PDF. Same response as /pdf/fields.

X-Session-Token read-only
POST /session/:id/fill

Fill fields in the session PDF. Supports formulas and overrideReadOnly. Can be called multiple times. Returns calculatedFields. Does NOT flatten.

X-Session-Token fields, formulas? { calculatedFields? }
POST /session/:id/finalize

Flatten the session PDF (fields → static content) and return the final base64 PDF. Session becomes read-only after this.

X-Session-Token { pdf: base64, finalized: true }
GET /session/:id

Get session status, op history and current PDF. Useful for debugging multi-step workflows.

X-Session-Token read-only
DEL /session/:id

Discard a session and free its memory. Good practice after finalize.

X-Session-Token { discarded: true }

Ops & Monitoring

In-memory structured operation log with suspicious-pattern detection. Resets on restart. Max 500 entries (configurable via OP_LOG_MAX_ENTRIES).

GET /ops/summary

Aggregated stats: total ops, count by operation type, suspicious call count and the last 10 suspicious entries.

{ total, by_op, suspicious_count }
GET /ops/log

Filterable operation log. Query params: ?op=fill, ?suspicious=true, ?limit=20, ?since=ISO.

?op= ?suspicious= ?limit= ?since= { entries }
DEL /ops/log

Clear the in-memory log store. Useful before a test run to get a clean baseline.

{ cleared: true }