headless.md
Documentation Index
Fetch the complete documentation index at: https://filecheck.io/docs/llms.txt Use this file to discover all available pages before exploring further.
Headless API integration
Submit files straight to POST /jobs — no widget — and collect results synchronously, by polling, or by webhook.
Use the REST API alone when there is no browser in the flow: files arrive from your own upload pipeline, a batch process, email, or another system. Your server submits each file as a job with the ordered steps to run on it, then collects the result.
[!NOTE]
If a customer uploads the file in a page you control, prefer embedding the Element — you get the drop zone, progress, findings, and auto-fix UI for free, and only the verification happens server-side. This page is for flows with no widget at all.
Every request in this flow is server-to-server, authenticated with your secret key as a bearer token. Never call these endpoints from the browser.
1. Get the file to Filecheck
A job source can reference the file three ways:
| Source | Use when |
|---|---|
url |
The file is already reachable over HTTP(S). Pass optional headers (e.g. Authorization) if the URL needs them. |
file |
Small files only — inline base64, capped at roughly 9 MB of encoded content. Add name as a filename hint. |
fileRef |
Large files, up to 500 MB. Create an upload first (below) and pass the returned reference. |
For fileRef, mint presigned upload credentials with POST /uploads:
curl https://api.filecheck.io/uploads \
-H "Authorization: Bearer sk_live_…" \
-H "Content-Type: application/json" \
-d '{ "mimeType": "application/pdf", "sizeBytes": 48211234 }'
The response contains a fileRef plus a presigned S3 form POST (upload.url and upload.fields). POST the file there as multipart/form-data within 300 seconds, then use the fileRef as your job source.
2. Submit the job
POST /jobs is the canonical submission: each entry in sources[] is one file plus the ordered steps[] to run on it. A common print flow checks the file, auto-fixes what it can, and re-checks:
curl https://api.filecheck.io/jobs \
-H "Authorization: Bearer sk_live_…" \
-H "Content-Type: application/json" \
-d '{
"sources": [{
"url": "https://example.com/artwork.pdf",
"steps": [
{ "type": "preflight" },
{ "type": "autofix" },
{ "type": "repreflight" }
]
}],
"policy": { "onFail": "reject" },
"webhook": { "url": "https://example.com/hooks/filecheck" },
"metaData": { "orderRef": "SO-1042" }
}'
Steps run sequentially per source, each feeding its output to the next; steps incompatible with the file's detected type are recorded as skipped. Available step types include preflight, autofix, repreflight, validate, previews, optimize, convert, upscale, removebg, and deliver — see the API reference for each step's parameters. A job accepts up to 50 sources; each source becomes its own task under the job. metaData (up to 4 KB) is echoed back on responses and webhook callbacks, so use it to carry your own correlation ids.
For the common cases you can skip composing steps and call a sugar wrapper, which builds them for you:
| Endpoint | Runs |
|---|---|
POST /jobs/preflight |
Preflight only. |
POST /jobs/fix |
Preflight + autofix, plus a re-check with repreflight: true. |
POST /jobs/optimize |
Optimize only. |
POST /jobs/validate |
PDF/A / PDF/UA conformance validation. Synchronous by default. |
POST /jobs/previews |
Render preview images. |
3. Collect the result
Jobs are asynchronous by default — POST /jobs returns 201 immediately with the job id. Pick whichever result channel fits your flow:
Wait synchronously. Set sync: true on the submission to hold the connection up to ~27 seconds. You get 200 with the completed job, or 202 with pending: true if it is still running (fall back to polling or the webhook). Good for small files in a request/response cycle. (POST /jobs/validate is the inverse: synchronous by default, async: true to detach.)
Poll. Fetch the job until it reaches a terminal status (ready, partial, or rejected):
curl "https://api.filecheck.io/jobs/{jobId}?expand=runs" \
-H "Authorization: Bearer sk_live_…"
Webhook. Pass a per-job webhook on submission (as in the example above, with optional headers for authenticating the callback), or configure account-level webhooks in the admin to receive job.created / job.completed for every job. Either way, fetch the full job when the callback arrives rather than trusting the payload alone.
4. Read the outcome and download the output
?expand=runs returns a flattened per-file summary — one entry per source — with the verdict and download links:
{
"runs": [{
"id": "task_…",
"name": "artwork.pdf",
"outcome": "pass",
"status": "done",
"hasOutput": true,
"downloadUrl": "https://…",
"proofs": [{ "url": "https://…" }]
}]
}
outcome is pass, warn, or fail per file; how warnings and failures roll up into the job's final status is controlled by the policy.onFail you submitted (reject, accept_with_warnings, or manual_review). When a step produced a fixed or converted file, hasOutput is true and downloadUrl is a short-lived link to it. Omit expand to get the full job object with per-task step detail instead.