Early access. Oomplo is looking for its first pilot companies. Tell us about your documents →

API

Base address: where Oomplo runs, e.g. http://127.0.0.1:3001. Requests and answers are JSON unless a PDF is returned. Errors are {"error": "…"} with a status code (400 wrong request, 404 unknown, 409 conflict, 422 the document cannot be made). Messages are in English (older ones, until they are rewritten, in Polish). The full reference: [oomplo.openapi.json](oomplo.openapi.json) (OpenAPI 3.0).

Authentication #

Once the server has an account, every request needs an API key. An administrator creates one in the page: account menu → API keys… → Create key (the key is shown once). Send it with every request:

Authorization: Bearer oomplo_…

A key can make PDFs (render, check, series jobs and their results, schemas, history, the list of templates); other paths answer 403. Each key has a limit of requests at a time (4 by default); more answer 429 with Retry-After: 1, so retry after a second. A revoked or wrong key answers

  1. Keep keys in your system's secret store, one key per system, so that you can revoke one without stopping the others.

A PDF from a published template #

POST /api/templates/{id}/render
Content-Type: application/json

{ "data": { "client": { "name": "Contoso Logistics S.A." } } }

Returns the PDF (application/pdf). Options:

FieldMeaning
dataThe data (a plain object is the main source json.dane1)
versionA kept version instead of the published one
strictRefuse (422) when the template has simplifications
sealSeal the PDF with the company seal (needs OOMPLO_SEAL_KEY and OOMPLO_SEAL_CERT on the server)
formatpdf (default) or docx: the filled Word document instead of the PDF
fieldsWith docx: text (default) or keep, the fields stay Word content controls showing the values, so the file is still a template
responsefile (default) or json: { "file": "<base64>", "contentType", "fileName", "pages", "warnings" } for tools that handle JSON better than files
missingerror (default): a value the data does not have stops the PDF with 422 naming every missing value at once; empty: such values are left empty

Response headers: X-Oomplo-Template-Version (the version used), X-Oomplo-Signature-Fields (see Signature fields), X-Oomplo-Warnings (number of simplifications) and X-Oomplo-License (valid; used=…; limit=…, over-limit; … or trial; …).

Check data before generating: POST /api/templates/{id}/validate with { "data": … } answers { "valid", "missing", "problems", "error" }: every missing value and every value of the wrong kind (a date, a number, an e-mail address, a picture) with its path, e.g. json.dane1.items[2].price, all at once and without making a PDF.

Template ids: GET /api/library lists templates with id and title. Give a template a fixed name in the template list (Name in the API) and call it by that name instead: POST /api/templates/invoice-vat/render.

Testing an integration. Create a test key (API keys → Test key). It may render the template's working copy ("draft": true), every PDF it makes carries the watermark "Oomplo – test key", and none counts against your licence. What data a template needs: GET /api/templates/{id}/schema (fields, arrays, signers, an example that fills every field and a jsonSchema, draft 2020-12, to validate or generate types in your system).

Archival and accessible PDF #

Add these fields to POST /api/templates/{id}/render, POST /api/render or a series job (POST /api/templates/{id}/jobs):

FieldValuesWhat you get
pdfa2b, 2u, 2a, 3b, 3u, 3aPDF/A (ISO 19005) for long-term archiving. Level b keeps the look, u also makes all text searchable, a also adds the document structure.
pdfuatruePDF/UA-1 (ISO 14289-1) for screen readers. The file gets headings, lists, tables with header cells, footnotes and links. Pictures get the alternative text you set in Word. The page header and footer are marked as artifacts. The title comes from the document's properties (File › Properties › Title in Word).
attachDatatrueThe data the document was filled with, attached as data.json. With pdfa, only PDF/A-3 can carry attachments. In a ZIP job, each PDF carries the data of its own row.

The look of the PDF does not change. If the document cannot meet the standard, the answer is 422 with the reason, for example a font that forbids embedding or a CMYK picture. An unknown level, or attachData with PDF/A-2, is 400. On the command line, use oomplo pdf template.docx --data invoice.xml --pdfa 3b --pdfua --attach-data --out invoice.pdf; the data file is attached as it is.

KSeF invoice visualization #

When the data is a KSeF invoice XML (FA(2) or FA(3)), it also contains $ksef, the verification code (KOD I) of the Polish Ministry of Finance:

  • $ksef.url is https://qr.ksef.mf.gov.pl/invoice/{seller NIP}/{P_1 as DD-MM-YYYY}/{SHA-256 of the file, Base64URL}; urlTest and urlDemo are the same link for the test environments;
  • $ksef.label is OFFLINE, because KSeF assigns the invoice number after the file is sent.

Send the invoice file itself as "dataXml": "<the XML file in base64>" instead of data (the code is computed from the file's exact bytes), with "attachData": true to attach that file as data.xml. Bind a QR code (Insert QR or barcode) to $ksef.url and put $ksef.label under it. When the invoice already has its KSeF number, pass the number in another data source and show it instead of the label. The hash is taken over the XML file exactly as you send it, so send the file KSeF received.

A template from filled documents #

If you have filled documents but no template, send 2 to 20 of them of one kind, for example the same contract for different clients:

POST /api/infer
{ "documents": [ { "name": "contract-alfa", "docx": "<base64>" }, { "name": "contract-beta", "docx": "<base64>" } ] }

Oomplo compares the documents and builds the template from what differs:

  • Text that differs becomes a data field. The field is named after the text before it, for example NIP: 526… gives nip.
  • A table whose rows differ in number gets a repeated row (pozycje[]). The header and total rows stay fixed, and the total becomes a field.
  • Paragraphs or tables that only some documents have become conditional blocks, with a true/false value for each document.

The answer contains three things:

  • template: the template as DOCX in base64. Open it in Word or upload it as a template.
  • datasets: the data of each document.
  • report: the fields, tables and conditions found. Its reproduced list says, for each document, whether the template filled with that document's data gives the document's text again.

The first document sets the look of the template. On the command line, use oomplo infer a.docx b.docx c.docx --out template.docx --data-dir data.

A series as a job #

For many PDFs at once (up to 1000 rows): send the rows as a file in base64, or as JSON right in the request: "series": { "name": "recipient", "rows": [{ "name": "…" }, …] }. A webhook (an http:// address) is told with a signed POST when the job ends, so you need not poll; send an Idempotency-Key header to make a retried request return the same job.

POST /api/templates/{id}/jobs
Content-Type: application/json

{
  "series": { "name": "recipient", "kind": "csv", "file": "<base64 of the CSV>" },
  "label": "{{json.recipient.name}}",
  "zip": true
}
  • series.name: the data source a row replaces (the template's fields read json.<name>.<column>); kind: xlsx, csv or json (sheet, headerRow for Excel; path of the array inside JSON).
  • series.mapping: when the file's columns have other names than the template's fields, { "field": "Column" } (e.g. { "lastName": "Nazwisko klienta" }). series.join (Excel): items from another sheet joined by a key, e.g. invoices and their lines: { "sheet": "Lines", "key": "No", "detailKey": "Invoice", "as": "items", "mapping": { "name": "Product" } }. Without them the job uses the mapping saved with the template in „Generate from a file”.
  • format: "docx" (and fields) gives a ZIP of filled Word documents.
  • rows ("1-3, 7"), label (file names and PDF bookmarks), zip (a PDF per row) or one PDF (duplex: each copy starts on an odd page), strict, seal, version.

Oomplo first fills the template with every row. If any row fails, the answer is 422 with the rows and their errors, and nothing is made. Otherwise the answer is 202 {"id": "…", "state": "running", "total": n}.

GET /api/jobs/{id}          → { "state": "running|done|failed", "done": 120, "total": 1000, "result": "/api/jobs/{id}/result", … }
GET /api/jobs/{id}/result   → the ZIP or the PDF

Results are deleted after OOMPLO_JOB_HOURS hours (24 by default). As a guide, 1000 one-page letters take under a second on a laptop.

History #

GET /api/history lists who made which PDF when: template, version, pages, rows, duration, warnings and the error, newest first. Filters: template, user, kind (render, job), status (ok, error), from, to (Unix time), limit. GET /api/history.csv gives the same as CSV for Excel. The history never contains your data or the PDFs; entries are deleted after OOMPLO_HISTORY_DAYS days (90).

Other endpoints #

  • POST /api/render makes a PDF from a DOCX sent in the request ({"docx": "<base64>", "data": {…}}) without storing a template.
  • POST /api/check gives the qualification report of a template (fonts, simplified elements, pages).
  • Templates are saved with PUT /api/library/templates/{id}; send the If-Match header with the rev you read (GET gives it), so that two people never overwrite each other (409 when someone saved in between).