Skip to content

/api/v1 reference

Every endpoint the phone app speaks — method, path, what it does and what it answers — read from the FastAPI app in ocrmd/web/v1.py, so it cannot drift from the code.

The machine-readable contract is openapi-v1.json; the app's TypeScript types are generated from it (cd mobile && npm run gen:api). How pairing and access work: docs/mobile.md. Every route needs Authorization: Bearer <device token> from another machine when the server runs with ocrmd serve --lan, except GET /api/v1/ping and POST /api/v1/pair; the devices routes answer only the computer ocrmd runs on.

Method Path What it does Body Answers
GET /api/v1/ping Open to anyone who can reach the port: says only that this is ocrmd and whether to pair. — Ping
POST /api/v1/pair Exchange a pairing code made on the computer (ocrmd pair) for this device's token. PairIn PairOut
GET /api/v1/me The device this request's token belongs to. — Device
GET /api/v1/server What this server can do: API version, access mode, whether pages get the model's reading now, OCR engines. — ServerInfo
GET /api/v1/devices Paired devices and pending codes. — list[Device]
POST /api/v1/devices/pairings A one-time code for a phone, with the link and QR code that carry it. PairingIn Pairing
DELETE /api/v1/devices/{device_id} Revoke a device (or cancel a pending code) by id or name. — Device
GET /api/v1/documents Every document in the library, with its catalogue entry and progress. — list[Document]
POST /api/v1/documents Start a new document before its first capture, so it has a title from the first page on. NewDocument Document
GET /api/v1/documents/{slug} One document with a row (and a thumbnail) per page. — DocumentDetail
GET /api/v1/search Full-text search over every page of every document (or of doc). — list[Hit]
GET /api/v1/documents/{slug}/pages/{seq} A page: its reconciled text, open disagreements, verdict, images and neighbours. — Page
PUT /api/v1/documents/{slug}/pages/{seq} A human edit: it survives the next verify. PageEditIn Page
GET /api/v1/documents/{slug}/pages/{seq}/image/{kind} A picture of the page: flat, processed, bin or raw; ?max= scales it down to a JPEG. — image/png | image/jpeg
POST /api/v1/documents/{slug}/pages/{seq}/resolve Settle one disagreement with the OCR reading, the model's, or your own text. ResolveIn Page
POST /api/v1/documents/{slug}/pages/{seq}/signoff Mark the page reviewed; refused (409) while a disagreement is open. SignOffIn Page
POST /api/v1/documents/{slug}/pages/{seq}/reopen Undo a sign-off. — Page
POST /api/v1/documents/{slug}/captures One photo from the phone's camera → a page (or two, for a spread), read twice like any other. multipart/form-data Job
POST /api/v1/documents/{slug}/verify Run the stages a document's pages are missing (the model pass for pages captured OCR-only). VerifyIn Job
GET /api/v1/jobs Recent jobs, newest first; active keeps the queued and running ones. — list[Job]
GET /api/v1/jobs/{job_id} A job's progress and, for a capture, what became of the photo (results). — Job

Models

  • CaptureResult — What became of one uploaded photo. file, client_id, pages, duplicate_of, rejected, error
  • CapturedPage — sequence, status
  • Device — id, name, platform, created_at, paired_at, last_seen_at, revoked_at, pending
  • Document — slug, title, author, year, kind, tags, project, pages, counts, done, flagged, unverified, needs_reshoot, page_labels, created_at, last_captured_at, scanning, cover
  • DocumentDetail — slug, title, author, year, kind, tags, project, pages, counts, done, flagged, unverified, needs_reshoot, page_labels, created_at, last_captured_at, scanning, cover, page_list
  • Flag — One open disagreement: ocr and llm are the two readings, context the text around the mark. n, ocr, llm, context
  • Hit — document, sequence, page_id, page_label, status, snippet, title
  • Job — id, kind, doc, status, created_at, started_at, ended_at, error, done, total, results, log
  • LogLine — at, level, line
  • NewDocument — slug, title?, author?, kind?, tags?, project?
  • Page — slug, sequence, id, status, page_label, part, width_px, advice, reviewed_by, llm_error, captured_at, agreement, overlap, body, flags, unresolved, images, context, frontmatter, prev, next, prev_flagged, next_flagged, exists
  • PageEditIn — body?, page_label?, context?
  • PageRef — document, sequence
  • PageRow — sequence, id, status, page_label, part, agreement, overlap, captured_at, reviewed_by, llm_error, thumb
  • PairIn — code, name, platform?
  • PairOut — token, device, server
  • Pairing — id, code, expires_at, server, link, qr_svg
  • PairingIn — name?
  • Ping — Is this an ocrmd server, which API does it speak, and does this request need (or carry) a token. ocrmd, api, version, access, local, paired
  • ResolveIn — n, chosen
  • ServerInfo — version, api, access, llm, provider, model, ocr_engines, scanning, sinks, formats
  • SignOffIn — who?
  • VerifyIn — refresh?, flagged_only?, no_llm?