Skip to content

HTTP API ​

The self-hosted image serves the web interface at / and this API. Everything runs on your server; nothing leaves it. If you have not started the container yet, that is one command:

bash
docker run -d -p 8080:8080 ghcr.io/alam00000/bentopdf-kura:latest

Your first request ​

Send the PDF as the raw request body; the converted PDF comes back as the response body.

bash
curl -o out.pdf --data-binary @in.pdf 'http://localhost:8080/api/convert?level=2b'

See what happened without opening the file:

bash
curl -s -o out.pdf -D - --data-binary @in.pdf \
  'http://localhost:8080/api/convert?level=2b' | grep -i '^x-kura'
x-kura-level: 2b
x-kura-engine: BentoPDF Kura Engine 1.1.0
x-kura-changes: 3

--data-binary matters: plain -d would mangle the bytes. A JPEG works as input too; it becomes a one-page document first.

POST /api/convert ​

Converts the document to the target and returns the result.

Query parameters ​

The names match the npm package options; every one maps to a CLI flag. A switch is on when its value is true, 1 or on; anything else, or leaving it out, means off. Text values may be up to 512 characters and may not contain line breaks or other control characters. Each option may be given once.

ParameterMeaning
levelrequired: 1b, 1a, 2b, 2u, 2a, 3b, 3u, 3a, 4, 4f, 4e, x1a, x3, x4, x6, e1, vt1, vt3, or none to apply a preset or colour conversion without a standard. The check-only flavours are refused here with BAD_LEVEL; use them with /api/check
pdfVersionwith none: the PDF version to write, 1.3 to 2.0
ua=trueadd PDF/UA on top of the level
langdocument language tag, for example en-US
allowVisualRisk=trueaccept repairs that may change appearance instead of rejecting
rasterizePages=truerasterize every page
rasterDpiresolution for rasterized pages, 24 to 1200; a plain number such as 150
outlineFonts=trueconvert text to outlines
imageMaxPpidownsample images above this resolution; a plain number such as 300
outputCondition, outputConditionInfo, registrythe PDF/X output intent
convertColorsconvert colour to cmyk, gray or rgb through ICC profiles; cmyk uses the uploaded destProfile when there is one. Profile names and file paths are not accepted over HTTP: upload the ICC file as destProfile instead. See converting colour
intentrendering intent: perceptual, relative, saturation or absolute
convertObjectslimit conversion to a comma list of text, vector, shading, images, lossy, lossless
keepSpots=truekeep spot colours and convert only their alternate
noBpc=trueturn off black point compensation
grayToK=true, rgbGrayToKput gray, and RGB within this many percent of neutral, on the black plate only
inkLimittotal ink coverage limit, 100 to 400 percent
vtRecordsPDF/VT record boundaries, for example 1-3,4-6
embedSource=true, embedSourceNameattach the original file to the result
attachXmlName, facturxProfilee-invoice attachment name and profile; facturxProfile is up to 32 letters, digits, spaces, _ or -, for example EN 16931
profilea bundled preflight profile to apply, by its id from /api/profiles, for example press/book-text-pages-check-and-fix
report=jsonreturn the JSON report with the PDF inside instead of raw bytes
passwordthe password of an encrypted input, as a form field when you cannot send the X-Password header; the header wins when both are sent. It is not read from the URL, because URLs end up in logs
dedupe=truethrough a coordinator: reuse the result of an identical recent job instead of converting again

Body ​

Either the document itself as the raw body, or multipart/form-data with these fields:

FieldMeaning
filethe document (required)
profilea preflight profile in JSON, when it is not one of the bundled ones
xmlan e-invoice XML to attach
destProfilean ICC profile for the output intent
defaultRgb, defaultCmyk, defaultGrayICC profiles for uncalibrated colour
deviceLinka device link profile to convert through

Any query parameter may also be sent as a text field, level included; when both are sent, the query string wins. A file field may be sent as a file part or as a text field holding the content. A profile sent as a text field is read as profile JSON, not as a bundled id: name a bundled profile with the profile query parameter, which takes precedence over a profile field.

What the API does not take ​

The API carries the options above and nothing else, so a request can never point the engine at a path on the server. In particular:

  • profile variables (--var, --var-file) cannot be set: a profile with variables runs with each variable's default;
  • colour profiles cannot be named by description or file name; upload the ICC file in a field;
  • ua1 and ua2 are not levels here; check PDF/UA with level=2u&ua=true or level=4&ua=true;
  • signing, OCR, font folders, batch and watch mode, and report files are CLI-only.

Headers ​

HeaderDirectionMeaning
X-Passwordrequestpassword for encrypted input
Authorization: Bearer <token>requestrequired when the server has KURA_API_TOKEN set (X-Api-Token works too)
X-Kura-Levelresponsethe level the file was converted to
X-Kura-Engineresponseengine name and version
X-Kura-Changesresponsehow many entries the report's issues list has
Content-Typeresponseapplication/pdf for a converted file, application/json for every report and error

With the report ​

report=json returns the same report the CLI prints, minus the file field, with the PDF base64-encoded in pdf:

bash
curl -s -F file=@in.pdf 'http://localhost:8080/api/convert?level=2b&ua=true&report=json' \
  | jq '{level, changes: (.issues | length), first: .issues[0]}'
json
{"level":"2b","changes":3,"first":{"code":"OUTPUT_INTENT_ADDED","detail":"sRGB IEC61966-2.1","fixed":true}}

Examples ​

An e-invoice, attaching the XML and producing PDF/A-3:

bash
curl -o invoice-a3.pdf -F file=@invoice.pdf -F xml=@invoice.xml \
  'http://localhost:8080/api/convert?level=3b'

Apply a bundled preflight profile's fixes:

bash
curl -o fixed.pdf --data-binary @in.pdf \
  'http://localhost:8080/api/convert?level=x4&profile=press/book-text-pages-check-and-fix'

Apply your own profile:

bash
curl -o fixed.pdf -F file=@in.pdf -F profile=@my-rules.json \
  'http://localhost:8080/api/convert?level=2b'

POST /api/check ​

Checks without changing anything and returns the report. The level may also be a check-only flavour (x4p, x5g, x5n, x5pg, x6n, x6p, vt2).

bash
curl -s --data-binary @in.pdf 'http://localhost:8080/api/check?level=2b'
json
{"ok":true,"level":"2b","engine":"BentoPDF Kura Engine 1.1.0","mode":"check","compliant":false,"findings":2,"issues":[...]}

Add analyze=true for the document analysis lines, or profile=<name> (or a profile field) to run a preflight profile; the findings arrive in analysis:

bash
curl -s -F file=@in.pdf 'http://localhost:8080/api/check?level=x4&profile=press/book-text-pages-check' \
  | jq '.analysis[] | select(.code=="CHECK_HIT") | .detail'

The HTTP status is 200 whether or not the file conforms; read compliant and findings. The body is the CLI's check report without the file field. Form fields work as for /api/convert, so -F file=@in.pdf -F profile=@my-rules.json checks against your own profile.

GET /api/profiles ​

Lists the bundled preflight profiles as [{id, name, description}], sorted by id. The id is the folder and file name without .json (for example press/book-text-pages-check), and is what profile= takes. The list is read once when the server starts. It needs no token.

bash
curl -s http://localhost:8080/api/profiles | jq -r '.[].id' | grep '^press/'

POST /api/verify-password ​

Send the encrypted PDF as the raw body (not a form) with X-Password; returns {"ok":true,"valid":true} or {"ok":true,"valid":false} without converting. true means /api/convert will accept the same password. A file that is not encrypted is valid: true with any password.

bash
curl -s --data-binary @locked.pdf -H 'X-Password: hunter2' http://localhost:8080/api/verify-password

GET /healthz ​

json
{"ok":true,"version":"BentoPDF Kura Engine (kura) 1.1.0","active":0,"queued":0}

active is jobs currently running, queued is jobs waiting for a slot. Wire it into your load balancer or uptime monitoring as is. It needs no token.

Other routes ​

RouteWhat it returns
GET /the converter page
GET /preflightthe preflight page
GET /docs/...a redirect to the same page of this documentation
anything else404 with errorCode NOT_FOUND

Every GET route also answers HEAD.

Authentication ​

With KURA_API_TOKEN set, every POST /api/... request needs Authorization: Bearer <token> or X-Api-Token: <token>; without it the answer is 401 UNAUTHORIZED. The pages, GET /api/profiles and /healthz stay open. On a coordinator, /status.json needs the token too.

bash
curl -o out.pdf -H 'Authorization: Bearer my-token' --data-binary @in.pdf \
  'http://localhost:8080/api/convert?level=2b'

Errors ​

Every error is a JSON body with ok: false, an errorCode and a plain-language error:

StatusCodeMeaningWhat to do
400BAD_LEVELunknown level, or a check-only level sent to /api/convertthe response lists valid ones in levels
400BAD_REQUESTan option is malformed (error names it, for example invalid value for rasterDpi), the engine refused the options, or no document was sentfix the request
400BAD_PROFILEno bundled profile with that idsee /api/profiles; the response's profiles field points there
400NOT_A_PDFthe body is neither a PDF nor a JPEGsend the file with --data-binary
401UNAUTHORIZEDtoken requiredsend Authorization: Bearer <token>
404NOT_FOUNDno such routecheck the method and path; the API routes are POST
413TOO_LARGEbody exceeds the upload limit; maxBytes gives the limitraise KURA_MAX_UPLOAD_MB
422the engine's codethe document was rejected; error says why and suggestedLevel names a level that would accept it. The body is the engine's full report, issues includedsee Rejection codes
429BUSYqueue fullretry with backoff, or raise KURA_QUEUE
500INTERNALthe server could not run the job or the engine produced no report; the server log has the detailcheck the log; please report it with the file
504TIMEOUTthe job exceeded the time limitraise KURA_TIMEOUT_MS

PASSWORD_REQUIRED is a 422 like any other rejection: send X-Password.

Limits and tuning ​

Concurrency, queue depth, upload size and the time limit are environment variables on the container. Defaults: 2 parallel jobs, a queue of 8, 500 MB uploads, 10 minutes per job. See Self-hosting.

Several machines ​

A coordinator answers this same API, with the work spread over its workers. Everything above applies unchanged; /healthz then counts the jobs running and waiting across all workers, and the coordinator adds:

RouteMeaning
GET /statusa status page: workers, queue, recent jobs
GET /status.jsonthe same as JSON: queued, running, done, failed, workers[] (each id, name, slots, running, version, lastSeenMs, alive), jobs[] (the latest 200, each id, name, kind, state, attempts, worker, origin api or hot-folder, created, updated, exitCode) and folders (needs the API token when one is set)

Dual-licensed under AGPL-3.0 and Commercial License.