API manual
Jason Tools Document Toolbox exposes a RESTful API. Every tool has an endpoint, ready to plug into automation, your own systems or scheduled jobs.
Basic principle: the API is open by default (matching the web UI); to lock it, an administrator turns on enforce mode on the admin “API Token” page and issues bearer tokens.
Authentication disabled (default)
A new installation has authentication off, so every /api/* endpoint works straight away without a token.
Enabling API tokens
An administrator goes to admin → API Token:
- Press "issue a new token" → give it a purpose (for example
gitlab-ci) → receive a 64-character hex token (shown once only; keep it safe) - Tick “Enforce; refuse anything without a token” and save
From then on every /api/* call must carry one of these:
Authorization: Bearer 64char-hex-token-here
or as a query string:
GET /api/jobs/abc123?token=64char-hex-token-here
Missing or invalid token → 401 Unauthorized JSON:
{"ok": false, "detail": "需要有效的 API token(Authorization: Bearer ...)"}
Tokens are managed from admin /
jtdtManaged from the CLI, entirely separate from web authentication (jtdt-admin/ LDAP / AD).
2. Common conventions
| Item | Description |
|---|---|
| Base URL | http://your-server:8765 (depends on JTDT_HOST / JTDT_PORT ; the examples below use localhost:8765) |
| Content-Type | File uploads: multipart/form-data; JSON: application/json |
| Authentication header | -H "Authorization: Bearer YOUR_TOKEN" (may be omitted while enforce is off) |
| Response format | JSON (unless it explicitly returns PDF / PNG / ZIP binary data) |
| Error format | {"detail": "錯誤訊息"} plus the matching HTTP 4xx/5xx |
| Large files | Large or slow operations use job mode: the call first returns {"job_id": "..."}, you poll /api/jobs/{job_id}, and once it is done you fetch the result from /api/jobs/{job_id}/download |
Each endpoint below includes
curlexamples. Endpoints that return a file use--output 檔名to save it; endpoints that return JSON can be piped through| jqto pretty-print it.
Office to PDF
Convert an office document to PDF (via the OxOffice / LibreOffice engine).
POST /api/convert-to-pdf
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | Office document |
curl -X POST http://localhost:8765/api/convert-to-pdf \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@報告.docx" \
--output 報告.pdf
Response: the PDF itself (application/pdf). On failure, 4xx plus JSON {"detail": "..."}.
Office format conversion
Converts between formats of the same kind: word processing ↔ word processing, spreadsheet ↔ spreadsheet, presentation ↔ presentation. Job mode; returns job_id.
Ask which target formats are available before submitting a conversion. The values of target differ from one installation to another (without the Impress module there is no presentation group), so do not hard-code the ids in your own program:
GET /tools/office-convert/formats
curl -s http://localhost:8765/tools/office-convert/formats \
-H "Authorization: Bearer YOUR_TOKEN" | jq
# → {"families": [{"id": "text", "name": "文書檔",
# "sources": ["odt", "docx", ...],
# "targets": [{"id": "docx-2007", "ext": "docx",
# "label": "Word 2007", "note": "...",
# "common": true}, ...]}, ...]}
POST /tools/office-convert/convert
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | Office document; may be repeated (several files come back as a ZIP) |
target | str | ✓ | The target format id, taken from formats above |
Files in one request must all be of the same kind (a spreadsheet and a word-processing file cannot be mixed) and must match the kind that target belongs to, otherwise the call returns 400.
# 文書檔:.odt 轉成 Word 97–2003
curl -X POST http://localhost:8765/tools/office-convert/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@報告.odt" -F "target=doc" | jq
# → {"job_id": "...", "download_url": "/api/jobs/.../download"}
# 簡報:.pptx 轉成 ODF 簡報
curl -X POST http://localhost:8765/tools/office-convert/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@簡報.pptx" -F "target=odp" | jq
.docx / .xlsx / .pptx each offer two targets; the difference is the Compatibility mode is more than just a name:
| Target id | Produces | Compatibility mode |
|---|---|---|
docx-2007 | Word 2007 format | 12 |
docx-365 | Word 2010; 365 format | 15 |
xlsx-2007 / xlsx-ooxml | Excel 2007–365 / Office Open XML | — |
pptx-2007 / pptx-ooxml | PowerPoint 2007–365 / Office Open XML | — |
Response: {"job_id": "...", "download_url": "..."}. One file comes back in the target format, several come back as a ZIP. On failure, 4xx plus JSON {"detail": "..."}.
Images to PDF
Combine one or more images into a single PDF.
POST /tools/image-to-pdf/api/image-to-pdf
| Parameter | Type | Required | Description |
|---|---|---|---|
files | file (repeatable) | ✓ | PNG / JPG / GIF / TIFF / WebP / HEIC |
page_size | str | A4 (default) / A3 / A5 / B5 / Letter / Legal / Tabloid / original | |
margin_mm | float | Margin (mm), default 0 | |
rotations | str | Rotation for each image as CSV, in upload order, e.g. 0,90,0 | |
filename | str | Output filename |
curl -X POST http://localhost:8765/tools/image-to-pdf/api/image-to-pdf \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "files=@p1.jpg" -F "files=@p2.png" \
-F "page_size=A4" -F "margin_mm=5" \
--output album.pdf
Response: PDF binary.
PDF to images
Converts each page of a PDF or office document to PNG / WebP / JPEG (multiple pages are bundled into a ZIP). The size can be set by DPI or by a fixed width (every page is scaled to the same width; the height follows the page's proportions).
POST /tools/pdf-to-image/convert
GET /tools/pdf-to-image/download/{upload_id}
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | PDF or office document (anything that is not a PDF is converted to PDF first) |
format | string | Output format: png (default) / webp / jpeg (jpg is accepted too); any other value returns 400 | |
width | int | Width of every page in pixels (16 to 10000); when given, dpi is ignored. Out of range returns 400 rather than quietly using a different width | |
dpi | int | Resolution used when width is not given; default 200, range 72 to 600 | |
quality | int | WebP / JPEG quality, 1 to 100, default 80; PNG is lossless and ignores it |
A page over 40 million pixels (or, in WebP, over 16383 px on either side, a limit of the format itself) is output smaller; that page has reduced set to true, and the top-level reduced_pages lists which pages.
# 1. 上傳並轉換(網頁用:WebP、寬 1920)
curl -X POST http://localhost:8765/tools/pdf-to-image/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@slides.pdf" -F "format=webp" -F "width=1920" | jq
# → {"upload_id": "...", "page_count": 3, "format": "webp", "size_mode": "width",
# "width": 1920, "dpi": null, "reduced_pages": [], "pages": [{"width_px": 1920, ...}]}
# 依 DPI 轉 PNG
curl -X POST http://localhost:8765/tools/pdf-to-image/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" -F "dpi=200" | jq
# 2. 下載
curl -s http://localhost:8765/tools/pdf-to-image/download/abc123 \
-H "Authorization: Bearer YOUR_TOKEN" --output pages.zip
Response: step 1 returns each page's details (width_px / height_px / dpi / size_bytes / reduced) and the upload_id; step 2 returns the images: a single image in the chosen format for one page, or a ZIP for several (each page named like slides_p1.webp).
PDF to Office
Turns a PDF back into Word (.docx) or OpenDocument (.odt). Job mode; returns job_id.
POST /tools/pdf-to-office/convert
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
output_format | str | docx (default) / odt | |
engine | str | Conversion engine: pdf2docx-refine (default, stable) / jtdt-reform (our own layout rebuild) / jtdt-layout (layout reproduction: precise import through LibreOffice/OxOffice Draw, then rebuilt by our own engine) | |
enable_postprocess | bool | Only applies to pdf2docx-refine: whether to run the jtdt-refine post-processing (25 fixers), default false |
# 預設引擎 pdf2docx-refine
curl -X POST http://localhost:8765/tools/pdf-to-office/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@form.pdf" -F "output_format=docx" \
| jq
# → {"job_id": "...", "download_url": "/api/jobs/.../download"}
# 改用自家 jtdt-reform 引擎
curl -X POST http://localhost:8765/tools/pdf-to-office/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@form.pdf" -F "output_format=odt" -F "engine=jtdt-reform" \
| jq
# 改用 jtdt-layout 版面重現引擎(表單 / 多欄 / 含框線表格版面最接近原 PDF)
curl -X POST http://localhost:8765/tools/pdf-to-office/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@form.pdf" -F "output_format=odt" -F "engine=jtdt-layout" \
| jq
Response: {"job_id": "...", "download_url": "..."}; then poll and fetch with the job API in chapter 10.
Getting before/after thumbnails: once the job finishes, meta.preview in GET /api/jobs/{job_id} contains page_indices (the 0-based pages to preview: all of them for ≤ 6 pages, otherwise the first 2, middle 2 and last 2), orig_pages, result_pages, orig_chars and result_chars. For the thumbnails themselves:
GET /tools/pdf-to-office/preview/{job_id}/orig/{page} # 轉換前(原 PDF)
GET /tools/pdf-to-office/preview/{job_id}/result/{page} # 轉換後(docx/odt 渲染)
page is a 1-based page number (the page_indices element plus 1), returning image/png。
# 完成後讀 preview 頁碼清單
curl -s http://localhost:8765/api/jobs/$JOB \
-H "Authorization: Bearer YOUR_TOKEN" | jq '.meta.preview'
# 取第 1 頁的前 / 後對照縮圖
curl -s http://localhost:8765/tools/pdf-to-office/preview/$JOB/orig/1 \
-H "Authorization: Bearer YOUR_TOKEN" --output before_p1.png
curl -s http://localhost:8765/tools/pdf-to-office/preview/$JOB/result/1 \
-H "Authorization: Bearer YOUR_TOKEN" --output after_p1.png
PDF to Markdown
Extract a PDF as Markdown. A single call returns the content directly, without job mode.
POST /tools/pdf-to-markdown/api/pdf-to-markdown
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
include_images | bool | Whether to output the embedded images as well, default false | |
page_separator | bool | Insert a separator between pages, default true | |
image_format | str | Image format png (default) or jpg; only applies when include_images=true |
# 只要文字:回 text/markdown
curl -X POST http://localhost:8765/tools/pdf-to-markdown/api/pdf-to-markdown \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@report.pdf" --output report.md
# 連圖片一起:回 ZIP(.md + 圖片檔)
curl -X POST http://localhost:8765/tools/pdf-to-markdown/api/pdf-to-markdown \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@report.pdf" -F "include_images=true" --output report.zip
The response type depends on include_images: false returns text/markdown, true returns application/zip
Markdown to office document
Turns Markdown into PDF / Word / OpenDocument. The content can be uploaded as file or passed directly as text.
POST /tools/markdown-to-doc/api/markdown-to-doc
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | △ | A Markdown file. Use this or text |
text | str | △ | The Markdown content itself. Use this or file |
format | str | pdf (default) / docx / odt. Any other value returns 400 | |
theme | str | Layout theme, default classic. Valid values: classic / github / academic / book / report / mono / teal / indigo / forest / coral / navy-gold / magazine. An unknown value falls back to classic | |
font | str | Font, default default | |
title | str | Document title |
# 檔案轉 PDF
curl -X POST http://localhost:8765/tools/markdown-to-doc/api/markdown-to-doc \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@notes.md" -F "format=pdf" --output notes.pdf
# 直接帶內容轉 Word
curl -X POST http://localhost:8765/tools/markdown-to-doc/api/markdown-to-doc \
-H "Authorization: Bearer YOUR_TOKEN" \
--form-string "text=# 標題
內文。" -F "format=docx" --output notes.docx
Returns the file itself, not JSON. A format other than pdf / docx / odt returns 400.
PDF to slides
Turns a PDF back into PowerPoint (.pptx) or an OpenDocument presentation (.odp), one page per slide, keeping the original slide size (portrait PDFs are reproduced too). Job mode; returns job_id.
There is only one engine (jtdt-layout layout reproduction), so there is no engine parameter.
POST /tools/pdf-to-slides/convert
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
output_format | str | pptx (default) / odp |
curl -X POST http://localhost:8765/tools/pdf-to-slides/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@deck.pdf" -F "output_format=pptx" \
| jq
# → {"job_id": "...", "download_url": "/api/jobs/.../download"}
# 輸出 OpenDocument 簡報(物件多時比 .pptx 快)
curl -X POST http://localhost:8765/tools/pdf-to-slides/convert \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@deck.pdf" -F "output_format=odp" \
| jq
Before-and-after thumbnails work the same as for pdf-to-office:
GET /tools/pdf-to-slides/preview/{job_id}/orig/{page} # 轉換前(原 PDF)
GET /tools/pdf-to-slides/preview/{job_id}/result/{page} # 轉換後(簡報渲染)
Once the job finishes, meta.stats in GET /api/jobs/{job_id} contains pages (the number of slides), images and objects (the total object count).
Environment requirement: the office suite's Impress module(
oxoffice-impress/libreoffice-impress). Without the module you only see "converted successfully but no output found"; check it under "settings → dependency check".
Merge PDFs
Merge several PDFs into one, in upload order.
POST /tools/pdf-merge/api/pdf-merge
| Parameter | Type | Required | Description |
|---|---|---|---|
files | file (repeatable) | ✓ | two or more PDFs |
curl -X POST http://localhost:8765/tools/pdf-merge/api/pdf-merge \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "files=@a.pdf" -F "files=@b.pdf" -F "files=@c.pdf" \
--output merged.pdf
Response: the merged PDF.
Split PDF
Split a PDF by page count or ranges.
POST /tools/pdf-split/api/pdf-split
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
mode | str | each (default, one file per page) / ranges (by range, one file per range) | |
ranges | str | The ranges when mode=ranges, e.g. 1-3,5,7-9 (each range becomes one file) |
curl -X POST http://localhost:8765/tools/pdf-split/api/pdf-split \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@big.pdf" -F "mode=ranges" -F "ranges=1-3,8-10" \
--output parts.zip
Response: the resulting PDFs (several come back as a ZIP).
PDF page operations
Delete, extract or reorder pages.
POST /tools/pdf-pages/api/pdf-pages
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
mode | str | ✓ | keep (keep only) / delete (delete) / reorder (reorder) |
spec | str | ✓ | Page specification, e.g. 1,3,5-8 |
curl -X POST http://localhost:8765/tools/pdf-pages/api/pdf-pages \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" -F "mode=keep" -F "spec=1,3,5-8" \
--output picked.pdf
Response: the processed PDF.
Rotate PDF
Rotate selected pages.
POST /tools/pdf-rotate/api/pdf-rotate
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
angle | int | 90 (default) / 180 / 270, clockwise | |
mode | str | Replaces angle when given: rotate-90 / rotate-180 / rotate-270 / flip-h (mirror left-right) / flip-v (mirror top-bottom) | |
pages | str | Pages to apply to, e.g. 1,3-5; all or empty = all pages | |
per_page | str | Per-page settings (a JSON object, pages from 1), e.g. {"2": "flip-h", "5": "none"}; none = leave that page alone. Takes precedence over mode / pages |
curl -X POST http://localhost:8765/tools/pdf-rotate/api/pdf-rotate \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@scan.pdf" -F "angle=90" -F "pages=1-4" \
--output rotated.pdf
Response: the rotated PDF.
Add page numbers
Add page numbers at a chosen position.
POST /tools/pdf-pageno/api/pdf-pageno
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
position | str | br (bottom right, default) / bc (bottom centre) / bl / tl / tc / tr (t = top, b = bottom, l / c / r = left / centre / right) | |
fmt | str | Format template: {n} is the current page number and {N} the total ({total} works the same as {N}), e.g. Page {n} / {n} / {N} | |
start | int | Starting page number, default 1 | |
from_page / to_page | int | Number only the pages in this range (1-based; to_page=0 means up to the last page; default all pages); {N} counts only the pages in the range | |
font_size | float | Font size, default 11 | |
margin_mm | float | Margin (mm) | |
color | str | Text colour as hex, e.g. #000000 |
curl -X POST http://localhost:8765/tools/pdf-pageno/api/pdf-pageno \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@report.pdf" -F "position=bottom-center" \
-F "fmt=第 {n} / {N} 頁" -F "start=1" \
--output numbered.pdf
Response: the numbered PDF.
PDF page borders
Draw a border on every page. Accepts PDF and word processing files (office documents are converted to PDF first); the output is always PDF.
POST /tools/pdf-border/api/pdf-border
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | PDF or word processing file |
mode | str | page (inset from the page edge, default) / content (flush with that page's content) | |
margin_mm | float | Margin (mm), default 5 | |
width_pt | float | Line width (pt), default 1.5 | |
color | str | Border colour as hex, default #333333 | |
style | str | solid (default) / dashed / dotted | |
radius_mm | float | Corner radius (mm), default 0 (square corners) | |
opacity | float | Opacity 0; 1, default 1 | |
double | bool | Double border (certificate style), default false | |
double_gap_mm | float | Gap between the two lines of a double border (mm), default 1.5 | |
shadow | bool | Outer shadow, default false | |
shadow_color | str | Shadow colour as hex, default #000000 | |
shadow_blur_mm | float | Shadow spread (mm), default 1.2 | |
shadow_offset_mm | float | Shadow offset (mm), default 0.6 | |
shadow_opacity | float | Shadow density 0; 1, default 0.25 | |
pages | str | Specific pages, e.g. 1,3,5-8; blank = all | |
skip_first | bool | No border on the first page (a slide cover is often a full-bleed design), default false |
curl -X POST http://localhost:8765/tools/pdf-border/api/pdf-border \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@slides.pptx" -F "mode=page" -F "margin_mm=4" \
-F "width_pt=2" -F "color=#1e293b" -F "skip_first=true" \
--output slides_border.pdf
Response: the bordered PDF. Every value is clamped to a safe range on the server.
PDF bookmarks and contents
Adds bookmarks to a PDF (the navigation panel on the left of the reader) and a clickable table of contents page. Several files are joined automatically, with each file name becoming a first-level bookmark; bookmarks inside each document move one level down and are kept. Accepts PDFs and office documents (office documents are converted to PDF first).
POST /tools/pdf-bookmark/api/pdf-bookmark
| Parameter | Type | Required | Description |
|---|---|---|---|
files | file[] | ✓ | One or more PDF / office files; several are joined in order |
bookmarks | str | Supply the bookmarks yourself (a JSON array of {"title","page","level"}). If given, this replaces the automatically generated ones | |
auto | bool | Detect headings automatically from the font size, default false (only applies with no bookmarks and a single file) | |
toc_page | bool | Insert a table of contents page, default false. The web interface has this ticked by default, while the API keeps false so that existing automated calls do not suddenly gain a page | |
toc_at | int | Insert the contents before this page, default 1 (right at the front). With a cover page, use 2 | |
toc_title | str | Table of contents title, default Contents | |
toc_max_level | int | How many levels the contents lists (1; 3), default 3 | |
toc_dots | bool | Draw dot leaders between titles and page numbers, default true |
Bookmark levels must start at 1 and may only go one level deeper at a time (1→3 is corrected to 1→2), and a page number beyond the end of the document is clamped to the last page; both are corrected automatically rather than failing. Page numbers shift on their own once a contents page is inserted, so there is nothing to work out by hand; bookmarks before toc_at are left untouched (the one pointing at the cover is still page 1).
# 多檔串接 + 以檔名建書籤 + 產生目錄頁
curl -X POST http://localhost:8765/tools/pdf-bookmark/api/pdf-bookmark \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "files=@投標須知.pdf" -F "files=@規格書.pdf" -F "files=@價格標.pdf" \
-F "toc_page=true" \
--output 標案文件.pdf
# 單檔 + 自己指定書籤
curl -X POST http://localhost:8765/tools/pdf-bookmark/api/pdf-bookmark \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "files=@report.pdf" \
-F 'bookmarks=[{"title":"第一章","page":1,"level":1},{"title":"1.1 背景","page":3,"level":2}]' \
--output report_bm.pdf
Response: the bookmarked PDF.
PDF seam stamp
Split one stamp across consecutive pages; if any page is swapped or lost, that slice no longer lines up. Accepts PDF and office files.
POST /tools/pdf-seam-stamp/api/pdf-seam-stamp
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | A PDF or office document, at least 2 pages |
stamp | file | Your own stamp image (PNG / JPG; a near-white background is removed automatically). Without one the system generates a stamp | |
text | str | The text on a generated stamp, default 騎縫章 (up to 4 characters, laid out in a square) | |
shape | str | circle (default) / square / rect | |
color | str | Stamp colour as hex, default #c81414 | |
mode | str | side (side seam, default) / spread (across a spread) | |
group | int | How many pages one stamp spans, default 2; 0 = one stamp for the whole document | |
edge | str | Which edge to place it on in side mode: right (default) or left | |
size_mm | float | Stamp size (mm), default 40 | |
offset_mm | float | Distance from the page edge (mm), default 3 | |
pos_mm | float | Vertical position (mm), 0 = centred | |
angle_deg | float | Angle, default 0 | |
opacity | float | Density 0; 1, default 1 | |
jitter_pos | bool | Randomise the height of each group, default false | |
jitter_angle | bool | Randomise the angle of each group (up to ±8 degrees), default false | |
seed | int | Random seed; 0 = random |
The whole stamp is rotated before it is sliced; the other way round (slice first, rotate each piece) leaves seams that do not line up. Within one group the position and angle of every slice are identical, otherwise the pieces do not fit back together.
curl -X POST http://localhost:8765/tools/pdf-seam-stamp/api/pdf-seam-stamp \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@contract.pdf" -F "text=節省" -F "group=3" \
-F "mode=side" -F "size_mm=45" -F "jitter_angle=true" \
--output contract_seam.pdf
Response: the PDF with the seam stamp.
Scan cleanup
Straightens documents that were photographed or scanned at an angle, trims dark borders and evens out uneven background. For phone photos it finds the four corners of the sheet and corrects the perspective. No AI and no GPU involved (classical image processing; about 0.8 s per page on CPU at 200 dpi).
POST /tools/doc-straighten/api/doc-straighten
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | PDF, an image (including HEIC from a phone) or an office document |
dpi | int | Processing resolution: 150 / 200 (default) / 300 | |
binarize | bool | Convert to black and white. Off by default: measurements show it erases thin Chinese strokes and clearly lowers OCR accuracy; its purpose is a smaller file, not clearer text | |
detect_quad | bool | Detect the sheet edges and correct the perspective (on by default). Falls back to straightening only when the edges cannot be found | |
enhance | bool | Clean up: flatten uneven background and shadows (on by default). Measured on a phone photo with a hard one-sided shadow, text recognition went from 0.472 to 0.982; scans that are already even are left bit-for-bit identical | |
size_w / size_h / size_unit | str | Output page size; size_unit is px (default) or mm; empty or invalid = the straightened size |
curl -X POST http://localhost:8765/tools/doc-straighten/api/doc-straighten \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@scan.pdf" -F "dpi=200" \
-o straightened.pdf -D -
# 回應標頭:
# X-Straighten-Pages: 12
# X-Straighten-Worst-Residual: 0.10 ← 修正後殘留的歪斜角(越接近 0 越好)
X-Straighten-Worst-Residual is the acceptance figure: if the rotation went the wrong way the reported angle still looks like something happened; only the residual reveals it. It should stay within 0.2 degrees.
The web interface runs it as a background job: POST /tools/doc-straighten/load to upload, POST /tools/doc-straighten/submit to start (returns a job_id), poll GET /api/jobs/{job_id}, then fetch the result from GET /api/jobs/{job_id}/download. Per-page preview is POST /tools/doc-straighten/preview, which returns the correction angle and the residual.
Unify PDF page size
Bring mixed page sizes onto one paper size. The content stays vector (text is still selectable) rather than being turned into images.
POST /tools/pdf-page-size/api/pdf-page-size
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | PDF or word processing file |
paper | str | a3 / a4 (default) / a5 / b4 / b5 / letter / legal / tabloid / custom | |
custom_w_mm custom_h_mm | float | paper=custom width and height (mm) when | |
orientation | str | auto (follow the original page, default) / portrait / landscape | |
fit | str | scale (scale to fit, default, nothing is lost) / center (centre without scaling; anything outside is cropped) / crop (scale up to fill) | |
align | str | center (default) / top-left | |
keep_same | bool | Leave pages that are already the target size untouched, default true |
curl -X POST http://localhost:8765/tools/pdf-page-size/api/pdf-page-size \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@tender.pdf" -F "paper=a4" -F "orientation=auto" -F "fit=scale" \
--output tender_a4.pdf
Response: the resized PDF.
PDF N-up
Fit several pages onto one sheet (2-up, 4-up …).
POST /tools/pdf-nup/api/pdf-nup
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
cols | int | Columns per sheet, default 2 | |
rows | int | Rows per sheet, default 1 (cols × rows at most 64) | |
paper | str | a4 (default) / a3 / a5 / b4 / b5 / letter / legal / custom | |
paper_w_mm / paper_h_mm | float | paper=custom width and height (mm) when | |
orientation | str | auto (default) / portrait / landscape | |
margin_mm | float | Margin on all four sides (mm), default 10 | |
gap_mm | float | Space between cells (mm), default 5 | |
direction | str | ltr (across, then down; default) / ttb (down, then across) | |
reverse | bool | Reverse order, default false | |
auto_rotate | bool | Rotate original pages to fill each cell, default true | |
page_align | str | Where the original page sits in its cell: center (default) / left-top | |
show_border / border_width_pt / border_color | bool / float / str | Cell borders; defaults: off, 0.5 pt, #94a3b8 | |
show_page_num / page_num_format / page_num_size_pt | bool / str / float | Print the original page number in each cell ({n} = original page number, {t} = total pages); defaults: off, {n}, 8 pt | |
pad_blanks | bool | Fill the last sheet with blank cells, default true | |
show_crop_marks / crop_mark_len_mm | bool / float | Crop marks; defaults: off, 4 mm |
Numbers are clamped to sensible ranges; margins and gaps can never squeeze the cells to nothing.
curl -X POST http://localhost:8765/tools/pdf-nup/api/pdf-nup \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@slides.pdf" -F "cols=2" -F "rows=2" \
-F "paper=A4" -F "orientation=landscape" \
--output 4up.pdf
Response: the N-up PDF.
Compress PDF
Make a PDF smaller.
POST /tools/pdf-compress/api/pdf-compress
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
preset | str | gentle (light) / balanced (default, balanced) / aggressive (smallest) |
curl -X POST http://localhost:8765/tools/pdf-compress/api/pdf-compress \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@large.pdf" -F "preset=balanced" \
--output small.pdf
Response: the compressed PDF.
Scan merge
Detect the areas with content in several scans (both sides of an ID, say), keep their original colour and compose them onto one white A4 PDF. layout decides the arrangement: by default each block keeps its relative position from the original scan (overlaps are not rearranged), or blocks are arranged automatically so they do not overlap (use the web page if you need to drag to fine-tune).
POST /tools/scan-merge/api/scan-merge
| Parameter | Type | Required | Description |
|---|---|---|---|
files | file (repeatable) | ✓ | Scans; PDF / PNG / JPG / TIFF / WebP, one block of content each |
whiten | bool | Whether to lift a pale grey or yellowish scan background to pure white (colour content is unaffected), default true | |
filename | str | Output file name, default scan-merge.pdf | |
layout | str | Layout: original (default, original positions, may overlap) or auto (laid out in upload order, top to bottom and left to right, without overlapping; scaled down proportionally when they do not fit). Any other value returns 400 |
curl -X POST http://localhost:8765/tools/scan-merge/api/scan-merge \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "files=@id-front.jpg" -F "files=@id-back.jpg" \
-F "whiten=true" -F "layout=auto" \
--output id-merged.pdf
Response: a single white A4 PDF binary.
Returns 422 when none of the files has a detectable content block (an all-white page, say, or an all-black one from scanning with the lid open). That is not a problem with the request format: there is nothing in the images to assemble, and the message says which case it is.
Extract PDF text
Extract all text from a PDF (broken CMaps and OCR double layers are handled automatically).
POST /tools/pdf-extract-text/api/pdf-extract-text
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ |
curl -X POST http://localhost:8765/tools/pdf-extract-text/api/pdf-extract-text \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" | jq
JSON response: text per page plus the whole document.
Extract PDF images
Extract every image embedded in a PDF.
POST /tools/pdf-extract-images/api/pdf-extract-images
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ |
curl -X POST http://localhost:8765/tools/pdf-extract-images/api/pdf-extract-images \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" \
--output images.zip
Response: the images as a ZIP.
Extract PDF attachments
List or extract files embedded in a PDF.
POST /tools/pdf-attachments/api/pdf-attachments
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ |
curl -X POST http://localhost:8765/tools/pdf-attachments/api/pdf-attachments \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@with_attachments.pdf" \
--output attachments.zip
Response: the attachment list plus contents (ZIP).
PDF metadata
Read or clear PDF metadata, XMP, bookmarks, annotations and form fields.
POST /tools/pdf-metadata/api/pdf-metadata
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
clear_info | bool | Clear document info (author / title / producer …) | |
clear_xmp | bool | Clear XMP metadata | |
clear_toc | bool | Clear bookmarks / contents | |
clear_annots | bool | Clear annotations | |
clear_forms | bool | Clear form fields |
curl -X POST http://localhost:8765/tools/pdf-metadata/api/pdf-metadata \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" -F "clear_info=true" -F "clear_xmp=true" \
--output cleaned.pdf
Response: without any clear_* flag it returns the metadata as JSON; with a flag it returns the cleaned PDF.
PDF word count
Count pages, characters, words, reading time and frequent terms.
POST /tools/pdf-wordcount/api/pdf-wordcount
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | A PDF, an office document (.doc / .docx / .odt / .xls / .xlsx / .ods / .ppt / .pptx / .odp) or plain text (.txt / .md / .csv / .log / .json / .xml / .html) |
Office documents are converted to PDF before counting; that is the only way the page count and the words per page match what actually prints. This endpoint therefore needs an Office engine (OxOffice / LibreOffice) when it is given an office document.
curl -X POST http://localhost:8765/tools/pdf-wordcount/api/pdf-wordcount \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" | jq
JSON response (excerpt):
{
"filename": "document.pdf",
"page_count": 12,
"char_count": 18342,
"word_count": 3521,
"estimated_reading_minutes": 12.5,
"per_page_chars": [/* ... */],
"top_words_zh2": [/* ... */], "top_words_en": [/* ... */]
}
Meeting recording to transcript
Turns a meeting recording or video into a transcript with timings and speakers. Recognition runs on the external speech service (JTLW), so it has to be set up under the admin area's speech service (JTLW) page first; without that it returns 503.
POST /tools/meeting-transcribe/api/meeting-transcribe
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | Audio .m4a / .mp3 / .wav / .aac / .ogg / .opus / .flac, video .mp4 / .mov / .mkv / .webm |
language | string | auto (the default) or BCP-47 (zh-Hant / en / ja / ko …). When the speech service does not support it, at submission time it returns 400 right away. zh / zh-TW are converted to zh-Hant before sending. | |
num_speakers | string | Defaults to 0, which lets it decide for itself. Leaving it at 0 is the recommendation | |
terms | string | Terms or meeting background (optional): attendee names, company and product names, terms, one per line or separated by enumeration commas / commas / semicolons; known misheard spellings as one line "misheard spelling → correct spelling"; you can also write a few sentences of meeting background |
Terms (since v1.16.39) are sent to the speech service as a glossary used in correction: correct spellings are kept as written, and misheard spellings that are close are changed to yours (since speech service interface version 2.8, punctuation-only correction does this too). One term per line works best (Proxmox, PVE and Proxmox VE on separate lines); words misheard as something spelled very differently may not be fixed. Recognition does not use this list: the speech service measured that when a listed word does not occur in the meeting, recognition inserts it into the transcript anyway, so it is not used. Duplicates (ignoring case) keep only the first, in the order you gave. At most 500; more returns 400 and is never silently truncated (truncated terms would not be used, while the caller would think they were sent).
Known misheard spellings (since v1.16.49): if you already know how a word gets misheard, write one line "misheard spelling → correct spelling" (the arrow can also be -> or =>; separate several misheard spellings with enumeration commas or commas), for example Proksmox、Proxmux → Proxmox. The speech service replaces them as listed before correction: no language model is involved, it happens at every correction level, and the raw recognition layer is unchanged; misheard words spelled very differently, which correction cannot recognise, can only be fixed this way. English must match as a whole word and ignores case; Chinese matches literally, so a very short Chinese misheard spelling may be replaced inside other words; make it specific. The correct spelling is also sent as a term. The rules follow the speech service: at most 20 misheard spellings per term, each 2–200 characters; only one term to the right of the arrow (enumeration commas, commas, semicolons, |, / or a / with a space on either side separate terms; TCP/IP is one term); a misheard spelling must not be another term on the list (replacing it would change correctly written text; a list line written as Proxmox VE / PVE counts as the two terms Proxmox VE and PVE); the same misheard spelling must not point to two terms. A line that breaks these returns 400 naming the line and is not sent. Lines with two or more arrows, lines starting with # and sentences are still meeting background. Only speech service interface version 2.9 and later accept them; with an older version (or when the version cannot be read) they are not sent and variants_sent in the response is false.
Lines written as sentences are not sent as terms (since v1.16.44): a line with a full stop, exclamation or question mark, or with a piece longer than 40 characters / 10 Han characters, is treated as meeting background. A whole sentence as a term is pointless: correction would keep it as written and match spellings against it. For a line like "Attendees: Wang Xiaoming, Bianca" the label before the colon is not sent and the rest is sent as a list; a line that is only a label ("Attendees are:") is not sent; heading lines starting with # and pieces with no letters at all (dates, times, plain numbers) are not sent either (v1.16.48). The full text is in the response's context and goes into the meeting background when the transcript is sent to Meeting summary.
Which speaker-separation method is used depends on the speech service version (from v1.16.31): when the speech service is on interface version 2.5 or later, this system asks for NVIDIA Nemotron; on 2.4 or earlier (or when the version can't be read) the original method is used. The response field speaker_engine shows which one this job requested. The speech service measured both on the same real recognition output with no speaker count given: speaker errors fell from 18.52% to 2.92% on 20 Chinese meetings and from 12.31% to 4.65% on 16 English meetings.
The same num_speakers means opposite things under the two methods:
Nemotron (speaker_engine = auto) | Original method (legacy) | |
|---|---|---|
| The number you give | Only an upper limit: speakers are merged only if more are found; fewer are left as they are | Forces exactly that many groups |
| Higher than the real count | No effect | Splits the main speakers apart |
| Lower than the real count | Merges different people into one speaker | Merges different people into one speaker |
| Advice | Leave 0 if unsure; err on the high side | Leave 0 if unsure; don't count people who say only a sentence or two |
Under Nemotron, giving the correct count instead of none differs by only 0.01 percentage points (20 meetings, 95% confidence interval [−0.03, 0.00]). That only shows it is no worse; don't fill it in expecting better accuracy.
The new method separates at most 8 speakers. If you specify more than 8, the speech service always falls back to the original method; if you don't, it falls back only when the new method fills all 8 slots and the original method finds more than 8 speakers, otherwise it keeps the new method with at most 8 speakers. When it falls back, the reason is in the response fields diarization.reason (code) and diarization.note (explanation). For meetings you know have more than 8 speakers, specify the number.
auto only listens to about the first 30 seconds of speech and uses that language for the whole meeting; it does not decide per segment. If someone speaks another language at the start (20 seconds is enough), the whole meeting may be recognised wrongly; silence or background noise at the start does not matter. When you know the language of the whole meeting, set it. For meetings where whole sentences alternate between Chinese and English, set the language used most: whole sentences in the other language are mostly not recognised correctly (English terms inside Chinese sentences are fine).
This endpoint is synchronous: a 37-minute meeting measured 7 to 8 minutes (recognition plus speaker separation plus correction), so give the caller a generous timeout. For background processing use the web path instead (POST /upload → POST /start → poll /api/jobs/{id} with the job id).
| Status | Meaning | What to do |
|---|---|---|
| 400 | File format not accepted, empty file, too many terms, a malformed misheard-spelling line, or the speech service rejected a parameter you sent (language / num_speakers / terms) | Change the parameter; if you are unsure of the language, use auto |
| 502 | The speech service accepted the job but it failed (recognition failed, the result was empty, or the service itself errored) | The message gives the reason; if it keeps happening, ask an administrator to check the speech service |
| 503 | The speech service is not set up yet, or cannot be reached | Ask an administrator to check the “Speech service (JTLW)” settings and connection |
| 504 | No result after too long (queued for more than 4 hours, or recognition exceeded the limit) | The job has already been cancelled on the speech service; send it again later |
curl -X POST http://localhost:8765/tools/meeting-transcribe/api/meeting-transcribe \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@meeting.m4a" \
-F "language=auto" \
-F "num_speakers=0" \
-F "terms=王小明、Bianca、Proxmox VE" | jq
JSON response (excerpt):
{
"source": {"filename": "meeting.m4a", "size_bytes": 17823213},
"remote_job_id": "job_01M34PVW581P2QD3Q0YFT5Y903",
"status": "succeeded",
"uncorrected": false,
"diarize_skipped": false,
"speaker_engine": "auto",
"diarization": {"requested": "auto", "engine": "nemotron", "note": null, "reason": null},
"diarize_fallback": null,
"diarize_saturated": false,
"terms": ["王小明", "Bianca", "Proxmox VE"],
"glossary": {"entries": 3, "keep_terms": 3, "asr_bias_terms": 0, "variants": 0},
"variants": {},
"variants_sent": false,
"asr": {"model": "large-v3-turbo", "location": "gpu_server", "device": "cuda"},
"context": "第四季備份規劃會議。\n王小明\nBianca\nProxmox VE",
"layers": {"raw": 1045, "final": 1045, "speakers": 1045},
"tasks": ["transcribe", "diarize", "correct"],
"summary": {"correction_level": "punctuation_only",
"correction": {"edited": 612, "variant_replacements": 0}},
"upload_id": "3f9c0a1e5b7d4c2a9e8f6b1d0c3a5e7f",
"retry_until": 1790000000.0,
"segments": [
{"seq": 1, "text": "各位早,我們開始。", "speaker": "S1",
"start_ms": 1450, "end_ms": 2650}
]
}
segments is three layers merged: the text comes from the corrected layer, the timings from the raw recognition layer and the speakers from the speakers layer, matched by seq. Segments that do not line up are not forced together: better to leave a segment without a speaker than to put somebody else's name on it.
uncorrected is true means the correction step failed, and what you get back is the raw recognition output (punctuation and misrecognitions unrepaired); do not compare it as though it had been corrected.
diarize_skipped is true means the recognition mode used this time does not separate speakers (for example, the Taiwanese mode). In that case segments has no speaker field, and num_speakers is not sent to the speech service. What a recognition mode can do follows the list the speech service provides, and it is checked before each submission.
In the response, speaker_engine is the separation method this job requested (auto is Nemotron, legacy is the original method, and null when no separation was done), and diarization is the speech service's report of which one it actually used (only from interface version 2.5; null on older versions). When auto was requested but engine is legacy, note gives the reason (for example, more than 8 speakers were specified).
In the response, diarize_fallback is set only when Nemotron was requested but the original method was used, and is null otherwise: reason is the speech service's code (interface version 2.6 and later) and text is the explanation this system picks for that code. When the code is unknown or the speech service gave none, text is a general sentence and note carries the speech service's own wording.
When diarize_saturated in the response is true, all 8 slots of the new method (Nemotron) were used: there may be more speakers, and some of them will have been merged into someone else. If you know there are more than 8, resend with num_speakers (the speech service only reports this from interface version 2.7; older versions always give false).
terms in the response is the cleaned list of terms sent for this job, and glossary is how the speech service used them: entries received, keep_terms kept as written, asr_bias_terms used in recognition (normally 0: recognition does not use them; it is above 0 only when the speech service's GPU server is unavailable and recognition runs on the service host). With no terms, terms is an empty array and glossary is null. context is the original text of the terms field (including sentences not treated as terms), or an empty string. asr in the response is the recognition model reported by the speech service (model), where it ran (location: gpu_server or api_host) and on what device (device); it exists from speech service interface version 2.8, and is null on older versions or when recognition failed.
variants in the response are the misheard spellings written for this job ({"Proxmox": ["Proksmox", "Proxmux"]}, an empty object when none), and variants_sent says whether they were actually sent to the speech service (only interface version 2.9 and later accept them; when false, the transcript was not replaced as listed). The number of replacements is in summary.correction.variant_replacements, and how many misheard spellings the speech service accepted is in glossary.variants (both also since 2.9).
speaker is a code (S1 / S2…). Mapping those to names is up to the caller; on the web path you can click a code and rename it.
Add terms and re-run only the correction
If a name or term turns out to be wrong after transcription, you can add terms and re-run only the correction (from v1.16.41): recognition is not re-run, seq, times and speakers stay the same, and only the text is replaced by the new correction.
After the transcript is saved, the speech service keeps its copy for up to 24 hours so you can re-run (administrators can shorten this on the "Speech service (JTLW)" settings page; 0 = delete as soon as it is saved, no re-runs), and is then asked to delete it. In the response, retry_until is the latest time a re-run is possible (UNIX seconds; null when it is not possible), and upload_id is the ID the two calls below take.
POST /tools/meeting-transcribe/retry
| Parameter (JSON) | Type | Required | Description |
|---|---|---|---|
upload_id | string | ✓ | The upload_id from the synchronous API response |
terms | string or string[] | ✓ | Terms (the whole list, not only the new ones, including the misheard spellings; the speech service replaces the previous list with this one); same rules as when submitting |
Returns {"job_id": "…"}; poll /api/jobs/{id}, then fetch the new transcript with GET /tools/meeting-transcribe/result/{upload_id} (retry.count is how many times it has been re-run).
A re-run changes only the correction; recognition is not re-run. For words misheard as something spelled very differently, which correction cannot recognise, include a line "misheard spelling → correct spelling" (replaced as listed from speech service interface version 2.9).
| Status | Meaning |
|---|---|
| 400 | No terms given, too many terms, or a malformed misheard-spelling line |
| 409 | Cannot re-run: the speech service has already been asked to delete its copy (the window has passed, or "No more changes" was pressed), this recognition mode has no correction, less than 15 minutes are left, or a re-run is already in progress. The message says which. |
| 503 | The speech service is not configured yet |
curl -X POST http://localhost:8765/tools/meeting-transcribe/retry \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"upload_id": "UPLOAD_ID", "terms": ["王小明", "Bianca", "Proxmox VE", "Proksmox → Proxmox"]}'
When no more re-runs are needed, ask the speech service to delete its copy now (the transcript here is not affected):
POST /tools/meeting-transcribe/done
curl -X POST http://localhost:8765/tools/meeting-transcribe/done \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"upload_id": "UPLOAD_ID"}'
Returns {"ok": true, "acked": true}. acked is false when the speech service cannot be reached right now; it will be notified again automatically.
Meeting summary
Turns a meeting transcript into a summary, decisions, action items, risks and chapters, with a segment number on every entry.
POST /tools/meeting-summary/api/meeting-summary
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | Transcript: .vtt / .srt / .json / .txt / .md / .docx / .odt |
second_pass | string | 1 (default) runs the second review pass;0 first pass only: faster, but both misses and false positives go up | |
context | string | Meeting background (optional, up to 4000 characters): the topic, attendees and their roles, terminology, or anything else you want to tell the model | |
replacements | string | Spellings to replace before the analysis (optional): a JSON array [{"from": "Bianka", "to": "Bianca"}], usually picked from the suggestions of /api/term-suggestions below. Anything that is not a JSON array returns 400 |
context is used only to make sense of the transcript; it never becomes a source of items. Knowing that someone is the VP of Operations and chairs the meeting helps decide who is delegating and who is the owner, but what you write in the background did not happen in the meeting — decisions, actions, risks and open questions are always drawn from the transcript. Besides saying so in the prompt, two mechanisms enforce it: citation verification (an item must point back to transcript segments, and the background is not part of what is compared), and dropping anything that closely matches the background and matches it noticeably better than it matches the transcript. Dropped items are counted in dropped_count.
This endpoint is synchronous; a two-hour meeting takes several minutes (roughly 30-60 model requests), so raise the caller's timeout. For background processing use the web path instead (POST /upload to POST /start, then poll the job id with /api/jobs/{id}).
The LLM must be enabled in the admin area first; if it is not, this returns 503. A transcript that cannot be read returns 400 (the message says which formats are supported).
Timestamps are optional: for a plain-text transcript with no times, the summary, decisions and action items still work, but speaker_stats comes back empty and charts will not contain speaker_share or timeline; both are computed from the times, and a guessed number would be worse than none.
curl -X POST http://localhost:8765/tools/meeting-summary/api/meeting-summary \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@meeting.vtt" \
--form-string 'context=會議主題:第四季預算
與會者
王小明:財務部經理,會議主席
李美華:法務專員' | jq
JSON response (excerpt):
{
"summary": { "text": "這場會議確認了第四季的預算…",
"grounded": true, "unsupported": [] },
"items": {
"decisions": [
{ "text": "第四季預算維持原案", "segment_ids": [18, 19] }
],
"actions": [
{ "text": "月底前把修訂版寄給法務", "owner": "李美華",
"due_text": "月底", "segment_ids": [42] }
],
"risks": [], "questions": [], "impacts": []
},
"chapters": [
{ "title": "預算討論", "start_seq": 1, "end_seq": 60,
"start_ms": 0, "end_ms": 840000, "duration_ms": 840000,
"segment_ids": [1, 2, 3], "percentage": 38.5 }
],
"mindmap": [
{ "node_id": "c1", "parent_id": null, "label": "預算討論",
"type": "topic", "segment_ids": [1] }
],
"charts": ["timeline", "topic_share", "speaker_share", "mindmap"],
"speaker_stats": {
"王小明": { "speaking_ms": 512000, "percentage": 61.2,
"turn_count": 24, "average_turn_ms": 21333,
"chars": 4210, "char_pct": 58.3, "first_seq": 1 }
},
"dropped_count": 3,
"llm_calls": 41,
"context": "會議主題:第四季預算\n與會者\n王小明:財務部經理,會議主席\n李美華:法務專員",
"source": { "filename": "meeting.vtt", "segments": 186 }
}
In the summary, grounded means the numbers and Latin-script words in the summary can all be found in the transcript; any that cannot are listed in unsupported (whether the wording is faithful can only be judged by a person, with the segment numbers).
The context in the response is the meeting background that was sent (with leading and trailing spaces removed); the field is absent when none was sent. Documents exported from the web page carry it verbatim after the title and before the summary.
dropped_count Yes the number of entries dropped because their citation did not match the transcript Everything extracted has to be findable in the segment it claims; if it is not, it is not kept. A high number here means the model is inventing, and changing the model helps more than tuning parameters.
Fixing proper nouns in the transcript from the meeting background
Transcripts often get names wrong (Bianca written as Bianka, or a Chinese name written with a same-sounding character). When the meeting background has the right spelling, this endpoint finds the places in the transcript that are probably misspelled. It only suggests: it changes nothing and stores nothing, and it does not need an LLM:
POST /tools/meeting-summary/api/term-suggestions
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | Transcript (same formats as above) |
context | string | Meeting background; without it there are no suggestions |
curl -X POST http://localhost:8765/tools/meeting-summary/api/term-suggestions \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@meeting.vtt" \
-F "context=與會者:王小明(財務長)、Bianca(PM)" | jq
{
"terms": ["王小明", "Bianca"],
"suggestions": [
{"from": "Bianka", "to": "Bianca", "count": 2, "seqs": [2],
"example": "報價我已經寄給 Bianka 了,Bianka 會再確認。"},
{"from": "王曉明", "to": "王小明", "count": 1, "seqs": [1],
"example": "王曉明今天要報告第四季的預算。"}
]
}
The matching rules are fixed and err on the side of suggesting less: in English, one or two letters off, or an extra space or hyphen in the middle; in Chinese, three to eight characters where every character has a matching pronunciation (same sound, different character). Differences only in case, singular and plural forms, two-character words, spellings the background itself uses, and spellings that could be either of two terms are never suggested.
Put the ones you pick into replacements of /api/meeting-summary and they are applied before the analysis: English is replaced as whole words (Biankas is not cut into), and the response gains replacements (what was actually replaced and how many times; pairs that matched nothing are left out). The .json exported from the web page carries the transcript, where each changed segment keeps its original text in orig_text.
Spellings the suggestions do not catch (when recognition misheard too much, e.g. Groxmoxity for Proxmox) can go into replacements yourself; the same rules apply. English replacement is case-sensitive, so add a separate pair to also replace the lowercase groxmoxity.
curl -X POST http://localhost:8765/tools/meeting-summary/api/meeting-summary \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@meeting.vtt" \
-F "context=與會者:王小明(財務長)、Bianca(PM)" \
--form-string 'replacements=[{"from": "Bianka", "to": "Bianca"}]' | jq '.replacements'
# → [{"from": "Bianka", "to": "Bianca", "count": 2}]
PDF OCR
Run OCR on a scanned PDF and add a selectable text layer.
POST /tools/pdf-ocr/api/pdf-ocr
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
lang | str | Language, e.g. chi_tra+eng (default) / eng / chi_sim | |
dpi | int | Render resolution, default 300 | |
skip_pages_with_text | bool | Skip pages that already have a text layer, default true |
curl -X POST http://localhost:8765/tools/pdf-ocr/api/pdf-ocr \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@scan.pdf" -F "lang=chi_tra+eng" -F "dpi=300" \
| jq
# → {"job_id": "...", "upload_id": "...", "download_url": "/api/jobs/.../download"}
Response: a job_id (OCR runs in the background). Poll it with the job API in chapter 10, then download the PDF with its new text layer from download_url. The first run downloads the recognition models, so allow extra time.
External GPU OCR server
An administrator can deploy jt-ocr-server to a GPU host from admin/ocr-langs → external GPU recognition server; jtdt then calls remote EasyOCR over HTTP, more than 10× faster than CPU. The related admin endpoints:
GET /admin/ocr-langs/deploy/install.sh # 下載安裝腳本
GET /admin/ocr-langs/deploy/uninstall.sh # 下載解除安裝腳本
GET /admin/api/ocr-langs/external/status # 讀取目前設定
POST /admin/api/ocr-langs/external/save # 儲存 URL / Token / Timeout / 啟用
POST /admin/api/ocr-langs/external/test # 測試連接
Once enabled, /tools/pdf-ocr/* and any tool that calls EasyOCR internally use the remote GPU, falling back to the local machine if the connection fails. jt-ocr-server's own endpoints:
GET /healthz # 不需 token,回 GPU/VRAM 資訊
GET /version # 需 Bearer token
POST /ocr # 需 Bearer token,multipart image + langs form
PDF annotation report
List every annotation in a PDF (page, type, author, content, coordinates, time).
POST /tools/pdf-annotations/api/pdf-annotations
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ |
curl -X POST http://localhost:8765/tools/pdf-annotations/api/pdf-annotations \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@reviewed.pdf" | jq
JSON response: full detail for each annotation.
Remove PDF annotations
Remove PDF annotations (filtered by type or author).
POST /tools/pdf-annotations-strip/api/pdf-annotations-strip
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
types | str | Remove only these types, as CSV (Highlight / Text / FreeText …); blank = remove everything | |
authors | str | Only these authors, as CSV; blank means all | |
mode | str | Processing mode |
curl -X POST http://localhost:8765/tools/pdf-annotations-strip/api/pdf-annotations-strip \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@reviewed.pdf" -F "types=Highlight,Text" \
--output clean.pdf
Response: the cleaned PDF.
Flatten PDF annotations
Burn annotations into the page content stream (the recipient cannot remove them; form fields stay fillable).
POST /tools/pdf-annotations-flatten/api/pdf-annotations-flatten
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ |
curl -X POST http://localhost:8765/tools/pdf-annotations-flatten/api/pdf-annotations-flatten \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@annotated.pdf" \
--output flattened.pdf
Response: the flattened PDF.
PDF hidden content scan
Scan a PDF for hidden content that could leak (metadata, covered text, layers, attachments …).
POST /tools/pdf-hidden-scan/api/pdf-hidden-scan
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ |
curl -X POST http://localhost:8765/tools/pdf-hidden-scan/api/pdf-hidden-scan \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" | jq
JSON response: what was found in each category.
Encrypted Paper Backup
There is deliberately no create or restore API: encryption, key splitting, PDF generation, QR reading and restoring all happen in the browser, and the server never sees the content, the key or the shares (no endpoint ever receives a secret). Only the following non-secret endpoints exist.
GET /paper-backup/offline
GET /paper-backup/offline.json
POST /tools/paper-backup/audit
GET /paper-backup/offline: download the offline restore tool (a single HTML file that works by double-clicking, no network needed). Requires sign-in when login is enabled, but not permission for this tool; the content is fixed for a given version and language, and the response headerX-JTDT-SHA256is its SHA-256. The language follows the interface language.GET /paper-backup/offline.json: the offline restore tool'sfilename、size、sha256。POST /tools/paper-backup/audit: after the browser finishes creating or restoring, record one audit entry (paper_backup_create/paper_backup_restore). Only these fields are accepted; any other field (such as a title, content or shares) returns 400:
| Field | Description |
|---|---|
action | create / restore |
backup_id | Backup ID (16 lowercase hex characters) |
t / n | Threshold and number of shares (2 ≤ t ≤ n ≤ 16) |
mode / density / blocks | create only: paper (fixed), low / medium / high, number of main-document blocks (1–2000) |
ok | restore only: whether the restore succeeded |
curl -OJ http://localhost:8765/paper-backup/offline \
-H "Authorization: Bearer YOUR_TOKEN"
Fill a PDF form
Detect form fields automatically and fill them from a company profile.
POST /tools/pdf-fill/api/pdf-fill
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | The form to fill in (PDF or office document) |
company_id | str | Company profile id (created by an administrator; see the list below); empty = the currently selected one. An unknown company returns 400; another company's data is never used instead | |
font_id | str | Font id for the filled text, default auto |
curl -X POST http://localhost:8765/tools/pdf-fill/api/pdf-fill \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@vendor_form.pdf" -F "company_id=acme" \
--output filled.pdf
Response: the filled PDF.
List the companies you can use (ids and names only, no field data):
GET /tools/pdf-fill/api/companies
curl -s http://localhost:8765/tools/pdf-fill/api/companies \
-H "Authorization: Bearer YOUR_TOKEN" | jq
# → {"companies": [{"id": "acme", "name": "範例股份有限公司", "is_active": true}, ...]}
is_active is the one used when no company_id is given.
Stamp / sign a PDF
Overlay a stamp or signature image on a PDF.
POST /tools/pdf-stamp/api/pdf-stamp
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
stamp_image | file | Stamp or signature image (a transparent PNG works best). Use either this or asset_id | |
asset_id | str | Use a stamp, signature or logo from the asset library instead (ask an administrator for the id: Asset management in the admin area, or GET /admin/api/assets). Use either this or stamp_image | |
x_mm | float | X position of the bottom-left corner (mm) | |
y_mm | float | Y position of the bottom-left corner (mm) | |
width_mm | float | Width (mm) | |
height_mm | float | Height (mm) | |
rotation_deg | float | Rotation, default 0 | |
page_mode | str | all (per page) / first / last, default all | |
pages_json | str | Specific pages: a JSON array of 0-based page numbers (such as [0,2,4]). When present it overrides page_mode; page numbers out of range are ignored | |
placements_json | str | Per-page positions (optional). A JSON array in which each object carries its own page number and coordinates → different pages can use different positions, and one page can hold several. When present it overrides x_mm / y_mm / width_mm / height_mm / rotation_deg / page_mode / pages_json; when absent the behaviour is exactly as before |
curl -X POST http://localhost:8765/tools/pdf-stamp/api/pdf-stamp \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@contract.pdf" -F "stamp_image=@chop.png" \
-F "x_mm=150" -F "y_mm=30" -F "width_mm=30" -F "height_mm=30" \
-F "pages_json=[0,2]" \
--output stamped.pdf
Response: the stamped PDF.
When the position fields are omitted: with asset_id the stamp goes where that asset is set up in the library; with an uploaded image the defaults are 105 / 250 / 30 / 30 mm.
# 用資產庫裡的公司大章,位置照資產庫的設定
curl -X POST http://localhost:8765/tools/pdf-stamp/api/pdf-stamp \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@contract.pdf" -F "asset_id=ASSET_ID" \
--output stamped.pdf
Stamps applied through the API are saved to the Stamp and signature history just like the web version (the original and the stamped file, which auditors can review); an uploaded stamp image is not stored separately, only its fingerprint is recorded.
Per-page positions (placements): suited to multi-page contracts and renewals, where each page signs in a different spot and one page may need several signatures.
| placement fields | Type | Required | Description |
|---|---|---|---|
page | int | ✓ | 0-based page number; anything beyond the document is skipped |
x_mm / y_mm | float | ✓ | Position (mm) |
width_mm / height_mm | float | Size (mm), default 30×30 | |
rotation_deg | float | Rotation, default 0 | |
asset_id | str | Use a particular stamp from the asset library at this position (omit it to use the stamp_image or asset_id above). If every position has its own asset_id, no image upload is needed |
# 第 1 頁蓋 2 處、第 3 頁蓋 1 處,第 2 頁不蓋
curl -X POST http://localhost:8765/tools/pdf-stamp/api/pdf-stamp \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@policy.pdf" -F "stamp_image=@sign.png" \
-F 'placements_json=[
{"page":0,"x_mm":40,"y_mm":250,"width_mm":20,"height_mm":20},
{"page":0,"x_mm":150,"y_mm":100,"width_mm":20,"height_mm":20},
{"page":2,"x_mm":100,"y_mm":150,"width_mm":25,"height_mm":25}]' \
--output stamped.pdf
PDF watermark
Add a text watermark.
POST /tools/pdf-watermark/api/pdf-watermark
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
text | str | ✓ | Watermark text |
opacity | float | Opacity 0.05–1, default 0.25 | |
rotation_deg | float | Rotation angle, default 30 | |
mode | str | tile (tiled, default) / single (a single one) | |
page_mode | str | all (every page, default) / first (first page only) / last (last page only) | |
text_color | str | Text colour as hex | |
text_size_pt | float | Font size (pt) |
curl -X POST http://localhost:8765/tools/pdf-watermark/api/pdf-watermark \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" -F "text=機密" \
-F "opacity=0.12" -F "mode=tile" \
--output watermarked.pdf
Response: the watermarked PDF.
PDF editor
Burn text, images, shapes and masks into a PDF from an overlay JSON model (including genuine redaction).
POST /tools/pdf-editor/api/pdf-editor
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | The original PDF |
model | str (JSON) | ✓ | Overlay object model as a JSON string |
curl -X POST http://localhost:8765/tools/pdf-editor/api/pdf-editor \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" \
-F 'model={"version":1,"pages":[{"page":0,"objects":[{"id":"o1","type":"text","x":100,"y":200,"w":120,"h":20,"text":"已蓋章","font_size":14,"color":"#cc0000"}]}]}' \
--output edited.pdf
Response: the PDF with the overlay applied. The model format is documented in the web UI's pdf-editor.
Images are refused when called through MCP (AI): objects whose type is image or that carry asset_id / existing_src get 400. Images can be stamps and signatures from the asset library, and AI stamping has its own rules that the editor must not bypass. Ordinary API calls are unaffected.
Coordinates and sizes are in pt (origin at the top left). A rotated object also carries angle (clockwise degrees) and quad (its four corners after rotation, [[x,y],…], in the order top left, top right, bottom right, bottom left); this applies to text, images, rectangles, ellipses, white-out and highlights. Images may carry opacity (0~1).
Encrypt PDF
Add user and owner passwords and set permissions.
POST /tools/pdf-encrypt/api/pdf-encrypt
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | |
user_pw | str | Open password | |
owner_pw | str | Permissions password | |
algorithm | str | aes-256 (default) / aes-128 / rc4-128 | |
allow_print | bool | Allow printing, default true | |
allow_print_hq | bool | Allow high-quality printing, default false | |
allow_copy | bool | Allow copying the content, default false | |
allow_modify | bool | Allow changing the content, default false | |
allow_annotate | bool | Allow annotations, default false | |
allow_form | bool | Allow filling in forms, default false | |
allow_assemble | bool | Allow inserting, deleting and rotating pages, default false | |
allow_accessibility | bool | Allow screen readers and other accessibility tools to read the text, default true |
curl -X POST http://localhost:8765/tools/pdf-encrypt/api/pdf-encrypt \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@document.pdf" -F "user_pw=open123" \
-F "owner_pw=admin456" -F "algorithm=AES-256" -F "allow_print=true" \
--output encrypted.pdf
Response: the encrypted PDF.
Decrypt PDF
Remove PDF encryption with the password.
POST /tools/pdf-decrypt/api/pdf-decrypt
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | The encrypted PDF |
password | str | Open password; leave empty for a PDF that only has permission restrictions and no open password | |
use_filename_as_password | bool | When true, try the file name without its extension as the password | |
thsr_mode | bool | When true, enables THSR mode: Taiwan High Speed Rail e-ticket PDFs use the travel date as the open password, so every date in the range is tried | |
thsr_date_from / thsr_date_to | str | Required in THSR mode | Date range, YYYY-MM-DD; a reversed range is swapped automatically; at most 800 days |
thsr_date_format | str | How the date is written in the password, default YYYYMMDD (THSR); only Y, M, D and - / . _ or spaces are allowed |
Passwords are tried in this order: THSR dates → file name → password.
curl -X POST http://localhost:8765/tools/pdf-decrypt/api/pdf-decrypt \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@encrypted.pdf" -F "password=open123" \
--output decrypted.pdf
# 高鐵模式:在 2026-08-01 到 2026-10-31 之間找出發日期
curl -X POST http://localhost:8765/tools/pdf-decrypt/api/pdf-decrypt \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@thsr-ticket.pdf" -F "thsr_mode=true" \
-F "thsr_date_from=2026-08-01" -F "thsr_date_to=2026-10-31" \
-OJ
Response: the decrypted PDF. A file opened in THSR mode is named after the travel date (for example 20261108.pdf; / and . in the date format become _); otherwise it is <original name>_decrypted.pdf. If no password works the response is 400; in THSR mode it says how many days were tried.
Document redaction
Detect and mask personal data in Word and PDF documents (regex, with an optional LLM).
POST /tools/doc-deident/api/doc-deident
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | PDF / Word document |
types | str | PII types to detect as CSV (ID number / phone / email / address …); blank means the default set | |
mode | str | mask (mask, default) / redact (genuine deletion) / replace (replace with fake values) | |
replacements | str | replace only: a JSON object {"original": "the new value"}. Anything not listed is generated automatically | |
valid_checksum | str | Only with replace: 1 or true = generate fake values that pass the check digit (see below) | |
custom | str | Custom detection rules, one per line (format below the table) |
custom each line is “label, |, regex”, for example 代號|PROJ-\d+; a line without | is treated as a regex as a whole. Patterns with nested repetition (such as (a+)+) is refused (400).
curl -X POST http://localhost:8765/tools/doc-deident/api/doc-deident \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@contract.pdf" -F "mode=mask" \
--output deidentified.pdf
Response: the redacted file.
Replacement mode (mode=replace)
Replaces detected data with something that looks normal but is not real: useful for testing a system, reports that go outside, and teaching examples. The original is still genuinely deleted.
Values not listed in replacements are generated automatically, shaped correctly for each field type (ID number, tax ID, mobile number, email address, credit card, personal name, address, date …), and the same original always maps to the same fake value throughout one document.
valid_checksum is off by default, and the fake values it generates deliberately fails checksum validation, so it can never collide with a real person's data. Set to 1 makes ID numbers, tax IDs and credit cards carry a correct check digit (so a test system will not reject them; but a number that computes correctly could happen to belong to a real person). Email addresses use example.com, IP addresses use 192.0.2.x, MAC addresses use 00:00:5E, all of them ranges reserved for documentation, so either setting is safe.
curl -X POST http://localhost:8765/tools/doc-deident/api/doc-deident \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@contract.pdf" -F "mode=replace" \
-F 'replacements={"0912345678":"0955555555"}' \
-F "valid_checksum=1" \
--output replaced.pdf
Text redaction
Detect and mask personal data in plain text.
POST /tools/text-deident/api/text-deident
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
text | str | ✓ | The text to process |
mode | str | mask (default) / redact | |
types | array | Array of PII type IDs to detect; omit for the default set | |
custom_regex | str | Custom detection regex |
curl -X POST http://localhost:8765/tools/text-deident/api/text-deident \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text":"我的電話是 0912345678,身分證 A123456789","mode":"mask"}'
JSON response: the masked text plus the list of PII found.
Text compare
Compare two pieces of text.
POST /tools/text-diff/api/text-diff
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
text_a | str | ✓ | Old text |
text_b | str | ✓ | New text |
curl -X POST http://localhost:8765/tools/text-diff/api/text-diff \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text_a":"原始內容\n第二行","text_b":"修改內容\n第二行"}'
Response JSON: the type of each difference (equal / insert / delete / replace) and its content.
Document compare
Compare the contents of two documents (PDF / Word).
POST /tools/doc-diff/api/doc-diff
| Parameter | Type | Required | Description |
|---|---|---|---|
file_a | file | ✓ | Old document |
file_b | file | ✓ | New document |
curl -X POST http://localhost:8765/tools/doc-diff/api/doc-diff \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file_a=@v1.pdf" -F "file_b=@v2.pdf" | jq
Response JSON: the per-segment diff structure. Besides diff (the line-level text differences), each page also carries:
| Field | Description |
|---|---|
uid | the id of this comparison (at the top level of the response), used to fetch the page images |
pages[].marks.a / .b | the difference boxes on that page. Each is {tag, line, rects}, where tag is delete / insert / replace |
pages[].marks[].rects | [x, y, w, h],a 0~1 ratio (not pixels): multiply by the size of the page image you are showing |
pages[].size.a / .b | the page size in points, [width, height] |
When no text coordinates can be read (a scan, or text converted to outlines) marks is an empty array. That does not mean there are no differences — they are still in diff.
Page image
GET /tools/doc-diff/page-image/{uid}/{slot}/{page}
| Parameter | Description |
|---|---|
uid | the id returned by the comparison above |
slot | a (old version) or b (new version) |
page | 1-based |
Returns image/png (150 dpi). For office files this is the layout after conversion to PDF. An expired file returns 410; an invalid uid / slot / page always returns 404.
curl -X POST http://localhost:8765/tools/doc-diff/api/doc-diff \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file_a=@v1.pdf" -F "file_b=@v2.pdf" > diff.json
UID=$(jq -r .uid diff.json)
curl -H "Authorization: Bearer YOUR_TOKEN" \
"http://localhost:8765/tools/doc-diff/page-image/$UID/b/1" -o page1.png
List tools
Run a list of text through a pipeline of deduplication, sorting, counting and set operations.
POST /tools/text-list/api/text-list
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
text | str | ✓ | List text, one item per line |
ops | array | The processing pipeline; each element is {"op": "..."}, where op may be dedup / sort / count / exclude / lower / upper / title and others |
curl -X POST http://localhost:8765/tools/text-list/api/text-list \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text":"banana\napple\napple\ncherry","ops":[{"op":"dedup"},{"op":"sort"}]}'
Response JSON: {"lines": [...], "count": N, "original_count": M, ...}.
Limits on custom regular expressions (List tools filter with "regex": true, Text de-identification custom_regex, Document de-identification custom): patterns with nested repetition (such as (a+)+ or (\d+)*), which can be extremely slow, return 400; the rest run in a dedicated worker, and 503 is returned when too many run at once, so try again later.
Document translation
Translates a whole office document into another language and returns a file in the same format with the same layout; only the text changes, nothing is re-laid-out. Supports .doc / .docx / .odt, .xls / .xlsx / .ods, .ppt / .pptx / .odp.
PDF is not accepted: a PDF has no paragraphs; its text is positioned fragments, and replacing them with translations of a different length is bound to break the layout. To translate a PDF, use “sentence translation” below.
POST /tools/doc-translate/api/doc-translate
Form (multipart):
| Field | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | Office document (the nine extensions above) |
target_lang | str | Target language, default zh-TW | |
source_lang | str | auto (default) / en / ja / ko … | |
domain | str | Domain hint (legal contract, medical report …) to sharpen the terminology |
curl -X POST http://localhost:8765/tools/doc-translate/api/doc-translate \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@contract.docx" \
-F "target_lang=en" \
-F "domain=法律合約" \
-o contract_translated.docx
The response is the translated file itself (Content-Disposition: attachment), in the same format as the upload.
This endpoint is synchronous: it responds only when the whole document is done, so a large file will hit the reverse proxy's timeout. The web interface uses the background-job version (
POST /tools/doc-translate/start, and after submitting use/api/jobs/{job_id}to check progress, thenGET /tools/doc-translate/download/{upload_id}to fetch the file). Requires an administrator to enable the LLM service (/admin/llm-settings). If it is not enabled it returns503。
Sentence translation
Sentence-by-sentence translation with a local LLM.
POST /tools/translate-doc/api/translate-doc
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
text | str | ✓ | Text to translate |
source_lang | str | auto (default) / en / zh / ja / ko ... | |
target_lang | str | Target language, default zh-TW | |
domain | str | Domain hint (sharpens specialist vocabulary) |
curl -X POST http://localhost:8765/tools/translate-doc/api/translate-doc \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text":"Hello world. This is a test.","source_lang":"auto","target_lang":"zh-TW"}'
JSON response:
{
"source_lang": "en",
"target_lang": "zh-TW",
"results": [
{"src": "Hello world.", "translated": "你好,世界。", "error": ""},
{"src": "This is a test.", "translated": "這是一個測試。", "error": ""}
]
}
Requires an administrator to enable the LLM service (
/admin/llm-settings). If it is not enabled it returns503。
Many sentences: the background-job version
The endpoint above is synchronous: it responds only when the whole document is done, so a large number of sentences will hit the reverse proxy's timeout. For a few hundred sentences or more, use the background job instead: you get a job id straight away, translation carries on the server, the caller can go offline, and progress and results can be fetched later.
POST /tools/translate-doc/start
GET /tools/translate-doc/job/{job_id}?start=0
start body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
sentences | list[str] | ✓ | An array of sentences you have already split (yourself, or with /extract-text) |
source_lang | str | auto (default) / en / zh … | |
target_lang | str | Target language, default zh-TW | |
domain | str | Domain hint | |
filename | str | Source filename for display (it appears in “My jobs”) |
JOB=$(curl -s -X POST http://localhost:8765/tools/translate-doc/start \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"sentences":["Hello world.","This is a test."],"target_lang":"zh-TW"}' \
| jq -r .job_id)
curl -s "http://localhost:8765/tools/translate-doc/job/$JOB" \
-H "Authorization: Bearer YOUR_TOKEN" | jq
The response to a poll:
{
"status": "running",
"progress": 0.5,
"message": "翻譯中… 1 / 2 句",
"elapsed": 3.2,
"total": 2,
"start": 0,
"results": [
{"src": "Hello world.", "translated": "你好,世界。"},
{"src": "This is a test."}
],
"cancelled": false
}
status:pending/running/done/error/cancelled/interrupted- The source text is available as soon as it is submitted (items not yet translated simply have no
translatedfield),
so the caller can display results as they arrive.
start=Nreturns only the items after the Nth; with tens of thousands of sentences there is no need to fetch them all every time.- To cancel, use the shared job endpoint:
POST /api/jobs/{job_id}/cancel. - Ownership works as it does for every other job endpoint: anyone who is not the owner gets
404.
Official document drafting
Turns a plain-language request into an approval memo (the internal memo asking a superior to approve something) or a letter to another agency, unit or member of the public, or drafts the handling note for an incoming document from how you plan to handle it. What comes back is a draft: the program lays out the section names, item numbering, closing phrases and forms of address, and the model writes the content. Amounts, dates, laws, article numbers, document numbers and wording such as "already approved" in the draft are compared with what you sent, and anything without support is listed in issues (nothing is deleted). The web page works in the Chinese, English and Japanese interfaces; whatever the interface language, the output is always a Traditional Chinese document in Taiwan's government format.
POST /tools/official-doc/api/official-doc
Body (JSON), shared by all three modes:
| Field | Type | Required | Description |
|---|---|---|---|
mode | str | Mode: sign (approval memo, default) / letter (letter) / endorse (handling note) | |
length | str | Length: short / normal (default) / long | |
use_kb | bool | When true, the official document knowledge base is searched for material related to the request before drafting (off by default). Which datasets can be searched depends on the user the token belongs to; only material whose purpose is a substantive basis counts as support for the draft | |
use_history | bool | When true, the token user's own past cases are searched for similar ones (up to 3, latest version of each) to use as a wording reference (off by default). Other people's cases are never searched, for administrators too; past cases never count as support for the draft |
Approval memo (mode=sign):
| Field | Type | Required | Description |
|---|---|---|---|
narrative | str | ✓ | The request in plain language (why, what is to be done, how much it costs, when), up to 4,000 characters |
unit | str | The unit handling the matter, written into the heading line of the memo | |
addressee | str | Who the memo goes up to, one per line (listed after the closing salutation) | |
closing | str | Closing phrase of the subject line: 核示 (default, asking for instructions) / 鑒核 / 核准 / none (a full stop only) | |
with_date | bool | When true, today's Minguo date goes under the heading line |
Letter (mode=letter):
| Field | Type | Required | Description |
|---|---|---|---|
narrative | str | ✓ | Request in plain language: what you are asking the recipient to do, deadlines and attachments; up to 4,000 characters |
issuer | str | Issuer: agency (government agency, default) / company (a company writing to a government agency). For a company, relation is always company (whatever you send is ignored); the draft calls itself "this company", addresses the agency as 貴〇 (or 貴機關 when that can't be told), never uses 鈞〇 or internal-memo wording; the heading has no file number, retention period or classification, and an empty address, business ID number, contact or signature/seal is marked 〔待補:…〕 | |
org | str | Full name of the issuing agency (the company name for a company), written into the title 〇〇〇 函 | |
receiver | str | Addressee. The form of address takes the last character of the addressee's name (東湖區公所 → 貴所) | |
relation | str | Relationship: up (to a superior agency) / peer (to a peer) / down (to a subordinate agency) / people (to the public or an organisation) / unknown (not sure, default). The form of address and the closing request both follow from it; with unknown the draft marks them as 〔待確認:…〕. A company letter is set by issuer=company; no need to send this | |
closing | str | Closing request; it must belong to that relationship (see the table below). Empty means the first one for the relationship; not accepted with relation=unknown | |
speed | str | Urgency: 普通件 (normal, default) / 速件 (urgent) / 最速件 (most urgent) | |
doc_no | str | Reference number (optional), e.g. 府資字第1150000001號, up to 200 characters. Left blank when not sent; the draft never makes one up | |
copies | str | Main recipients (empty means the same as the addressee) | |
cc | str | Copy recipients | |
signature | str | Signature, for example 局長 王○○ | |
contact_fields | object | Contact details, one key per field (any of them can be left out): address address, tax_id company ID (only used with issuer=company), person contact name, person_label the name of that field in the draft (聯絡人 (default) or 承辦人), phone phone, fax fax, email email. The system writes the field names and their order, fields not sent do not appear, and line breaks within a value are joined into one line | |
contact | str | Older form: plain text with one item per line, up to 500 characters. Ignored when contact_fields is sent. Recognised lines (address, contact person, officer in charge, phone, fax, email, company ID and their common variants) are split into the fields; lines that match no field are left out of the draft and listed in contact_unplaced in the response | |
attachments | str | Attachments | |
org_codes | object | Mapping from agency name to agency code (optional): keys are full agency names, values are agency codes (e.g. Q1000000); at most 40 entries; used when exporting a DI file. Only names that appear in the issuing agency, recipient, original or copy fields, and whose code in the electronic document exchange address book belongs to that name, are stored; mismatches are dropped (no error) |
relation | Form of address | Allowed closing requests |
|---|---|---|
up | 鈞〇(鈞府、鈞部) | 請 鑒核 / 請 核示 / 請 鑒察 / 請 核備 |
peer | 貴〇 | 請 查照 / 請 查照辦理 / 請 查照見復 / 請 惠允見復 / 請 同意見復 |
down | 貴〇 | 請 照辦 / 請 查照 / 請 轉知 / 請 確實辦理 |
people | 台端 (for an organisation: 貴〇) | 請 查照 / 請 照辦 |
company | 貴〇 (when that can't be told: 貴機關) | 請 查照 / 請 惠予審查 / 請 惠予辦理 / 請 惠予同意 / 請 惠復 |
The program leaves a space before the form of address and turns 擬請 貴局 and 請求 貴局 into 請 貴局. The date, file number and classification are left blank; the document management system fills them in when the letter is issued. The reference number holds only the doc_no you send, and stays blank if you send none.
Handling note (mode=endorse):
| Field | Type | Required | Description |
|---|---|---|---|
source | str | ✓ | The incoming document (or your own outline of it), up to 12,000 characters |
direction | str | ✓ | How you plan to handle it, up to 2,000 characters. Missing returns 400: approving, rejecting or simply filing is your decision, and the tool does not make it for you |
outline | bool | true means source is your own outline rather than the full incoming document | |
units | str | Units handling or assisting | |
internal_deadline | str | Internal deadline (kept separate from the deadline in the incoming document) | |
fmt | str | Layout: compact (one short paragraph, default) / list (numbered items) | |
closing | str | Ending: 陳核 (default) / 陳閱 / none |
Generating again from edited data (all three modes, optional):
| Field | Type | Description |
|---|---|---|
facts | array | The facts from the previous response (edited if you like). With it, the model is not asked to extract the data again and only writes the draft. The server re-judges the status of every item: an item marked provided must have a quote that really appears in narrative / source, otherwise it drops to inferred |
overrides | object | Maps field keys to new values, for example {"budget_source": "115年度資訊設備費"}. An item you change becomes confirmed and the check uses it as support; an empty string means there is no such data |
Short fields such as the handling unit and recipients, and the values in overrides, take up to 200 characters. Anything over a limit returns 400 stating the limit and the current length; nothing is truncated (the part cut off could be exactly the deadline or a condition). An option outside the allowed list also returns 400.
curl -X POST http://localhost:8765/tools/official-doc/api/official-doc \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"mode": "sign", "unit": "資訊室", "addressee": "主任秘書\n局長",
"narrative": "本局資訊室兩台印表機已使用8年,經常卡紙,維修廠商表示零件已停產。擬以115年度資訊設備費新臺幣6萬元汰換雷射印表機2台,預計11月30日前完成採購。"}' | jq
Response JSON (facts shortened; the draft's explanation cites a law you never mentioned, so issues has two entries):
{
"mode": "sign",
"text": "簽 於資訊室\n主旨:汰換資訊室雷射印表機2台,簽請 核示。\n說明:\n一、本局資訊室印表機已使用8年,經常卡紙,維修廠商表示零件已停產。\n二、經費由115年度資訊設備費支應,並依政府採購法第49條辦理。\n擬辦:擬購置雷射印表機2台,預算新臺幣6萬元,於11月30日前完成採購。\n敬陳\n主任秘書\n局長",
"facts": [
{ "key": "amount", "label": "金額", "value": "新臺幣6萬元",
"quote": "新臺幣6萬元", "status": "provided" },
{ "key": "budget_source", "label": "經費來源", "value": "115年度資訊設備費",
"quote": "115年度資訊設備費", "status": "provided" }
],
"issues": [
{ "code": "law_unsupported", "severity": "error",
"message": "法規「政府採購法」不是你提供的,請確認是否適用,或刪除。",
"template": "法規「{0}」不是你提供的,請確認是否適用,或刪除。",
"args": ["政府採購法"], "snippet": "政府採購法" },
{ "code": "article_unsupported", "severity": "error",
"message": "「第49條」不是你提供的條號,請確認或刪除。",
"template": "「{0}」不是你提供的條號,請確認或刪除。",
"args": ["第49條"], "snippet": "第49條" }
],
"llm_calls": 2
}
Handling note:
curl -X POST http://localhost:8765/tools/official-doc/api/official-doc \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"mode": "endorse", "units": "資訊室", "direction": "擬由資訊室填報後函復",
"source": "嘉禾市政府115年10月1日府資字第1150012345號函:請各機關於115年10月20日前填報資訊設備盤點資料,逾期視同無資料。"}' | jq '.text'
# → "嘉禾市政府函請各機關於115年10月20日前填報資訊設備盤點資料,擬由資訊室填報後函復,陳核。"
Letter:
curl -X POST http://localhost:8765/tools/official-doc/api/official-doc \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"mode": "letter", "org": "嘉禾市資訊局", "receiver": "嘉禾市東湖區公所",
"relation": "down", "closing": "請\u3000照辦", "cc": "本局資訊管理科",
"signature": "局長\u3000王○○", "attachments": "資訊資產清冊1份",
"contact_fields": {"address": "嘉禾市文化路1號", "person_label": "承辦人",
"person": "王小明", "phone": "(02)1234-5678"},
"narrative": "請各區公所於115年10月20日前填報資訊資產清冊,以電子郵件回傳。"}' | jq -r '.text'
Response fields:
| Field | Description |
|---|---|
text | The full draft as plain text, ready to paste into a document management system. Required data you did not give is written as 〔待補:…〕 and conflicting data as 〔待確認:…〕; nothing is filled in or chosen for you |
facts | The data table; each item is {key, label, value, quote, status}. The five statuses: provided (found in your text; quote is the passage), inferred (the model's inference, to be confirmed), missing (not provided), conflict (contradictory, with values listing the versions) and confirmed (changed by you in overrides, the old value kept in was) |
issues | The check results, sorted by severity. The three severities: error (no support found, or the draft still shows a value you replaced), todo (something to fill in or confirm) and hint (a suggestion). In each entry message is the finished Chinese sentence, template and args are the same sentence as a template plus arguments (for translating it yourself), and snippet is the passage in the draft |
llm_calls | How many times the model was called (re-asking after a badly formatted answer counts too) |
references | With use_kb or use_history, the material the draft drew on: {id, title, dataset_name, version_label, locator_text, heading, purpose, text, source_url, used}. purpose is substantive_basis (a substantive basis; only this kind counts as support) / format_reference (format and wording reference) / style_example (writing example) / past_case (one of your own past cases, with case_id, case_rev and case_updated); used means the model says it cited it. An empty array when neither was used |
kb_note | Official document knowledge base status: an empty string (fine, or the official document knowledge base was not used) / none (nothing relevant found) / failed (the search failed; the draft is still produced, just without references, and the reason goes to the service log) |
history_note | Past case status: an empty string (fine, or past cases were not used) / none (none of your cases is similar) / failed (the search failed; the draft is still produced) |
contact_unplaced | Lines of contact details sent in the older contact form that match no field and were left out of the draft (an array; empty when every line matched) |
code | Meaning |
|---|---|
qty_unsupported / date_unsupported | An amount, quantity or date cannot be found in what you gave (ten-thousand units, Chinese numerals, Minguo and Western years are all converted before comparing) |
law_unsupported / article_unsupported / docno_unsupported | A law name, article number or document number that you did not provide |
claim_unsupported | Wording that presents something as settled ("already approved", "contract awarded", "required by law", "passed acceptance", "no penalty", "force majeure" and the like) that you did not use. An instruction in your request such as "don't say it is already approved" is a writing instruction and does not count as you saying it |
word_unsupported | The draft says tax included or tax excluded, but what you provided does not |
placeholder | A 〔待補:…〕 / 〔待確認:…〕 marker in the draft, to be resolved before sending |
missing_fact | Something that should be there is missing: money is involved but there is no amount or funding source, no purpose or method, or no timeline; for a letter, no addressee or issuing agency (the company name for a company letter) |
relation_unknown | The letter's relationship is "not sure", so the closing request and form of address need confirming before it goes out |
salutation | The letter's form of address does not match the relationship (貴〇 in a letter to a superior, or 鈞〇 in any other letter or in a company letter) |
company_wording | A company letter uses an agency's internal-memo wording (擬辦, 簽請, 陳核) or an agency's self-reference (本局) |
action_not_in_direction / action_negated | A step proposed in the handling note's 擬… that is not in your plan, or one you explicitly ruled out (for example the plan says 不用轉知 and the draft says 擬轉知) |
missing_section | An approval memo without a subject section (error) or a proposed-action section (hint) |
long_subject | The subject line is over 120 characters |
omitted | A number, date or law article you wrote yourself that the draft leaves out |
proposal_no_approval | The proposal section of an approval memo does not say what the supervisor is asked to approve (擬請同意…) |
weekday_mismatch | A date and its day of the week do not match (a date with no year is taken as this year, and the message says so); it is never corrected for you |
date_past | A deadline has already passed (one written as …前; an old plan such as 原本預計…前 does not count) |
attachment_mentioned | Letters: your text mentions an attachment but the attachment field is empty |
stale_value | A value you changed in overrides that the draft still shows in its old form |
injection_suspect | The incoming document contains something that reads like an instruction to the AI. That sentence was removed before anything went to the model and is not counted as support; the draft still needs a line-by-line check |
The checks cannot judge meaning: a reversed cause and effect or a wrong conclusion only shows up when a person reads it. An empty issues does not mean the draft is right; always have a person check it before it goes out.
Status codes: bad fields (a required one missing, over a limit, an option outside the list) return 400; LLM not enabled returns 503; a failed model call, or a model that ignores the format twice in a row, returns 502 (with a fixed message; the cause only goes to the service log).
This endpoint is synchronous (about 2 to 4 model requests per draft), so give the caller a generous timeout. For background processing, or to edit the draft before checking and exporting it, use the web flow below.
Background jobs and export (the web flow)
These can also be called with a Bearer token. Each one needs the case ID (case_id), and only your own cases are reachable.
| Endpoint | Description |
|---|---|
POST /tools/official-doc/start | Same fields as above (JSON). Returns {"job_id": "...", "case_id": "...", "contact_unplaced": [...]}; poll progress with /api/jobs/{job_id}. When it finishes, the job's result file is the draft as ODT (/api/jobs/{job_id}/download) |
GET /tools/official-doc/result/{case_id} | Gets the result: {case_id, mode, inputs, title, draft, created_at}, where draft is {mode, text, facts, issues, content, llm_calls}; expired or cleaned up returns 410 |
POST /tools/official-doc/check | Send {"case_id": "...", "text": "改過的草稿"}, get {"issues": [...]}: checks the current text again without calling the model, against what you sent when the case was created |
POST /tools/official-doc/export | Send {"case_id": "...", "text": "...", "fmt": "odt", "title": "...", "draft_mark": true, "extras": {...}} and get the file back. Formats (fmt): txt / odt / docx / pdf / png / svg / json / di; the export uses the text you send, i.e. your edited version |
POST /tools/official-doc/di-preview | Send {"case_id": "...", "text": "...", "title": "..."} and get {filename, mode, root, dtd, xml, notes, valid, errors}: the same generator as exporting di, so xml is exactly the file you would download; valid tells whether it passed the DTD check, and notes are remarks ({code, args}, e.g. agencies without a matching agency code) |
POST /tools/official-doc/exchange-plan | Before building an e-exchange package (DI + exchange form SW + attachments, for businesses that send with WebjAgent): send {"case_id": "...", "text": "..."}; returns {recipients, reasons, messages, max_bytes, max_files, exts}. recipients lists every original and copy recipient as {name, kind, code, attached, included, reason}; when included is false, reason is no_code (no agency code matched), not_exchangeable (the address book marks it as unable to exchange), internal (an internal unit) or duplicate (same code twice). Letters only; a memo returns 400 |
POST /tools/official-doc/exchange-package | Multipart: case_id, text, title, attachments (several allowed, up to 20; PDF, ODF, Office, plain text, images). Returns a zip with the .di, .sw and attachments; attachments are declared as NDATA entities in the DI. The DI, SW and attachments together, and the zip itself, must not exceed 2 MB (the WebjAgent limit). No exchangeable recipient, over the limit or an unaccepted attachment type → 400 with detail as {code, args, message}. Headers X-Jtdt-Exchange-Recipients / X-Jtdt-Exchange-Skipped give how many agencies went into the exchange form and how many did not. It only creates the files and does not send anything to the exchange centre |
GET /tools/official-doc/orgs | Look up agency names (electronic document exchange address book; available after an administrator has downloaded it): parameters q (name, or the start of a code) and limit (1 to 2000, default 10); returns {"orgs": [{"name": "...", "id": "...", "exchangeable": true}], "exact": "...", "total": 23, "max": 2000}; exchangeable is false when the address book marks the agency as unable to exchange at the moment (STATUSCODE F or D; paper delivery still works). exact is the agency code when exactly one agency has that full name; it is empty when several share the name. total is the number of matches (so a short list can say how many were left out), and max is the most that can be listed at once. Order: exact name matches first, then main agencies, with internal units after them |
POST /tools/official-doc/extract-text | multipart file → {"text": "...", "chars": 11, "filename": "..."}: pulls the text out of a PDF, Word (.docx / .doc), ODT, RTF or plain text (.txt / .md) file for you to paste into a field; the file is not kept; up to 20 MB |
GET /tools/official-doc/api/cases | Case history list: {"cases": [...], "show_owner": false, "limit": 500}, newest first. The query parameters q (matches name, title, document number and case ID) and mode (sign / letter / endorse) are optional. Each entry has case_id, name, title (for file names: the first 20 characters of the subject), subject (the whole subject), doc_no (the document number: filled in automatically from the issuing number entered when drafting a letter and from imported DI letters and approval memos, and editable afterwards), mode, latest_rev, issues, created_at, updated_at, deleted, imported (imported from a DI file) and di_ok (whether a DI file can be downloaded); administrators get everyone's cases (including deleted ones) with an extra owner |
GET /tools/official-doc/case/{case_id} | One case's list entry, plus has_result and job (the latest job's {id, status}, so you can keep polling it while it runs) |
POST /tools/official-doc/case/{case_id}/rename | Send {"name": "..."} to rename (up to 80 characters; longer returns 400, never truncated); an empty string means use the draft's title |
POST /tools/official-doc/case/{case_id}/doc-no | Send {"doc_no": "..."} to add or change the case's document number (for example the number your document system assigned after an approval memo was sent); returns that entry of the list. Up to 60 characters; longer or not text returns 400, never truncated; an empty string clears it. It is a record on the case only and does not change the draft |
DELETE /tools/official-doc/case/{case_id} | Delete a case: the owner can no longer list or open it; it is removed from disk according to the official-document cases retention period under File retention (365 days by default, counted from the deletion) |
GET /tools/official-doc/case/{case_id}/di | Downloads the latest version of the case as a DI file (named after the case name or title); handling notes have no DI file and return 400. The X-Jtdt-Di-Valid header says whether it passed the DTD check, and X-Jtdt-Di-Notes how many notes there are |
POST /tools/official-doc/cases/di | Send {"case_ids": ["...", "..."]} (up to 100 cases) to get a zip with one DI file per case. Handling notes and cases without a draft are skipped: the X-Jtdt-Di-Count header says how many were packed and X-Jtdt-Di-Skipped how many were skipped; if all are skipped you get 400. If any case is not yours, the whole request returns 404 |
POST /tools/official-doc/cases/import | Multipart files (several allowed: DI files or a whole zip, up to 50 at a time). Each DI file becomes a case owned by the uploader. Returns {"imported": [{filename, case_id, title, mode, mode_name, notes, issues}], "failed": [{filename, code, args, error}], "skipped": 2}: a file that cannot be read does not stop the others; skipped is the number of files in the archive that are not DI files. Only official letters and approval memos are accepted; files are read without expanding entities or using the network, up to 1 MB each |
Cases (inputs, drafts, versions) are stored on the server and kept according to the File retention settings, not the temporary-file retention. Someone else's case, a missing case and a deleted case all return the same 404 (if they could be told apart, any ID could be used to ask whether a case exists).
Export details:
- ODT is built by the program itself and needs no Office engine; Word and PDF (
docx/pdf) go through the Office engine and return 503 when there is none. - The page header says "draft" by default; set
draft_marktofalseto leave it off. The file name comes fromtitle(up to 40 characters, with characters not allowed in file names removed), so the download is named<title>-草稿.<fmt>. - The font is DFKai-SB. When the server does not have it, the PDF uses another regular-script font, and failing that a Ming (serif) font.
- JSON carries
"format": "jtdt-official-doc"and"format_version": 1and holds the whole case;draft.textis replaced by the text you send anddraft.issuesis re-checked against it. - The electronic document DI file (
di) is the body file (XML) of a Taiwan government electronic document, following the version 104 DTD of the National Archives Administration's computerised records management rules (letter104_2_utf8.dtd, memo104_5_utf8.dtd). Officers import it into their agency's own document system and then number, approve and send it as usual. Date of issue, document number and reference number stay empty when empty and are kept whole when given; agency codes come fromorg_codesfirst, otherwise from the address book by name (filled only when exactly one agency has that full name). Handling notes have no DI file, and a draft without a subject line cannot produce one; both return 400. Response headerX-Jtdt-Di-Validsays whether it passed the DTD check (1or0), andX-Jtdt-Di-Noteshow many remarks there are. - Images (
png/svg) use the same layout as the PDF: one page returns that image (PNG at 200 dpi; SVG text is converted to outlines so it looks the same without the font), several pages come as one image per page in a zip (<title>-草稿-png.zip), up to 30 pages.
Page additions (extras, optional; only for odt / docx / pdf / png / svg, never written into the draft text, and the preview shows them too):
| Field | Description |
|---|---|
page_numbers | When true, page numbers (page ○ of ○) are added in the footer |
binding_line | When true, a binding line is added on the left (a dotted line with the three binding marks) |
copy_mark | The mark in the top left: 正本 / 副本 / 抄本; letters only |
send_method | The dispatch method line in the top left: 電子交換 / 郵寄 / 掛號郵寄 / 專差送達 / 親自送達 / 傳真 / 電子郵件; letters only |
delegate | The approver in the delegated-approval line printed under the signature (for example 業務主管), up to 20 characters; agency letters only |
receiver_address | The recipient's postcode and address for a window envelope, printed above the recipient line, up to 80 characters; letters only |
endorse_frame | When true, adds the heading and sign-off block for printing on its own: 簽辦意見 and the incoming-document line at the top, the handling officer and date at the bottom; endorsement opinions only. The incoming-document line is taken by the server from the case's facts; any value sent in the request is ignored |
An option not on the list or text over the limit returns 400; fields that do not apply (for example copy_mark on an approval memo) are ignored.
# 改完草稿之後重新檢查,再匯出 ODT
curl -X POST http://localhost:8765/tools/official-doc/check \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"case_id": "CASE_ID", "text": "簽 於資訊室\n主旨:…"}' | jq '.issues'
curl -X POST http://localhost:8765/tools/official-doc/export \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"case_id": "CASE_ID", "text": "簽 於資訊室\n主旨:…", "fmt": "odt", "title": "汰換印表機"}' \
-o draft.odt
# 匯出電子公文 DI 檔(匯入機關的公文系統用)
curl -X POST http://localhost:8765/tools/official-doc/export \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"case_id": "CASE_ID", "text": "嘉禾市資訊局 函\n…\n主旨:…", "fmt": "di", "title": "盤點"}' \
-o draft.di
The LLM has to be enabled in the admin area first (/admin/llm-settings). check, export, result and extract-text do not call the model.
Company ID lookup (single)
Look up a company or agency name, address and industry by 8-digit tax ID.
POST /tools/vat-lookup/api/vat-lookup
Body (JSON): {"vat": "12345678"}
curl -X POST http://localhost:8765/tools/vat-lookup/api/vat-lookup \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"vat":"12345678"}' | jq
Fields in the JSON response:
- Basic data:
vat,name,address,org_type,category,industries,owner,status(the last two only from some sources). - Other tax registration data (from v1.16.92):
hq_vatis the head office company ID (branches only);capitalis the capital (NT$, integer);foundedis the date established (YYYY-MM-DD);uses_invoiceis whether the business issues uniform invoices (true/false). - Missing data is
null: government agencies and schools have none of these, and on an existing site they stay empty until the next database update after upgrading.
Returns 404 when not found.
Company ID lookup (path style)
The same, but as GET with a path parameter.
GET /api/vat-lookup/{vat}
curl http://localhost:8765/api/vat-lookup/12345678 \
-H "Authorization: Bearer YOUR_TOKEN" | jq
JSON response: the same as the single lookup.
Company ID lookup (batch)
Look up several tax IDs at once.
POST /tools/vat-lookup/api/vat-lookup/batch
Body (JSON): {"vats": ["12345678", "23456789"]}
curl -X POST http://localhost:8765/tools/vat-lookup/api/vat-lookup/batch \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"vats":["12345678","23456789"]}' | jq
JSON response: an array of results.
e-Invoice scan
Decode the contents of an e-invoice QR code.
POST /tools/einvoice-scan/api/einvoice-scan
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | Image or PDF containing the invoice QR code |
curl -X POST http://localhost:8765/tools/einvoice-scan/api/einvoice-scan \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@invoice.jpg" | jq
JSON response: invoice number, date, amount, seller tax ID and so on.
e-Invoice backend status
Check whether the QR decoding backend (zbar) is available.
GET /tools/einvoice-scan/api/backend-status
curl http://localhost:8765/tools/einvoice-scan/api/backend-status \
-H "Authorization: Bearer YOUR_TOKEN" | jq
Response JSON: {"available": true/false, ...}.
Pre-submission check
Creates a case, uploads the files and starts the check in one call (a background job). The case appears in the tool page's case list, just like one made on the web page.
POST /tools/submission-check/api/submission-check
| Parameter | Type | Required | Description |
|---|---|---|---|
files | file[] | ✓ | The documents to submit: PDF, office documents or images; up to 50 at a time, 200 MB in total |
case_name | str | Case name | |
main_entity_name | str | The company or person submitting (checked against every document) | |
main_entity_identifier | str | Its unified business number or ID number | |
counterparty_name | str | Who the documents are submitted to | |
case_number | str | Case number | |
deadline | str | Deadline, YYYY-MM-DD | |
allow_llm | bool | Default true (used only if the site has an LLM configured); with false the LLM text and LLM vision layers are not run and are marked as skipped in the report |
curl -X POST http://localhost:8765/tools/submission-check/api/submission-check \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "files=@quote.pdf" -F "files=@contract.pdf" \
-F "main_entity_name=範例股份有限公司" -F "allow_llm=false" | jq
# → {"job_id": "...", "case_id": "...", "version": "v1", "result_url": "/tools/submission-check/result/.../v1", ...}
# 做完之後讀報告
curl -s http://localhost:8765/tools/submission-check/result/$CASE/v1 \
-H "Authorization: Bearer YOUR_TOKEN" | jq '.summary'
Response: job_id, case_id, version, result_url (the report) and case_url (the case on the tool page). Wait for the job with the job API in chapter 10, then read result_url; the report is JSON (summary has the score and the status of each layer, followed by per-file and cross-file findings).
Pre-submission check; your own company profile
Manage your own company entities for the pre-submission check (CRUD).
GET /tools/submission-check/api/self-entities
POST /tools/submission-check/api/self-entities
PUT /tools/submission-check/api/self-entities/{entity_id}
DELETE /tools/submission-check/api/self-entities/{entity_id}
POST / PUT parameters: name, tax_id, address, aliases, type, note.
# 列出
curl http://localhost:8765/tools/submission-check/api/self-entities \
-H "Authorization: Bearer YOUR_TOKEN" | jq
# 新增
curl -X POST http://localhost:8765/tools/submission-check/api/self-entities \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "name=Acme 股份有限公司" -F "tax_id=12345678" \
-F "address=台北市..." -F "type=company"
# 更新
curl -X PUT http://localhost:8765/tools/submission-check/api/self-entities/abc123 \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "name=Acme 國際" -F "tax_id=12345678"
# 刪除
curl -X DELETE http://localhost:8765/tools/submission-check/api/self-entities/abc123 \
-H "Authorization: Bearer YOUR_TOKEN"
JSON response: the entity list or the result of the operation.
Travel receipts
Parses a batch of Taiwan Railway, THSR or Uber ride receipt PDFs and returns structured JSON. Parsing only — nothing is written to the user's list.
POST /tools/transit-proof/api/transit-proof
| Parameter | Type | Required | Description |
|---|---|---|---|
files | file[] | ✓ | Travel receipt PDFs, up to 200 at a time |
curl -X POST http://localhost:8765/tools/transit-proof/api/transit-proof \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "files=@proof1.pdf" -F "files=@proof2.pdf" | jq
{
"ok": true,
"count": 1,
"entries": [{"date": "...", "from": "...", "to": "...", "amount": 0}],
"failed": [{"file": "other.pdf",
"error": "無法辨識為乘車證明(格式不符或版面不支援)"}]
}
A file that cannot be recognised does not fail the whole batch; successes go into entries and each failure is listed in failed (the HTTP status is still 200). To tell whether anything was missed, check whether failed is empty rather than going by the HTTP status. More than 200 files returns 400; no files at all returns 422.
Business card reader
Business cards in photos or scans → frames, recognition, review → a contact list. No LLM is needed; OCR uses the engine under Settings → OCR. Only the person who created a batch can see it (by account when sign-in is enabled; shared by everyone on this computer when it is not), and other people's batches or unknown ids always return 404. Batches are kept for 30 days by default and then deleted with their images; they can be deleted at any time.
POST /tools/business-card-reader/api/batches # 建立批次(上傳)
GET /tools/business-card-reader/api/batches # 我的批次清單
GET /tools/business-card-reader/api/batches/{batch_id} # 批次內容(頁、卡面框、辨識行、聯絡人)
PATCH /tools/business-card-reader/api/batches/{batch_id} # 整批的備註
DELETE /tools/business-card-reader/api/batches/{batch_id} # 立即清除
GET /tools/business-card-reader/api/batches/{batch_id}/pages/{page_id}/image?max=1600
GET /tools/business-card-reader/api/batches/{batch_id}/cards/{card_id}/image?max=0
PUT /tools/business-card-reader/api/batches/{batch_id}/pages/{page_id}/cards # 改框
POST /tools/business-card-reader/api/batches/{batch_id}/mode # 改收件模式(不用重新上傳)
POST /tools/business-card-reader/api/batches/{batch_id}/recognize # 全部辨識(背景)
POST /tools/business-card-reader/api/batches/{batch_id}/cards/{card_id}/retry # 重新辨識(可改用另一種語言)
POST /tools/business-card-reader/api/batches/{batch_id}/lang # 整批改用另一種語言重新辨識
GET /tools/business-card-reader/api/langs # 可選的辨識語言、這台能不能用
POST /tools/business-card-reader/api/batches/{batch_id}/cards/{card_id}/contacts # 同一張卡再加一位
POST /tools/business-card-reader/api/batches/{batch_id}/contacts/save-all # 全部儲存 / 全部確認
POST /tools/business-card-reader/api/batches/{batch_id}/contacts/merge # 同一批合併兩位(正反面 / 同一人)
POST /tools/business-card-reader/api/batches/{batch_id}/contacts/{contact_id}/unmerge
POST /tools/business-card-reader/api/business-card-reader # 一次完成:上傳 → 辨識 → 回聯絡人 JSON
PUT /tools/business-card-reader/api/batches/{batch_id}/contacts/{contact_id} # 校對 / 確認 / 排除
DELETE /tools/business-card-reader/api/batches/{batch_id}/contacts/{contact_id}
POST /tools/business-card-reader/api/batches/{batch_id}/export/preview
POST /tools/business-card-reader/api/batches/{batch_id}/export
Create a batch (multipart): files (several allowed; JPEG, PNG, PDF, plus HEIC when the server has the decoder), mode = single (one card per image, recognised in the background right after creation) or multi (several cards per image; it stops at frame checking, adjust frames with PUT …/cards, then POST …/recognize); lang = zh (Traditional Chinese + English, default) / ja (Japanese + English); event, source, tags (comma-separated) and memo are your notes, applied to every contact in the batch (stored apart from the printed text). Up to 50 files, 100 pages and 300 cards per batch, 40 MB per file; beyond that you get 400 / 413 with how to split the batch. Returns 201 with the batch.
curl -X POST http://localhost:8765/tools/business-card-reader/api/batches \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "files=@card1.jpg" -F "files=@card2.jpg" -F "mode=single" -F "event=展場" | jq '.id, .counts'
The batch's counts: files, pages, cards, cards_done, cards_failed, cards_pending, contacts (excluding excluded ones), confirmed, check. status: frames (several-cards mode waiting for frame checks), recognizing, review. Recognition is finished when polling shows cards_pending at 0. Each card (pages[].cards[]) carries, once recognised, engine (the OCR engine actually used), secs (seconds for that card from straightening to extraction), ocr_secs (the text recognition part), lang (the card's language: its own choice if it has one, otherwise the batch's), lang_own (the card has its own language) and lang_used (the language of its last recognition); the batch itself also has lang.
Recognition language: zh (Traditional Chinese + English) / ja (Japanese + English). Japanese cards get Japanese rules: company names with Japanese legal-entity words, department and title on one line, name (family and given name, the given name may be kana; the kana reading line is not used as a field), postal code (→ zip) and address, and mobiles (11 digits starting 070 / 080 / 090, or +81). Any language EasyOCR knows can be chosen (local or remote GPU; the model downloads on first use); with Tesseract only, install the Japanese training data under Settings → OCR engine first, otherwise creating the batch returns 400 with an explanation. GET …/langs returns {"zh": {"ok", "via", "hint"}, "ja": {…}}. Recognise again in another language: POST …/cards/{card_id}/retry with {"lang": "ja"} changes just that card (one Japanese card in a pile of Taiwanese ones); POST …/batches/{batch_id}/lang with {"lang": "ja"} changes the whole batch (every recognised card is recognised again). Both keep fields you edited or confirmed; audited as business_card_relang.
Adjust frames (JSON): {"cards": [{"id"?, "quad": [[x,y]×4], "rotate": 0|90|180|270, "memo"?}], "recognize": true?}, with coordinates in page-image pixels; a frame without id is new, and frames missing from the list are deleted. Cards whose frame and angle did not change keep their results; only changed ones are recognised again. NaN, infinity and tiny frames are refused; at most 60 cards per page.
Switch intake mode (JSON): {"mode": "multi" | "single", "pages": [page ids…]?}, for when the wrong mode was chosen at upload, without uploading again. Only the given pages change (omitted = whole batch): cards on those pages are found again and their results and edits are cleared; other pages are untouched. multi stops at the frames step (status=frames), single recognises in the background straight away. If recognition is running it first waits for the card in progress (up to 60 seconds, otherwise 409). In single mode pages[].multi_hint=true means the image looks like it holds several cards.
Contacts: fields is a list of {"id", "key", "value", "status", "reason", "source", "ext"?, "label"?, "zip"?, "norm"?}; key is one of name, name_en, title, title_en, department, department_en, company, company_en, vat, mobile, phone, fax, email, url, address, im; phones, emails, addresses and the like can repeat. status: auto (recognised), check (needs checking, with reason), confirmed (confirmed by a person), deleted. source.method is ocr / qr / manual, and source.box is where the line sits on the card image ([left, top, width, height]). To save: PUT …/contacts/{id} with fields (the whole list), notes (event / source / tags / memo) and status (check / confirmed / excluded); with status=confirmed every field of that contact is marked as confirmed. Re-recognition (retry) keeps fields you edited or confirmed. Save all: POST …/contacts/save-all with {"items": [{"id", "fields"?, "notes"?}], "confirm_all"?: true} saves several contacts at once; the whole request is checked first (one bad item and nothing is saved), and confirm_all=true also marks every contact that is neither excluded nor confirmed as confirmed (its fields count as checked). Returns saved, confirmed and the batch.
Export (JSON): format = csv / xlsx / ods / vcf / json; scope = confirmed (default) / all (including unchecked) / selected (with ids); spreadsheets with table=true open ready to filter and search (an Excel table in XLSX, an autofilter in ODS), false gives plain data; lang = zh (Chinese column names) / en (English codes); columns picks columns and order; CSV also takes encoding (utf-8 default / big5; characters missing from Big5 return 422 rather than silently turning into question marks), bom (default true, UTF-8 only) and safe (default true: values starting with =, +, -, @, a tab, a line break or leading spaces get an apostrophe prefix); JSON also takes include_source. One person per row; second and later phones, emails and so on get their own columns, as many as the contact with the most values in this export. XLSX also takes layout=standard (default, the layout above) / roster (the card roster layout: row 1 holds the title and update date, row 2 the column headings, with Chinese and English columns side by side: date added, category (= tags), company name and Company Name, department and Department, name and Full Name, title and Job Title, phone, fax, mobile, Email, website, Chinese address and Address, where obtained (event + source), notes; the headings themselves are in Chinese to match the template; several values in one cell are separated by line breaks, and VAT number or messaging IDs are appended at the end when a card has them; the workbook also has a category list sheet and an empty favourites sheet; table, columns and lang do not apply). layout=roster with any other format returns 400. Phone, extension, postcode and VAT number are text in XLSX and ODS. Returns 409 when there is nobody to export. export/preview returns count, headers, the first 5 rows, skipped_check, excluded, plus big5_missing (characters missing from Big5, up to 10) and big5_missing_count.
curl -X POST http://localhost:8765/tools/business-card-reader/api/batches/BATCH_ID/export \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"format": "xlsx", "scope": "all", "table": true}' -OJ
Audit: creating a batch business_card_batch, switching the intake mode business_card_mode, confirming all business_card_confirm_all, exporting business_card_export, clearing business_card_delete (only the batch id, counts and format are recorded, never contact details).
One-shot (multipart, for scripts and MCP): files, mode, lang and event / source / tags / memo as for creating a batch, plus wait (10 to 600 seconds, default 120). In multi-card mode every card found automatically is recognised directly (nobody confirms the frames). Returns batch_id, done (false = not finished yet; read the rest later with the batch API), counts, contacts (each with fields: key / value / status / reason) and review_url. The results have not been reviewed by a person: fields whose status is check need confirming.
curl -X POST http://localhost:8765/tools/business-card-reader/api/business-card-reader \
-H "Authorization: Bearer YOUR_TOKEN" -F "files=@card.jpg" -F "mode=single" | jq '.contacts[0].fields'
Merging within a batch: POST …/contacts/merge with {"keep", "other"} folds other into keep (the name and company from the English side go into the foreign-language fields; phone numbers and email addresses are not duplicated), and the card images all count as keep's. merge_hints in the batch content lists pairs that may be the same person (reason = front_back for the two sides of one card / duplicate for the same person; by = email / mobile). POST …/contacts/{id}/unmerge undoes the most recent merge (both go back to how they were before the merge and edits made after it are lost; 409 if there was no merge). GET …/batches/{id}?lite=true leaves out each card's OCR text lines (for polling during recognition). Recognition runs through the site-wide job system and appears in My jobs (view_url leads back to the batch).
Card books
GET /tools/business-card-reader/api/books # 我看得到的名片簿與角色(owner / edit / view)
PATCH /tools/business-card-reader/api/books/{book_id} # 個人名片簿的保留天數 {"keep_days"}
GET /tools/business-card-reader/api/books/{book_id}/people?q=&tag=&limit=&offset=
GET /tools/business-card-reader/api/books/{book_id}/people/{person_id} # 目前資料、歷史名片、互動紀錄
PUT /tools/business-card-reader/api/books/{book_id}/people/{person_id} # {"fields"?, "notes"?}
DELETE /tools/business-card-reader/api/books/{book_id}/people/{person_id}
POST /tools/business-card-reader/api/books/{book_id}/people/merge # {"keep", "others": [...]}
GET /tools/business-card-reader/api/books/{book_id}/people/{person_id}/cards/{card_id}/image
POST /tools/business-card-reader/api/books/{book_id}/people/{person_id}/interactions # {"kind", "note", "at"?}
PUT /tools/business-card-reader/api/books/{book_id}/people/{person_id}/interactions/{id}
DELETE /tools/business-card-reader/api/books/{book_id}/people/{person_id}/interactions/{id}
POST /tools/business-card-reader/api/books/{book_id}/export # 參數同批次匯出,另有 ids / q / tag
POST /tools/business-card-reader/api/books/{book_id}/import # multipart file:匯入檔案(先比對、自動去重)
POST /tools/business-card-reader/api/books/{book_id}/import/{token}/preview # {"mapping"} 改了欄位對應後重新比對
POST /tools/business-card-reader/api/books/{book_id}/import/{token}/apply # {"mapping"?, "decisions": {列號: add|merge|skip}}
DELETE /tools/business-card-reader/api/books/{book_id}/import/{token}
GET /tools/business-card-reader/api/books/{book_id}/duplicates # 名片簿裡可能是同一人的幾組
POST /tools/business-card-reader/api/batches/{batch_id}/save-to-book/preview # {"book", "scope" | "ids"} → 每位可能是同一人的
POST /tools/business-card-reader/api/batches/{batch_id}/save-to-book # {"book", "items": [{"contact_id", "action": new|merge|skip, "person_id"?}]}
A personal card book is visible only to its owner (owner); a shared card book follows the member's role: view can search, view and export, and edit can also save into it, edit, merge, delete and record interactions. A card book you cannot see always returns 404, and editing with view-only access returns 403. q is space-separated keywords (each one must appear in some field or note), and tag is a whole tag. Interaction kind = meeting / call / email / visit / other, and at is a timestamp (omitted = now). When saving into a card book, preview looks for people in the book who may be the same person by email → mobile → name plus company (matches[].reason); merge adds one more card record (with the card image) to that person, the current details are replaced with the new ones and the old ones stay in the card history. Each card book has its own retention period (counted from the last update, 0 = forever), and personal card books are limited by the administrator's maximum. Audit events: business_card_book_query (keywords are not recorded), business_card_book_view, business_card_book_save, business_card_book_edit, business_card_book_merge, business_card_book_delete, business_card_book_export, business_card_interaction. Shared card books and their members are managed by an administrator under Settings → Card books (/admin/business-cards/api/…).
Importing a file into a card book (edit role required): the formats are the same as for merging a previous export (XLSX / ODS / CSV / VCF / JSON, same limits). The upload returns token, kind, headers, the first 5 rows, mapping, targets and the automatic duplicate check in items: each row is {"row", "kind", "default", "who", "match", "dup_of"}, with kind = new (not in the card book, default add) / match (a person in the card book found by email → mobile → name plus company, default merge: that person gets one more record with source import and their current details are filled in with what the file has) / dup (the same person as row dup_of of the same file, default skip; merge folds it into the person that row was imported as) / empty (blank row, skipped). Nothing is written during the comparison; apply writes it and deletes the temporary file, returning added / merged / skipped. The temporary file lasts about 2 hours, after which the API returns 410; a token belonging to someone else or another card book always returns 404. Checking for duplicates: duplicates returns groups (each with people and reasons: same email / mobile / name and company; if A and B share a mobile and B and C share an email they form one group) and can_edit; merge with people/merge. Audit events: business_card_book_import_upload, business_card_book_import (counts only), business_card_book_duplicates.
Merging a previous export or contact list
POST /tools/business-card-reader/api/batches/{batch_id}/list-merge # multipart file(CSV / XLSX / ODS / VCF / JSON)
POST /tools/business-card-reader/api/batches/{batch_id}/list-merge/{token}/plan # {"mapping"?, "scope", "pairs"?}
POST /tools/business-card-reader/api/batches/{batch_id}/list-merge/{token}/download # 參數同匯出(csv / xlsx / ods / vcf / json)+ decisions
DELETE /tools/business-card-reader/api/batches/{batch_id}/list-merge/{token}
POST /tools/business-card-reader/api/batches/{batch_id}/list-merge/{token}/ai-check # 選用,見下
You can upload a file you exported here before (all five formats are accepted; VCF also accepts vCards exported from phones or address books) or your own contact list, and merge it with this batch with duplicates removed. The upload returns token, kind (the file type), headers, the first 5 rows, mapping (column number → field, matched automatically) and the available targets; VCF / JSON are first laid out as the same table as an export (Chinese column names). The list is kept only in the server's temporary area (about 2 hours) and used only for this merge; after it expires the API returns 410. plan returns each person's kind (new new / same identical / update fills in what the list is missing / conflict the two differ; list rows with no match are untouched and kept as they are), the diffs, and pairs the rules could not decide; the pairs parameter lets you state that a person is a given row of the list. When several rows match under the same rule, the row with the fewest differences that no other card has taken is chosen (so duplicates in the list, or a card's front and back stored as two rows, are not both merged into one row). download takes decisions = {contact_id: add | merge | skip | keep_list | use_card}: all original rows and columns are kept in the same order and new people are added at the end; when saving as VCF / JSON, columns that are not mapped to a field are left out. Lists with a title row above the headings (headings on row 2, as in the card roster layout) are recognised too; when Chinese and English headings sit side by side (company name + Company Name, name + Full Name), the English column maps to the foreign-language field, and the category column maps to tags. When the uploaded file is a card roster, saving as XLSX writes it back in the same layout (new people get today's date added); other lists can be saved as a card roster with layout=roster. Importing a file into a card book recognises this layout as well. Limits are 20 MB, 5,000 rows and 100 columns; old Excel files (.xls) are not accepted.
AI assist (optional, off by default)
GET /tools/business-card-reader/api/ai # 有沒有開、模型、資料送到哪台主機
POST /tools/business-card-reader/api/batches/{batch_id}/contacts/{contact_id}/ai-suggest
POST /tools/business-card-reader/api/batches/{batch_id}/list-merge/{token}/ai-check # {"pairs": [{"contact_id", "row"}]}(最多 30 組)
Requires the site-wide LLM to be enabled and an administrator to turn it on under Settings → Card books; otherwise the API returns 409. ai-check sends only the field text of those pairs and returns same / confidence / reason; ai-suggest sends only that card's OCR text in text mode, or that one cropped card image in image mode, and every field it returns has status: check, with reason saying so when it differs from the OCR text. AI results are only suggestions and are never written into contacts by themselves. Audit event business_card_ai (only counts are recorded).
A batch's expires_at is counted from creation using the days the administrator sets under File retention / cleanup (business_cards_days, default 30; 0 = never, expires_at is null); batches are deleted with the account. GET /tools/business-card-reader/handoff-qr returns a QR code (PNG) of this page's address for "Continue on a phone"; it carries no sign-in information.
Mailbox retrieval on FUJIFILM MFPs and Document Server retrieval on RICOH MFPs (IM C2000, IM C2010, IM C2510, IM C3500, IM C3510) have been verified on real devices; retrieval on other brands and models is experimental. For now it can add MFPs, run connection tests and identify the model, scan from MFPs that support eSCL (AirPrint / Mopria scanning) straight into the workspace, use shared MFPs set up by an administrator, and retrieve documents from FUJIFILM mailboxes, from Canon / Konica Minolta / SHARP file shares and directly from KYOCERA / RICOH (all experimental). The tool page and the admin page on the web use these same endpoints. The tool was called Fetch from MFP and is renamed MFP Scan & Fetch from v1.16.89; its URLs and tool ID are unchanged.
Every MFP belongs to the caller (the token's owner when called with an API token): someone else's MFP always returns 404, without revealing whether it exists. Shared MFPs are created by an administrator who chooses members (users, or groups including subgroups); members can see them, test them again and scan, but cannot rename or remove them. Without sign-in enabled, only a browser on the server itself or a call with a valid API token is accepted.
Audit: every action is written to the audit log (connection tests, adding / renaming / removing MFPs, listing documents, shared MFP and member settings). Scans and retrievals write two entries: when submitted (mfp_scan_start, mfp_box_fetch, mfp_share_fetch, recording which documents were chosen and whether originals are to be deleted) and when finished (mfp_job_done, recording the actual result, the number of files saved to the workspace, and which originals were deleted from the device). Passwords and document contents are not recorded.
What a connection test may touch: internal network addresses only (private IPs; loopback, link-local, public addresses and this server's own addresses are always refused), web ports 80, 443, 8080 and 8443 only; only GET requests (the home page and the eSCL capabilities /eSCL/ScannerCapabilities), never any credentials or cookies; redirects are followed only within the same device. At most 10 per person in 5 minutes, one at a time.
Whether users may add their own MFPs is up to the administrator (allowed by default; see Usage settings below). When it is off, regular users get 403 (USER_DEVICES_DISABLED) from the connection test and from saving; MFPs they added earlier show paused: true in the list and cannot be tested, scanned from or fetched from, but can still be renamed and removed. Shared MFPs work as usual and administrators are not restricted.
Queueing: each physical device (judged by its resolved address) does one thing at a time. A connection test waits up to 30 seconds and otherwise returns 429 (DEVICE_BUSY, with waiting); scans queue in the background. At most 10 jobs per device (DEVICE_QUEUE_FULL) and 2 per person on the same device (OWNER_QUEUE_FULL); beyond that 429 is returned and nothing is sent to the device.
Connection test
POST /tools/mfp-fetch/api/detect
| Parameter (JSON) | Type | Required | Description |
|---|---|---|---|
host | string | ✓ | MFP IP address or host name (without http://, a path or a port) |
port | int | 80 / 443 / 8080 / 8443; if omitted, both HTTPS 443 and HTTP 80 are tested | |
scheme | string | http / https; if only the port is given, it is inferred from the port |
curl -X POST http://localhost:8765/tools/mfp-fetch/api/detect \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"host": "192.168.1.50"}' | jq
{
"ok": true,
"token": "(15 分鐘內有效,用來儲存這台)",
"report": {
"target": {"host": "192.168.1.50"},
"steps": [{"step": "dns", "ok": true, "code": "ADDR_OK", "message": "位址通過檢查(內部網路)"}],
"attempts": [{"scheme": "https", "port": 443, "reachable": true,
"steps": [{"step": "tls", "ok": false, "code": "TLS_VERIFY_FAILED",
"detail": {"reason": {"verify_message": "self-signed certificate"}}}]}],
"detection": {"vendor": "FUJIFILM", "family": "Apeos", "model": "C5571",
"status": "first_batch_unverified", "evidence": [{"what": "model", "field": "title"}]},
"summary": {"reachable": true, "reachable_on": ["https:443"], "status": "first_batch_unverified",
"scan": true},
"escl": {"scheme": "https", "port": 443, "model": "...",
"sources": {"platen": {"colors": ["color", "gray"], "formats": ["pdf", "jpeg"],
"resolutions": [200, 300, 600]}}}
}
}
The report's escl is this device's eSCL scanning capability (null if none): which sources it has (platen flatbed glass, adf document feeder, adf_duplex two-sided) and the colours, formats and resolutions each offers. Only MFPs with escl can use Scanning below.
Passwords, Authorization, cookie values, CSRF tokens and session IDs in the report are always masked as "masked, length N"; page content keeps only the first 500 characters after removing tags, and forms list only field names and types. An address or port that breaks the rules returns 400 with a code such as ADDR_LOOPBACK, ADDR_PUBLIC, PORT_NOT_ALLOWED or HOST_INVALID; too many tests return 429 (RATE_LIMITED / BUSY).
detection.status values:
supported: verified on a real device (currently Apeos C5571)supported_same_series: same series as a verified model (Apeos C7071 / C6571 / C4571 / C3571 / C3071 / C2571, verified on a real Apeos C5571)first_batch_unverified: a planned first-batch model, not yet verified on a real devicesame_vendor_unverified: same vendor, support not yet verifiedexperimental_vendor: Canon, Konica Minolta and SHARP (file share retrieval) and KYOCERA and RICOH (direct retrieval), all experimentalunsupported_vendor: another vendor with no retrieval method yet (MFPs with eSCL can still scan)login_required: the model can only be identified after signing inunknown: the model could not be identifiedunreachable: the device could not be reached
supported means the model has passed retrieval on a real device: FUJIFILM Apeos C5571 (the same series is marked supported_same_series) and RICOH IM C2000 / C2010 / C2510 / C3500 / C3510. Previously stored detection results follow the current list, so no retest is needed.
My MFPs
GET /tools/mfp-fetch/api/connections # 清單
POST /tools/mfp-fetch/api/connections # 儲存:{"token": "...", "display_name": "三樓行政區"}
GET /tools/mfp-fetch/api/connections/{id} # 單筆(含最近一次報告)
PATCH /tools/mfp-fetch/api/connections/{id} # 改名:{"display_name": "..."}
POST /tools/mfp-fetch/api/connections/{id}/test # 用存下來的位址與連線方式重新測試
GET /tools/mfp-fetch/api/connections/{id}/report # 下載最近一次診斷報告(見下方「診斷報告」)
DELETE /tools/mfp-fetch/api/connections/{id} # 從清單移除(不影響設備)
Saving accepts only the token returned by the connection test (not an address), so what is saved is always the device that was tested; an expired token or one belonging to someone else returns 410. Saving the same address and connection twice returns 409 (DUPLICATE), and each person can save up to 20 (LIMIT). For now no credentials are stored.
Each entry in the list also has shared (whether it is a shared MFP), can_manage (whether it can be renamed or removed), scan (whether it can scan and which settings are available, null without eSCL), box (whether mailbox retrieval is available; FUJIFILM only for now), share (the file share retrieval methods available, for example {"routes": ["canon_webdav", "canon_smb"]}, null if none), paused (your own MFP is paused because an administrator turned off adding your own) and queue ({"busy": true, "waiting": 1, "kind": "scan"}, whether the device is busy now and how many are waiting). The list itself also returns can_add (whether the caller may add MFPs). Shared MFPs are read-only for members: renaming and removing return 403 (SHARED_READ_ONLY). There is also rules_stale: the last result came from older identification rules and the device was not identified then (unknown / unsupported_vendor / login_required), so testing again may identify it (the web page shows it as ready to retest).
MFPs belong to the account, not the browser: the same account sees the same list after signing in on another computer. Local, LDAP and SSO accounts are separate accounts, each with its own list.
Remembered settings
GET /tools/mfp-fetch/api/connections/{id}/prefs?kind=box # kind:box(機內信箱)或 share(檔案分享 / 直接取件)
PUT /tools/mfp-fetch/api/connections/{id}/prefs # {"kind": "box", "patch": {"trust": "<64 碼 sha256>", "box": "96"}}
The trusted certificate fingerprint (trust), consent to send over HTTP or without encryption (http / plain), the last mailbox number (box), the account (user), the connection target (target), the retrieval method (route) and the sign-in method (mode) are stored on the server with the account. No password is ever stored; unknown fields and malformed values are dropped, and null or an empty string clears a value.
Shared MFPs: the trust / http / plain set by an administrator are the device's settings, and members read that copy (managed in the response lists the fields set by an administrator). A member changing those fields gets 409 (PREF_MANAGED), and a fingerprint or consent sent with a retrieval request is replaced by the administrator's settings. Where an administrator has not set them, members can store their own. Changing trust / http / plain is audited (mfp_trust, first 16 characters of the fingerprint only).
Diagnostic report
The full record of a connection test, downloadable in a choice of formats. For a saved MFP you get the latest test; for an unsaved test result use the token returned by the connection test.
GET /tools/mfp-fetch/api/connections/{id}/report?format=pdf # 已儲存的事務機
POST /tools/mfp-fetch/api/detect/report # 還沒儲存的測試結果:{"token": "...", "format": "pdf"}
The format parameter selects the format:
- Omitted or
json: the raw report with every field; attach this one to a problem report. - The readable versions
txt,md,htmlandpdf: the same content as Details on the page, with fixed text in the interface language (jtdt_localecookie).
Accounts, passwords, cookies and session information are masked when the report is produced, so no format adds anything. The token from the connection test works only for its owner for 15 minutes, and downloading does not use it up (you can still save afterwards); an expired token or someone else's returns 404 (REPORT_EXPIRED). An unknown format returns 422 (REPORT_FORMAT_INVALID).
curl -o mfp-report.pdf "http://localhost:8765/tools/mfp-fetch/api/connections/3/report?format=pdf" \
-H "Authorization: Bearer YOUR_TOKEN"
Scanning (eSCL)
Scan from an MFP into the caller's own workspace. Put the document on the glass (or in the feeder) before calling.
POST /tools/mfp-fetch/api/connections/{id}/scan # 開始掃描(202,回掃描紀錄)
GET /tools/mfp-fetch/api/scans # 最近 20 筆
GET /tools/mfp-fetch/api/scans/{scan_id} # 狀態與進度
POST /tools/mfp-fetch/api/scans/{scan_id}/cancel # 取消(排隊中的直接移出;掃描中的會刪掉設備上的掃描工作)
GET /tools/mfp-fetch/api/scans/{scan_id}/download # 沒存進工作區時下載(留 24 小時;多個檔案打包成 ZIP)
| Parameter (JSON) | Type | Description |
|---|---|---|
source | string | A source listed in this device's scan.sources: platen (default), adf, adf_duplex |
color | string | color (default) / gray / bw |
resolution | int | Resolution (dpi), one this device supports; default 300 |
paper | string | a4 (default) / letter / max |
format | string | Save as pdf (default, pages combined into one file) or jpeg (one file per page; the MFP must be able to send JPEG); the allowed values are in scan.sources.<source>.outputs |
file_name | string | File name (optional, up to 100 characters, the extension is added automatically; paths and special characters are removed) |
hold | bool | true: hold the scan instead of saving it to the workspace (marked HELD), then save it as one PDF with "Hold now, merge later" below. Only applies when saving as PDF; default false |
curl -X POST http://localhost:8765/tools/mfp-fetch/api/connections/3/scan \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"source": "platen", "color": "gray", "resolution": 300, "file_name": "合約掃描"}' | jq
A job's status: queued (ahead is how many are in front), running (phase is checking / scanning / merging / downloading / saving), done (pages, bytes, workspace_file_id), error (error_code, error_message) or cancelled. kind is scan (scanning) or box (mailbox retrieval), and files lists every file saved (name, pages, workspace_file_id, has_file). Files are saved only to the caller's own workspace; nobody else can look them up or download them by id. settings.via is the protocol used this time (for example {"protocol": "eSCL", "scheme": "https", "port": 443}) and tls_verified whether the certificate was verified.
Settings outside the device's capabilities return 400 (SCAN_OPTION_INVALID); a device without eSCL returns 400 (SCAN_NOT_SUPPORTED); a full queue returns 429. Errors during the scan are in the record's error_code: SCAN_DEVICE_BUSY (someone is using the device), SCAN_ADF_EMPTY, SCAN_AUTH_REQUIRED (the device requires sign-in to scan, not supported yet), SCAN_NO_DOCUMENT, SCAN_BAD_DOCUMENT, SCAN_TOO_LARGE, SCAN_TIMEOUT and so on. No credentials are sent.
Hold now, merge into one PDF later
The scanner glass takes one page at a time: send each scan with "hold": true so it is held (not saved to the workspace), check the preview, scan the next sheet, and finally merge the pages in the order you want into one multi-page PDF saved to the workspace. Held for 24 hours; up to 40 held scans per person (beyond that returns 400 HOLD_TOO_MANY), and up to 300 pages per merge.
GET /tools/mfp-fetch/api/scans/held?conn_id={id} # 還沒合併的暫存掃描(conn_id 選填)
GET /tools/mfp-fetch/api/scans/{scan_id}/preview/{page}?w=240 # 第 page 頁(從 0 起算)的預覽 PNG;w 是 240 或 1200
POST /tools/mfp-fetch/api/scans/merge # 合併成一份 PDF 存進工作區(回新的掃描紀錄)
POST /tools/mfp-fetch/api/scans/discard # 清除暫存的掃描
Merge body: pages is [["scan id", page], …]; that order is the page order of the result and pages you do not want can be left out. file_name is optional; release is optional and lists further held scans to remove (for example ones where every page was dropped). The held scans used are removed after merging (their workspace_note becomes MERGED_SOURCE). Sources that are not the caller's, have expired or were removed return 404 (MERGE_SOURCE_GONE). When the workspace is disabled the merged result is kept in temporary storage for 24 hours for the owner to download, like a normal scan.
curl -X POST http://localhost:8765/tools/mfp-fetch/api/scans/merge \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"pages": [["9f2c…", 0], ["a71b…", 0], ["9f2c…", 1]], "file_name": "合約"}' | jq
Discard body: {"scans": ["scan id", …]}; returns {"discarded": count} (scans that are not the caller's are not counted).
Mailbox retrieval (FUJIFILM, experimental)
Built from research and not yet verified on a real device. Based on research into the manufacturer's retrieval tool, it reads the mailbox of a FUJIFILM MFP over WebDAV (PROPFIND to list documents, GET to download). Only these two requests are sent, so nothing on the device is deleted or changed; but if the device or mailbox is set to delete after retrieval, the device deletes the documents itself (see the delete-after-retrieval confirmation parameter below). Only MFPs identified as FUJIFILM that the connection test can reach are supported; others return 400 (BOX_NOT_FUJIFILM).
POST /tools/mfp-fetch/api/connections/{id}/box/list # 列出信箱裡的文件
POST /tools/mfp-fetch/api/connections/{id}/box/fetch # 取件(202,回作業紀錄;進度一樣看 /api/scans/{id})
| Parameter (JSON) | Type | Description |
|---|---|---|
box | int | Mailbox number (1 to 999) |
box_password | string | Mailbox password (omit if none) |
user / password | string | Only needed when the MFP requires a sign-in: the user's account and password on the MFP |
trust_sha256 | string | When the HTTPS certificate cannot be verified (MFPs usually use self-signed certificates), the certificate's SHA-256 fingerprint as checked by the user |
allow_http | bool | Must be true when the MFP only uses HTTP (consent to credentials and documents travelling unencrypted on the internal network) |
target | string | Optional, for example "https:443"; it must be one the connection test could reach, and HTTPS is preferred when omitted |
documents | string[] | For retrieval: the numbers of the documents to fetch (the id from the listing), at most 20 at a time |
output | string | For retrieval: pdf (default, one PDF per document) or original (the TIFF / JPEG exactly as the device sends it, no conversion) |
confirm_delete_after_get | bool | For retrieval: must be true to retrieve when the mailbox or document is set to delete after retrieval |
delete_after | bool | Fetch and delete (experimental): with true, once each document's files are saved (workspace or temporary area), the original on the MFP is deleted with WebDAV DELETE and the box is listed again to confirm. In the job record each document's source is SOURCE_DELETED (deleted) or DELETE_NOT_DONE (the device did not delete it; delete_status is the device's status code); a document that was not saved gets delete = DELETE_SKIPPED_NOT_SAVED and is not deleted. With this set, confirm_delete_after_get is not needed |
curl -X POST http://localhost:8765/tools/mfp-fetch/api/connections/3/box/list \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"box": 1, "box_password": "1234", "trust_sha256": "9F:2A:..."}' | jq
{
"ok": true,
"box": 1,
"box_name": "Box 1",
"delete_after_get": false,
"documents": [{"id": "5", "name": "報價單", "pages": 3, "size": 482113, "modified": "...",
"format": "TIF", "compression": "MMR", "how": "whole", "delete_after_get": false}],
"via": {"protocol": "WebDAV", "scheme": "https", "port": 443},
"tls": {"verified": false, "pinned": true, "sha256": "9f2a..."},
"trace": [{"method": "PROPFIND", "path": "/dav/box-1", "depth": "1", "status": 401,
"challenges": [{"scheme": "digest", "realm": "box-1"}]},
{"method": "PROPFIND", "path": "/dav/box-1", "depth": "1", "status": 207, "auth": "digest"}]
}
Credentials are used only for this request (for box/fetch, only in that job's memory) and are never written to the database, logs or the protocol log. When the device asks for authentication they are sent once, and a failure stops there (no other combinations are tried, to avoid locking the account). trace is the protocol log (method, path, status code, authentication scheme and realm, no credentials), for comparison when testing on a real device.
Errors on the device side always return 422 (not 401, which is this site's own sign-in), with code:
- Certificate not verified:
TLS_UNTRUSTED, with the fingerprint and details indetail.certificate; after checking it, call again withtrust_sha256 - Certificate differs from the trusted fingerprint:
TLS_IDENTITY_FAILED; stopped without accessing the mailbox - The MFP only uses HTTP:
PLAIN_HTTP_NEEDS_CONSENT; sendallow_http: true - A mailbox password or an MFP account is needed:
AUTH_REQUIRED_BOX,AUTH_REQUIRED_USER - Authentication failed, or the device asks for an unsupported method:
AUTH_FAILED,AUTH_MODE_UNSUPPORTED - Mailbox not found, no permission, WebDAV not enabled, or an unexpected response:
BOX_NOT_FOUND,BOX_FORBIDDEN,WEBDAV_UNAVAILABLE,DAV_BAD_RESPONSEand so on - The device did not accept this request (HTTP 406):
DAV_REQUEST_NOT_ACCEPTED;detail.stageis the stage that was refused (probeorlist) anddetail.profileis the request format used (modern/legacy)
Retrieval jobs share the scan job record (kind: "box"): files lists every file saved (name, pages, workspace_file_id) and items the result for each document (status, error_code, format_note, and source: SOURCE_KEPT the original is still there / SOURCE_GONE it is no longer on the device / SOURCE_UNKNOWN). When some documents were not retrieved, status is still done and error_code is BOX_PARTIAL. If conversion to PDF fails (for example a TIFF with an unsupported compression), the original files are saved instead and format_note is PDF_FALLBACK_ORIGINAL.
File share retrieval (Canon, Konica Minolta, SHARP, KYOCERA, RICOH; experimental)
Experimental and not yet verified on a real device. Following the methods published in the manufacturers' manuals, it reads file shares on the MFP: Canon Advanced Box (shared and personal space over WebDAV or SMB), Konica Minolta public user boxes (SMB) and the NAS of SHARP MFPs (SMB). KYOCERA document boxes and the RICOH Document Server are read through the device's document service (SOAP), based on an analysis of the manufacturers' tools; this is not an interface the manufacturers publish. It only reads and never deletes, renames or writes files on the device. MFPs that can use it show the available methods in the list; other vendors return 400 (SHARE_ROUTE_INVALID).
POST /tools/mfp-fetch/api/connections/{id}/share/list # 列出位置、資料夾與檔案
POST /tools/mfp-fetch/api/connections/{id}/share/fetch # 取件(202,回作業紀錄;進度看 /api/scans/{id})
| Parameter (JSON) | Type | Description |
|---|---|---|
route | string | Retrieval method: canon_webdav, canon_smb, konica_smb, sharp_smb, kyocera_soap (HTTPS 9091), kyocera_soap_http (HTTP 9090) or ricoh_soap (the scheme and port the connection test reached) (share.routes in the list) |
root | string | Location: for Canon, share (shared space) or users (personal space); for SHARP, a share the device lists; for Konica it is found from the box number and is not needed; for KYOCERA, the document box number or polling (polling box, listing only); for RICOH, documents (the Document Server's shared folder) or a folder id returned by listing (starting with ~) |
path | string[] | For listing: the folder path, one name per level (for example ["2026", "十月"]); omit it for the top of the location |
user / password | string | Canon, SHARP, KYOCERA, RICOH: the account and password on the MFP (omit if no authentication is set; RICOH needs them when signing in with an account and password); write a domain account as 網域\帳號 (domain\account) |
box / box_password | string | Konica: the box number and box password. KYOCERA: box_password is the document box password; RICOH: box_password is the document password (only for documents that have one) |
auth_mode | string | RICOH sign-in method: auto (default: an account means account and password, a User Code uses the type the device lists, and with neither "No sign-in" is used), none (no sign-in), account (account and password: exchanged for a ticket when the device supports it, otherwise startSession), user_code, user_code_ext (User Code, extended User Code). Sign-in is sent once and no other method is tried |
user_code | string | RICOH User Code (digits only; leading zeros are kept) |
folder_password | string | Password of a RICOH Document Server folder (4 to 8 digits, sent as a string with leading zeros kept); sent only once: a wrong one returns FOLDER_PASSWORD_FAILED, and if the folder has a password and none is given, folder_state is returned |
trust_sha256 / allow_http | The WebDAV certificate fingerprint and HTTP consent, as for mailbox retrieval | |
allow_plain | bool | SMB is not encrypted, so this must be true (consent to files travelling unencrypted on the internal network) |
files | string[][] | For retrieval: the files to fetch, each a path (for example [["2026", "合約.tif"]]), at most 50 at a time |
output | string | For retrieval: pdf (default: TIFF / JPEG become PDF, PDF and other files stay as they are) or original (nothing is converted) |
Listing returns roots (the available locations; label is the display name and shared marks shared ones), root, path, entries (name, dir, size, modified), shared, via ({"protocol": "WebDAV"}, {"protocol": "SMB", "port": 445} or {"protocol": "SOAP"}) and trace (the protocol log, no credentials). For KYOCERA / RICOH, entries[].name is an encoded identifier (starting with ~); put it into files as is when retrieving and show label. A RICOH document with a password has locked set to true. RICOH retrieval covers documents in the Document Server: besides the shared folder, roots includes the device's folders (folder: true; locked is true / false, or null when the device does not say). When a folder with a password is chosen without folder_password, roots is still returned along with folder_state (code is FOLDER_PASSWORD_REQUIRED, FOLDER_PASSWORD_FAILED or FOLDER_LOCKED). When the folder list cannot be read, only the shared folder is listed and folder_error gives the reason. KYOCERA's polling (polling box) can be listed; retrieving from it returns KYOCERA_POLLING_DOWNLOAD_UNCONFIRMED (the parameters are still being confirmed and no guessed values are sent). Other people can see shared locations too; they are not just the caller's documents.
SMB uses NTLMv2 only; if the device only offers SMB1 it stops before authenticating (SMB1_REFUSED), messages are signed when the device supports it, and content is not encrypted. Errors on the device side always return 422: SMB_PLAIN_NEEDS_CONSENT, SMB_AUTH_FAILED, SMB_CONNECT_FAILED (port 445 closed), SHARE_FORBIDDEN, SHARE_NOT_FOUND, BOX_SHARE_NOT_FOUND (no share found for this Konica box), SHARE_LOGIN_PAGE, and the same TLS_UNTRUSTED, AUTH_FAILED and so on as mailbox retrieval. KYOCERA / RICOH also return SOAP_UNAVAILABLE (the device's document service did not respond), BOX_PASSWORD_FAILED, DOC_PASSWORD_REQUIRED, DOC_PASSWORD_FAILED, SESSION_EXPIRED, SOAP_BUSY, RICOH_AUTH_UNSUPPORTED (the device offers no usable sign-in method), RICOH_AUTH_MODE_REQUIRED (no sign-in method chosen yet; nothing was sent), RICOH_AUTH_MODE_MISMATCH, RICOH_AUTH_INPUT_CONFLICT, RICOH_AUTH_PROFILE_UNSUPPORTED, RICOH_USER_CODE_REQUIRED, RICOH_PASSWORD_UNSUPPORTED, RICOH_SESSION_REJECTED (the device did not accept this sign-in) and RICOH_URL_UNSUPPORTED (the download address is not on this device, or is FTP). When a document comes back in several parts, pdf merges them into one in order and original saves each as a numbered file. The job record's kind is share; the other fields are the same as for mailbox retrieval.
Shared MFPs (administrators)
Created by an administrator, who chooses the members (users or groups; a group includes the members of its subgroups). Non-administrators get 403 (ADMIN_ONLY). On the web it is under Settings, Shared MFPs. Members still need access to the MFP Scan & Fetch tool.
GET /tools/mfp-fetch/api/shared # 清單(含成員數)
POST /tools/mfp-fetch/api/shared # 建立:{"token": "...", "display_name": "三樓"}(token 來自管理員自己的 /api/detect)
PATCH /tools/mfp-fetch/api/shared/{id} # 改名
POST /tools/mfp-fetch/api/shared/{id}/test # 重新測試
DELETE /tools/mfp-fetch/api/shared/{id} # 移除(成員一起清掉)
GET /tools/mfp-fetch/api/shared/{id}/members # 成員(含名稱,以及使用者有沒有這支工具的權限)
PUT /tools/mfp-fetch/api/shared/{id}/members # 整份換掉:{"members": [{"type": "user", "key": "12"}, {"type": "group", "key": "3"}]}
GET /tools/mfp-fetch/api/shared-subjects # 挑成員用:使用者與群組清單
Members must be existing users and groups; anything else returns 400 (MEMBERS_INVALID). Membership is removed when the account or group is deleted; deleting the creator's account does not delete the shared MFP.
Administrators must also be listed as members to see the device in their own list of MFPs.
GET /tools/mfp-fetch/api/shared/local # {"count": 2}:未啟用登入時新增的事務機有幾台
POST /tools/mfp-fetch/api/shared/adopt-local # 轉成共用事務機:{"moved": 1, "left": 1}
MFPs added while sign-in was off belong to the local machine, and no account can see them once sign-in is turned on. adopt-local turns them into shared MFPs (together with the certificate trust and consent recorded then); set the members afterwards. Devices with the same address and connection method as an existing shared MFP are not moved (left is the number left behind), nor are any beyond the shared MFP limit. Calling it while sign-in is off returns 400; it is audited (mfp_shared_adopt_local).
Usage settings (administrators)
GET /tools/mfp-fetch/api/settings # {"settings": {"allow_user_devices": true, "updated_at": ...}}
PUT /tools/mfp-fetch/api/settings # {"allow_user_devices": false}
The allow_user_devices setting (default true) decides whether regular users may add their own MFPs. The value must be true / false, otherwise 400 (SETTINGS_INVALID); non-administrators get 403. Changes are audited (mfp_settings_update), and the MFP Scan & Fetch category of the settings backup includes it. On the web it is Usage settings at the top of Settings, Shared MFPs.
9c. Seal request API
To use a seal set to "approved requests only", submit a seal request and have it reviewed stage by stage; once every stage approves, the seal's custodian confirms the stamping. The feature must be enabled by an administrator and account login must be enabled; otherwise every endpoint returns 404. All endpoints require sign-in (the browser session cookie, or an API token bound to a user), and only requests you are involved in are visible; unrelated requests, documents and attachments always return 404.
| Endpoint | Method | Description |
|---|---|---|
/seal-request/api/home | GET | Flows I can use, and how many requests await my review |
/seal-request/api/flows/{flow_id}/assets | GET | Seals I can request in this flow (name, type and size only, no original image) |
/seal-request/api/cases | GET | Request lists: box=mine (my requests), review (awaiting my review), stamp (awaiting my stamping), handled (handled by me), all (administrators and auditors) |
/seal-request/api/cases | POST | Create a draft; body {"flow_id": 1} |
/seal-request/api/cases/{case_id} | GET / PUT / DELETE | Read; edit the subject and purpose (subject, purpose required), recipient, document type, preferred completion date, notes, requested seals (assets) and preferred positions (placements: asset_id, doc (which document; omitted = the first), page, position as br / bl / tr / tl / center / custodian); delete only drafts that were never submitted |
/seal-request/api/cases/{case_id}/documents | POST | Add a document to stamp (PDF, or an office document that can be converted to PDF; PDFs with an open password or a digital signature are rejected). Up to 20 per request; beyond that returns 400 TOO_MANY_DOCS. The returned case.docs is the current document list (id, name, pages, page_sizes) |
/seal-request/api/cases/{case_id}/documents/{doc_id} | GET / DELETE | Download one document (version selects a version); remove one (drafts and returned requests only; preferred positions on it are removed too) |
/seal-request/api/cases/{case_id}/documents/{doc_id}/pages/{page} | GET | Preview image of one page of one document (PNG) |
/seal-request/api/cases/{case_id}/document | POST / GET | Legacy: uploading replaces all documents with this one; download returns the first |
/seal-request/api/cases/{case_id}/pages/{page} | GET | Legacy: preview image of a page of the first document |
/seal-request/api/cases/{case_id}/attachments | POST | Add a reference attachment (not stamped) |
/seal-request/api/cases/{case_id}/attachments/{att_id} | GET / DELETE | Download / remove a reference attachment |
/seal-request/api/cases/{case_id}/submit | POST | Submit (also used to resubmit after changes, which creates a new version reviewed again from the first stage) |
/seal-request/api/cases/{case_id}/approve | POST | Approve (only reviewers whose turn it is, never the applicant); the body may carry {"comment": "…"} |
/seal-request/api/cases/{case_id}/return | POST | Return for changes; comment is required |
/seal-request/api/cases/{case_id}/reject | POST | Reject; comment is required |
/seal-request/api/cases/{case_id}/withdraw | POST | Withdrawn by the applicant |
/seal-request/api/cases/{case_id}/comment | POST | Comment; body {"text": "…"} (does not change the review status) |
/seal-request/api/cases/{case_id}/assets/{asset_id}/image | GET | The approved seal image (only for this request's custodian, and only while awaiting stamping, stamping or after a failed attempt) |
/seal-request/api/cases/{case_id}/stamp | POST | The custodian confirms stamping: placements (each with asset_id, doc, page, x_mm, y_mm, width_mm, height_mm, rotation_deg; approved seals only, each seal at least once and each document at least once, otherwise 400 SEAL_NOT_USED / DOC_NOT_STAMPED) and exec_id (an ID for this click, 32 hex digits; resending the same ID never stamps twice). Returns 409 DOC_CHANGED / ASSET_CHANGED if any document or seal image differs from the approved one. Stamping completes only when every document succeeds; if one fails, none count |
/seal-request/api/cases/{case_id}/custodian-return | POST | The custodian returns the request to the applicant; comment is required |
/seal-request/api/cases/{case_id}/result | GET | Download the stamped PDF (after voiding, only auditors can); with several documents, no parameter returns a ZIP and doc=<doc_id> downloads just that one |
/seal-request/api/cases/{case_id}/result/workspace | POST | The applicant saves the stamped PDF to their own workspace (with several documents, each is saved as its own file; returns file_ids) |
curl http://localhost:8765/seal-request/api/cases?box=review \
-H "Authorization: Bearer YOUR_TOKEN" | jq
Errors always return {"ok": false, "code": "…", "message": "…"}; for example, submitting when a stage lacks eligible reviewers returns 409 INSUFFICIENT_APPROVERS (detail gives the stage, how many are needed and how many there are), and a state already changed by someone else returns 409 BAD_STATE.
Long or batch operations go through the job queue. The flow:
- Call the tool's submit endpoint → receive
{"job_id": "..."} - Poll
GET /api/jobs/{job_id}untilstatus == "completed" - Download the result with
GET /api/jobs/{job_id}/download(a single PDF, or a ZIP for several files)
LLM verification (pdf-fill)
POST /api/llm-review
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✓ | PDF (fields already filled, ready for verification) |
template_id | str | ✓ | Template ID (the layout remembered in the admin area) |
rounds | int | Number of review rounds; defaults to the admin setting |
curl -X POST http://localhost:8765/api/llm-review \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@filled.pdf" -F "template_id=vendor_form_v3" \
| jq
# → {"job_id": "..."}
Response: {"job_id": "..."}.
Check job status
GET /api/jobs/{job_id}
curl http://localhost:8765/api/jobs/abc123 \
-H "Authorization: Bearer YOUR_TOKEN" | jq
Response:
{
"job_id": "abc123...",
"status": "running",
"progress": 0.65,
"message": "校驗第 5 / 12 欄位",
"error": null,
"tool": "pdf-fill-llm"
}
status:pending / running / completed / failed。
Download a job result
GET /api/jobs/{job_id}/download
GET /api/jobs/{job_id}/download/{filename} # 同一份結果,只是讓瀏覽器存成這個檔名
curl http://localhost:8765/api/jobs/abc123/download \
-H "Authorization: Bearer YOUR_TOKEN" \
--output result.pdf
Response: the result file (PDF / ZIP). If it is not finished (status != completed) the call returns 409.
Download a job result as PNG
GET /api/jobs/{job_id}/download-png
curl http://localhost:8765/api/jobs/abc123/download-png \
-H "Authorization: Bearer YOUR_TOKEN" \
--output result.zip
Response: the job's PDF result rendered as PNG (several pages or files come back as a ZIP).
List your own jobs (“My jobs”)
GET /api/jobs?active=false&limit=50&offset=0
The list behind the “My jobs” page; it only lists your own jobs (active=true lists only queued and running ones). Each row has status, progress, has_result (whether the download file is still there), view_url (the page “Open” goes to) and view_ok.
view_ok in the response says whether the view_url page can still be opened: when view_url is set but view_ok is false, the data has passed its retention period and been cleared. Use view_ok to decide whether to offer “Open”; do not use has_result instead (sentence translation has no download file, yet its “Open” works).
Lets AI clients such as Claude Code, Codex CLI and OpenCode call this site's non-LLM tools over MCP (Model Context Protocol). Off by default; an administrator turns it on under Settings → MCP (AI connection).
POST /mcp # JSON-RPC 2.0(Streamable HTTP,只回 JSON、無狀態)
GET /mcp # 405(不提供 SSE)
POST /mcp/files/upload # 用一次性票證上傳檔案進工作區
GET /mcp/files/download # 用一次性票證下載工作區的檔案
Authentication: Authorization: Bearer <API Token>. The token must also have "Allow MCP" ticked on the settings page; when sign-in is enabled the token must be bound to a user (the "Assigned user" column on the API Token page, or POST /admin/api/tokens/owner) and has that user's permissions (tools the user has no permission for are neither listed nor callable). If an Origin header is sent it must be the site URL's origin. Supported protocol versions: 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05.
A token allowed for MCP works only through MCP (since v1.17.38): calling the regular API with it directly returns 403 MCP_TOKEN_REST_DENIED. AI clients can read the token from their own configuration; if the same token could also call the API directly, the limits enforced by this MCP layer (AI stamping, no images in the PDF editor, tools not opened to MCP) would have no effect. For programs that call the API, create a separate token without MCP.
The tool list has only 9 fixed tools (it does not grow with the number of site tools offered, so it does not fill the model's context):
| MCP tool | What it does |
|---|---|
jtdt_catalog | Lists the tools you can run (name, category, one-line summary) |
jtdt_describe | Parameters, input files and an example for one tool |
jtdt_run | Runs a tool: tool, files (workspace file IDs), params; results go to the workspace. Returns a job_id after about 45 seconds |
job_status | Waits for / gets the result of jtdt_run |
workspace_list | Lists the files in your workspace |
workspace_upload_url | Gets a one-time upload command (curl) so the AI uploads a local file itself |
workspace_upload_inline | Uploads a small file (up to 256 KB) as Base64 (for clients that cannot run commands) |
workspace_download_url | Gets a one-time download command (curl) |
workspace_read_text | Reads a text file from the workspace in pages |
Tools currently available (47):
- Format conversion:
office_to_pdf(Office to PDF),document_to_images(Document to images),image_to_pdf(Images to PDF),pdf_to_markdown(PDF to Markdown),markdown_to_document(Markdown to office document),office_convert(Office format conversion),pdf_to_office(PDF to Word),pdf_to_slides(PDF to slides) - PDF editing:
pdf_merge(Merge files),pdf_split(Split pages),pdf_compress(Compress PDF),pdf_rotate(Rotate pages),pdf_page_numbers(Add page numbers),pdf_watermark(Watermark),pdf_flatten_annotations(Flatten annotations),pdf_remove_annotations(Remove annotations),pdf_encrypt(Protect PDF),pdf_decrypt(Remove PDF password),pdf_n_up(N-up),pdf_clean_metadata(Clear metadata),pdf_reorder_pages(Organise pages),pdf_page_size(Unify page size),pdf_bookmarks(Bookmarks and contents),document_straighten(Scan cleanup),pdf_add_border(Page borders),scan_merge(Scan merge),document_deidentify(Document redaction),pdf_fill_form(Auto-fill forms),pdf_edit(PDF editor) - Extraction and statistics:
pdf_extract_text(Extract text),document_word_count(Word count),pdf_extract_images(Extract images),pdf_ocr(OCR),pdf_extract_attachments(PDF attachments),pdf_hidden_content_scan(Hidden content scan),text_list_process(List tools),transit_proof_parse(Travel receipts),pdf_list_annotations(Annotation report),einvoice_scan(e-Invoice processing),text_deidentify(Text redaction),meeting_transcribe(Meeting recording to transcript),business_card_read(Business card reader) - Comparison:
text_diff(Text compare),document_diff(Document compare),submission_check(Pre-submission check) - Lookup:
vat_lookup(Company ID lookup),pdf_fill_companies(Auto-fill forms: company list)
PDF password removal (pdf_decrypt, which also supports THSR mode), Auto-fill forms (pdf_fill_companies, pdf_fill_form; what gets filled in is company data), Meeting recording to transcript (meeting_transcribe; large files, long processing) and Business card reader (business_card_read; it handles other people's contact details and the results have not been reviewed by a person) are off by default; an administrator has to select them. Tools with an LLM option (document / text redaction, annotation report, e-invoice processing, pre-submission check, auto-fill forms and others) never use an LLM through MCP. The PDF editor (pdf_edit) can only add text and shapes through MCP; images, stamps and signatures are refused. Stamping, seam stamps, LLM-centred tools (official document drafting, sentence translation, document translation, meeting summary), multifunction printers and encrypted paper backup are not available through MCP. Office format conversion and OCR run as background jobs on the server; jtdt_run waits for them to finish, and if that takes too long it returns a job id that the AI checks with job_status. On the settings page, click a tool card to see how the AI calls it, its parameters and what it returns.
Each run calls the tool's own API inside the server with the same token, so checks, permissions and audit are the same as for REST (audit entries are marked as via MCP).
File size limits: the responses of jtdt_catalog and workspace_list include limits (upload_max_mb, audio_video_max_mb, inline_max_kb, workspace_quota_mb, workspace_free_mb, retention_hours, ticket_minutes), so the AI can see them before uploading. The values come from the same settings that are enforced (the smaller of the workspace per-file limit and the site-wide request limit); null means this server sets no limit, and a reverse proxy in front may allow less.
File transfer (file contents never pass through the model): workspace_upload_url / workspace_download_url return a one-time ticket and a curl command. The ticket goes in the X-JTDT-Ticket header (not the URL), is valid for 15 minutes and covers one file; an upload only counts once it is saved (it can be retried after a dropped connection, and sending it again after success returns 409 with the original file ID); a sha256 can be given and a mismatch returns 422; a file larger than declared returns 413; by default the ticket is bound to the source IP that requested it. The URL is built from the configured site URL; when no site URL is set, the address of this call is used (the Host header plus the reverse proxy's X-Forwarded-Proto; no ticket is issued if Host is malformed). An HTTP address needs separate permission from an administrator. The Origin check always uses only the configured site URL and never follows Host.
# 列出工具(JSON-RPC)
curl -s -X POST http://localhost:8765/mcp \
-H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | jq
# 上傳(票證從 workspace_upload_url 拿)
curl -sS --fail-with-body -H 'X-JTDT-Ticket: TICKET' -F 'file=@report.pdf' http://localhost:8765/mcp/files/upload
# → {"ok": true, "file_id": "...", "name": "report.pdf", "bytes": 12345, "sha256": "..."}
Client configuration (the settings page has examples with the address filled in):
# Claude Code
claude mcp add --transport http jt-doc-tools https://docs.example.com/mcp --header "Authorization: Bearer YOUR_TOKEN"
# Codex CLI:~/.codex/config.toml(Token 放環境變數 JTDT_TOKEN)
[mcp_servers.jt-doc-tools]
url = "https://docs.example.com/mcp"
bearer_token_env_var = "JTDT_TOKEN"
{"mcp": {"jt-doc-tools": {"type": "remote", "url": "https://docs.example.com/mcp", "enabled": true,
"oauth": false, "headers": {"Authorization": "Bearer {env:JTDT_TOKEN}"}}}}
Above is OpenCode's opencode.json. Claude Desktop connects through mcp-remote (small files up to 256 KB only).
Limits and audit: each token has limits on calls per minute and concurrent jobs (adjustable on the settings page); every run writes an mcp_call audit record (tool, token name, user, source IP, input and output file IDs), and uploads / downloads write mcp_upload / mcp_download, without document contents or tickets.
Admin endpoints (administrators, session): GET /admin/mcp (settings page), POST /admin/mcp/save (master switch, site URL, enabled tools, rate limits, ticket settings, allow_stamp), POST /admin/mcp/token ({"preview": "<mask>", "allowed": true} turns MCP access on / off for a token; {"preview": "<mask>", "stamp": true} turns AI stamping on / off for it, which needs a bound user and MCP access).
AI stamping (v1.17.38)
AI stamps through MCP with seals from the asset library that were opened to AI beforehand. Off by default; if any of the following is missing the call is refused (and the AI does not see the tools):
- Account sign-in is enabled on the site
- “Allow AI stamping” is on under Settings → MCP
- The API token is bound to a user and has “Stamping” ticked in the token list (revoked automatically when re-bound to someone else or when its MCP access is turned off)
- The user has the Stamp and sign tool permission (Seam stamp for seam stamps)
- The seal is opened to AI under Settings → Seal requests (its mode must be direct use), the user is among those allowed, and today's limit has not been reached
(the daily limit counts placements: stamping 4 places counts as 4; checking and reserving happen in one transaction, and failed stamping gives the usage back)
Uploaded images and text-generated seals are not accepted, and the AI never gets the seal images. Seals limited to approved requests can never be used by AI.
MCP tools (visible only when all conditions are met; not switched one by one under the open tools above): stamp_list (seals you may use), pdf_stamp (seals and signatures), pdf_seam_stamp (seam seals), stamp_request_status (check a request waiting for confirmation), plus the presets added in v1.17.54: stamp_preset_list, stamp_preset_save, stamp_preset_delete.
The matching endpoints are used by MCP internally: they only accept calls that come through MCP (calling them directly with a token allowed for MCP is stopped by the rule above, 403), and a web sign-in cannot stamp through them either. The AI always calls the four MCP tools above through MCP's jtdt_run; they are listed here to document the parameters and responses:
GET /api/ai-stamp/seals?tool=pdf-stamp # 或 tool=pdf-seam-stamp
POST /tools/pdf-stamp/api/ai-stamp # file(PDF 或文書檔)+ placements_json 或 preset(擇一)+ dry_run
POST /tools/pdf-seam-stamp/api/ai-seam-stamp # file + asset_id + 騎縫章設定
GET /api/ai-stamp/requests/{request_id}
GET /api/ai-stamp/presets # 常用組合(自己的)
POST /api/ai-stamp/presets # {"name", "placements"}:新增或覆蓋
POST /api/ai-stamp/presets/delete # {"name"}
placements_json is an array; each item is {"asset_id", "page", 位置, 大小} (from v1.17.54):
page: an integer is the page number (0-based); a string isall、first、last、3、2-5、1,3,5-6(1-based). A page beyond the document returns 400.- Position, pick one:
x_mm/y_mm(top-left origin, displayed page coordinates);anchor(top-left,top-center,top-right,center-left,center,center-right,bottom-left,bottom-center,bottom-right) withmargin_mm(distance from the edges, default 15);anchor_text(text printed on the page, such as a signature label, 1-50 characters) withanchor_side(rightdefault /left/above/below/over),gap_mm(default 2) andanchor_match(firstdefault /last/ a 1-based number). Bothanchorandanchor_textalso takeoffset_x_mm/offset_y_mm(positive = right / down). With none of these the seal's default position from the asset library is used. - With several pages, pages where
anchor_textis not found are skipped (skippedin the response); if no page has it, 400 is returned (scanned PDFs have no text layer, so use coordinates oranchorinstead). - Size: with only
width_mm(or onlyheight_mm) the other side follows the seal's proportions; with neither, the seal's default size is used. Alsorotation_degandopacity(0.05-1). - Computed positions are always kept inside the page (
clampedin the response marks those that were moved).
Up to 50 items per request and 200 placements after expanding pages; the daily limit counts the expanded placements. Numbers must not be NaN or infinite, widths and heights must be above 0 and at most 2000 mm, angles within ±360; unknown fields return 400. preset is the name of a saved preset (use either it or placements_json). The file may be a PDF or an Office document (converted to PDF first).
dry_run=true does not stamp, does not count against the limit and creates no pending request; it returns {"dry_run": true, "placements", "skipped", "preview": {"page", "page_number", "png_base64"}}. The preview is the page of the first placement, with seal positions drawn only as outlines and names, without seal images (a seal not yet confirmed must not look stamped); the seal must still be usable (a seal not opened to AI still gets 403). Through MCP the preview is saved to the workspace and returned as preview_files。
The actual placement of each seal (asset_id, name, page, page_number, x_mm, y_mm, width_mm, height_mm, rotation_deg, opacity, how, clamped) is in the 202 response, or in the X-JTDT-Stamp-Placements header when stamped (JSON; only count when too long); through MCP it is always in the result's placements, ready to reuse next time.
Presets belong to each user (nobody else sees them) and store only placement settings, never seal images; every seal must be usable by you when saving, and each use still goes through authorisation, the daily limit and owner confirmation. Names are 1-40 characters without control characters or < >, up to 50 per user (more returns 409 TOO_MANY_PRESETS); audited as ai_stamp_preset. The owner can also see and delete them on the AI stamp confirmation web page (GET /ai-stamp/api/presets, POST /ai-stamp/api/presets/delete, web sign-in only).
Batch: MCP pdf_stamp accepts 1 to 20 files; each file is sent separately (each is its own AI stamping request with its own usage count and confirmation), and the results are in results (per file source and status: done / pending / error). A failure on one file does not affect files already stamped.
The seam settings are the same as /api/pdf-seam-stamp (mode, group, edge, size_mm, offset_mm, pos_mm, angle_deg, opacity, jitter_pos, jitter_angle, seed), but only asset_id is accepted, not stamp, text, shape or color.
An MCP jtdt_run example (files are workspace file ids uploaded first through /mcp/files/upload):
{"tool": "pdf_stamp", "files": ["<file_id>"],
"params": {"placements_json": "[{\"asset_id\": \"<seal id>\", \"page\": \"last\", \"anchor_text\": \"負責人\", \"width_mm\": 20}]",
"dry_run": true}}
Response: for seals that need no confirmation, the stamped PDF is returned directly (header X-JTDT-AI-Stamp is this request's id); for seals that need confirmation you get 202 {"status": "pending", "request_id", "expires_at"}, and once the token's owner approves it on the AI stamping tab of the Seal requests page (/seal-request#ai; before v1.17.56 this was a separate /ai-stamp page, which now redirects there), the status of GET /api/ai-stamp/requests/{request_id} becomes approved with file.file_id (in the owner's workspace). Approval and rejection only work when signed in on the web (POST /ai-stamp/api/{request_id}/approve, POST /ai-stamp/api/{request_id}/reject); requests carrying an API token always get 403. Unhandled requests become expired after 24 hours and the files are deleted. Conditions are checked again on approval (the seal's AI permission and allowed people, the tool permission, the AI stamping and MCP switches, the account being enabled); if any no longer holds, the response is 409 NO_LONGER_ALLOWED, the request becomes void and its files are deleted. Each person can have at most 20 pending requests and 500 MB of pending files (429 TOO_MANY_PENDING beyond that). Notifications only state the seal names, token name and time, never the file name sent by the AI. The confirmation page also uses GET /ai-stamp/api/pending and GET /ai-stamp/api/{request_id}/preview/{page} (add ?size=large for the enlarged image used when zooming).
Errors: 403 when a condition is not met (the message carries a code such as MCP_OFF, STAMP_OFF, TOKEN_NOT_MCP, TOKEN_NOT_ALLOWED, NOT_VIA_MCP, ASSET_NOT_ALLOWED), 429 when the daily limit is exceeded. The regular /api/pdf-stamp and /api/pdf-seam-stamp refuse calls through MCP (403).
Every stamp writes the audit event ai_stamp (approval / rejection / expiry write ai_stamp_decision): user, token name, seals, pages, SHA-256 of input and output, whether and by whom it was confirmed; never the seal image. The output PDF's document info carries a hidden JTDTAIStamp (id and time). Administrators: GET /admin/mcp/ai-stamp (log page), GET /admin/mcp/ai-stamp.json, GET /admin/mcp/ai-stamp.csv (filters asset_id, user_id, since, until, dates as YYYY-MM-DD); each seal's AI settings are the ai field (enabled, subjects, confirm, daily_limit) of PUT /admin/seal-request/api/assets/{asset_id}.
Requires an administrator sign-in or an admin-role token.
List assets
List every stamp, signature, logo and watermark asset.
GET /admin/api/assets
curl http://localhost:8765/admin/api/assets \
-H "Authorization: Bearer ADMIN_TOKEN" | jq
Read / update LLM settings
GET /admin/api/llm/settings
POST /admin/api/llm/settings
# 讀取
curl http://localhost:8765/admin/api/llm/settings \
-H "Authorization: Bearer ADMIN_TOKEN" | jq
# 更新
curl -X POST http://localhost:8765/admin/api/llm/settings \
-H "Authorization: Bearer ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"enabled":true,"base_url":"http://localhost:11434","model":"gemma4:26b"}'
api_key is never returned as the key itself when read: when a key is set it is "__KEPT__", and an empty string when none is set. When updating, sending "__KEPT__" or leaving the field out keeps the key; a new string replaces it (stored encrypted); an empty string removes it.
Test the LLM connection
POST /admin/api/llm/test-connection
| Parameter | Type | Required | Description |
|---|---|---|---|
base_url | str | The address to test. Omit it and the saved settings are tested instead | |
api_key | str | Same as above; the saved key is used if omitted. When "__KEPT__" is sent, the saved key is only sent if base_url matches the saved one | |
timeout_seconds | num | Capped at 30 seconds, so the admin page cannot hang |
A JSON body. The admin page’s "Test connection" button sends the settings that are not saved yet; from the command line, when you only want to know whether the current settings work, the whole body can be omitted.
# 測目前存檔的設定
curl -X POST http://localhost:8765/admin/api/llm/test-connection \
-H "Authorization: Bearer ADMIN_TOKEN" | jq
# → {"ok": true, "latency_ms": 42, "error": null, "models": [...]}
# 測一組還沒存的設定
curl -X POST http://localhost:8765/admin/api/llm/test-connection \
-H "Authorization: Bearer ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"base_url": "http://10.0.0.5:11434/v1"}' | jq
When the connection fails it still returns 200, with ok: false and an error message; being unable to reach the server is not a failure of this request itself.
Fetch the LLM model list
GET /admin/api/llm/models
curl http://localhost:8765/admin/api/llm/models \
-H "Authorization: Bearer ADMIN_TOKEN" | jq
System dependency status
GET /admin/api/sys-deps
curl http://localhost:8765/admin/api/sys-deps \
-H "Authorization: Bearer ADMIN_TOKEN" | jq
Company logo status
GET /admin/api/branding
curl http://localhost:8765/admin/api/branding \
-H "Authorization: Bearer ADMIN_TOKEN" | jq
Returns whether a company logo has been uploaded, the site name, and the current sidebar colours (sidebar_theme) and built-in logo (builtin_logo). The sidebar_themes list has the 12 schemes (id, kind is gradient or solid, tone is dark or light, name, description), and builtin_logos lists the two built-in logos (jt Jason Tools logo, doc document icon). It also returns the home page logo glow (hero_glow) and title text (hero_title) colours; hero_glows (8, none means no glow) and hero_titles (7) list the available IDs and names.
Sidebar colours and built-in logo
POST /admin/branding/appearance
curl -X POST http://localhost:8765/admin/branding/appearance \
-H "Authorization: Bearer ADMIN_TOKEN" -H "Content-Type: application/json" \
-d '{"sidebar_theme": "ocean", "builtin_logo": "doc"}'
Send one or more of sidebar_theme, builtin_logo, hero_glow and hero_title, using the IDs from the lists in the previous section; if any ID is unknown the call returns 400 and nothing is changed. Returns the updated settings plus sidebar_tone (dark / light) and the logo URLs the sidebar and browser tab should now use (sidebar_logo, icon_logo). An uploaded company logo always wins; the built-in logo choice applies once it is reset. Each change writes an audit record (settings_change, target branding).
Seal requests (administrators)
The feature switch and the per-seal / per-signature restriction settings. The feature is off by default; account login must be enabled first; it cannot be disabled while any seal is set to "approved requests only" (returns 409 STILL_CONTROLLED, with the seals listed in detail.assets). Even before it is enabled you can set up custodians, requesters, flows and the retention period; only switching a seal to approval must wait until the feature is enabled (otherwise 409 NOT_ENABLED).
| Endpoint | Method | Description |
|---|---|---|
/admin/seal-request/api/state | GET | Current state: enabled, auth_enabled, and each seal's and signature's mode, custodians and requesters |
/admin/seal-request/api/enabled | PUT | Enable / disable; body {"enabled": true} |
/admin/seal-request/api/assets/{asset_id} | PUT | Change one seal: mode (direct for direct use / approval for approved requests only), custodians and requesters; people and groups are given as {"type": "user", "key": "user ID"} or {"type": "group", "key": "group ID"} |
/admin/seal-request/api/subjects | GET | Users and groups to choose custodians and requesters from |
/admin/seal-request/api/flows | GET / POST | List / create seal request flows: name, description, enabled, applicants (who can request; empty = anyone), assets (seals; empty = all restricted seals), stages (each with name, rule as any / all / n, n and candidates), watermark (add a watermark when stamping; send {} for none: enabled, source is text / asset; text uses text (up to 100 characters, may contain {編號} / {number} and {日期} / {date}), color, text_size_pt; an image uses asset_id (a watermark-type asset); both take opacity, rotation_deg, size_mm, gap_mm. Invalid settings return 400 BAD_WATERMARK) |
/admin/seal-request/api/flows/{flow_id} | PUT / DELETE | Change (version +1; submitted requests are unaffected) / delete a flow |
/admin/seal-request/api/simulate | POST | Simulate a request (read only: no request is created and nobody is notified): flow (the flow, which may be unsaved), applicant (the applicant's user ID), assets (seals to use; omit for all the flow's seals). Returns result.ok, result.items (each with level error / warn / info / ok, code, detail, e.g. SIM_STAGE_SHORT when a stage lacks reviewers), result.stages (eligible reviewers per stage) and result.common_custodians |
/admin/seal-request/api/cases | GET | Request overview (request details only, no documents); stage.stuck means there are not enough eligible reviewers and the stage needs reassignment |
/admin/seal-request/api/cases/{case_id}/reassign | POST | Reassign the reviewers of the current stage; body {"candidates": […], "reason": "…"}, the reason is required |
/admin/seal-request/api/cases/{case_id}/void | POST | Void a completed request; body {"reason": "…"}, the reason is required |
/admin/seal-request/api/retention | PUT | Request retention period; body {"days": 0} (0 = never delete, at most 36500) |
curl http://localhost:8765/admin/seal-request/api/state \
-H "Authorization: Bearer ADMIN_TOKEN" | jq
Seals set to "approved requests only" return 403 in Stamp & Signature, Seam Stamp and the PDF Editor (including public APIs such as /tools/pdf-stamp/api/pdf-stamp), and their asset image URLs are not served either.
Card books (administrators)
Shared card books and their members, the retention cap for personal card books, and the business card reader's AI assist switch. Administrators manage card books and members but cannot see the people inside. Every change is audited.
| Endpoint | Method | Description |
|---|---|---|
/admin/business-cards/api/state | GET | Current settings: personal_max_days (retention cap for personal card books), ai (AI assist switch, mode and site-wide LLM status), shared (shared card books: name, number of people, retention period, members and roles, without the people inside), personal (number of personal card books and total people) |
/admin/business-cards/api/settings | PUT | Retention cap for personal card books, body {"personal_max_days": 0} (0 = no cap, up to 36500) |
/admin/business-cards/api/ai | PUT | AI assist, body {"enabled": true, "mode": "text"} (mode is text / vision); turning it on has no effect while the site-wide LLM is disabled |
/admin/business-cards/api/books | POST | Create a shared card book, body {"name": "…", "keep_days": 0} |
/admin/business-cards/api/books/{book_id} | PUT / DELETE | Change the name and retention period {"name"?, "keep_days"?}; deleting requires {"confirm": "名片簿名稱"} with the book's name (removes the people, card images and interaction records inside) |
/admin/business-cards/api/books/{book_id}/members | PUT | Replaces the whole member list, body {"members": [{"type", "key", "role"}]}: type is user / group / ou, role is view (can query) / edit (can edit); a bad format returns 400 and the existing members stay unchanged |
Settings export list
GET /admin/api/settings-export/categories
curl http://localhost:8765/admin/api/settings-export/categories \
-H "Authorization: Bearer ADMIN_TOKEN" | jq
Token management
POST /admin/api/tokens/create # 核發新 token
POST /admin/api/tokens/revoke # 撤銷 token
POST /admin/api/tokens/enforce # 開關 enforce 模式
POST /admin/api/tokens/owner # 綁定使用者:{"token": "<Token 或畫面上的遮罩>", "user_id": 12},null 是解除
GET /admin/api/tokens/owner-candidates?q=王 # 挑使用者用:啟用中的帳號,最多 20 筆
When sign-in is enabled, each token is bound to a user and has that user's permissions; tokens used for MCP must be bound. New tokens are bound to the administrator who created them (owner_user_id in the response); on the web, change it in the "Assigned user" column on the API Token page. A user that does not exist or is disabled returns 400, an unknown token 404, and calling it while sign-in is off 400. Creating, revoking, toggling enforcement and binding are all audited (api_token_change, with the label and action, never the token).
# 核發
curl -X POST http://localhost:8765/admin/api/tokens/create \
-H "Authorization: Bearer ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"label":"gitlab-ci"}' | jq
# 綁給使用者 12(MCP 回「This API token has no owner」時)
curl -X POST http://localhost:8765/admin/api/tokens/owner \
-H "Authorization: Bearer ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"token":"<要綁的 Token>","user_id":12}'
# 開啟 enforce
curl -X POST http://localhost:8765/admin/api/tokens/enforce \
-H "Authorization: Bearer ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"enforce":true}'
Signed-URL file fetch (not meant to be called by hand)
Some external services only accept a URL — the file is not uploaded to them, they fetch it themselves from an address we provide. In that case we hand over a short-lived signed URL rather than an API token:
GET /api/speech/audio/{file_id}?exp=<到期的 unix 秒數>&sig=<簽章>
- The URL itself is the authentication, with no
Authorizationheader. The signature binds the file id together with the expiry,
so extending exp invalidates the signature.
- Anything that fails to verify returns 404 — a malformed id, a wrong signature, an expired URL and a missing file all
look identical from outside (a 403 would tell the caller “that id exists”).
- The URL is produced server-side, and there is no public endpoint that hands out a signature —
it is listed here so that this document misses no endpoint, not for you to call.
If a fetch returns 404, the usual cause is an expired URL, not a missing file.
XHR endpoints used by the admin UI itself
These are endpoints the admin pages call themselves, not a stable public interface: their parameters and responses change along with the pages, so no compatibility is promised. They are listed so that this document covers every endpoint; for automation, prefer the APIs above, which have a defined contract.
| Endpoint | Method | Admin page |
|---|---|---|
/admin/api/check-latest-version | POST | Dependency check — check for a new version now (the result also feeds the home page notice; a manual check sends no notification) |
/admin/api/update-check | GET / PUT | Daily check for new versions: {"enabled": true} (off by default) and the last check result (last_check_at, last_ok, last_error, latest, is_outdated) |
/admin/api/upload-limit/probe | POST | System status: measure the reverse proxy's upload limit |
/admin/api/llm/context-variant | POST | LLM settings: create a version with a larger context on Ollama (model and num_ctx; returns the new name, e.g. gemma4:26b-ctx32k; only on a saved server, and the original model is left untouched) |
/admin/api/ocr-langs/set-engine | POST | OCR language packs: switch the default engine |
/admin/api/ocr-langs/set-quality | POST | OCR language packs: switch recognition quality |
/admin/api/ocr-langs/switch-active | POST | OCR language packs: switch the active language |
/admin/jobs/api/list | GET | Job queue: current jobs |
/admin/jobs/api/history | GET | Job queue: history |
/admin/jobs/api/cancel/{job_id} | POST | Job queue: cancel one job |
/admin/jobs/api/pause | POST | Job queue: pause or resume dispatching |
/admin/jobs/api/concurrency | POST | Job queue: maximum concurrent jobs |
/admin/jobs/api/priority-users | GET / POST | Job queue: priority dispatch list (the order is the priority) |
/admin/jobs/api/user-search | GET | Job queue: user search box for picking priority users |
/admin/api/jtlw/settings | POST | Speech service (JTLW): saves the endpoint and API key |
/admin/api/jtlw/test | POST | Speech service (JTLW): connection test (/health plus /capabilities, both halves) |
/admin/api/jtlw/profiles | GET | Speech service (JTLW): fetches the processing profiles they offer (for the dropdown) |
/admin/knowledge/api/overview | GET | Official document knowledge base: datasets, passage counts and the current search method |
/admin/knowledge/api/datasets | POST | Official document knowledge base: create a dataset |
/admin/knowledge/api/datasets/{dataset_id} | POST | Official document knowledge base: edit a dataset (name, category, purpose, visible groups) |
/admin/knowledge/api/datasets/{dataset_id}/delete | POST | Official document knowledge base: delete a dataset (with its versions and passages) |
/admin/knowledge/api/datasets/{dataset_id}/versions | GET | Official document knowledge base: document versions in a dataset |
/admin/knowledge/api/datasets/{dataset_id}/upload | POST | Official document knowledge base: upload a document (processed in the background) |
/admin/knowledge/api/versions/{version_id}/activate | POST | Official document knowledge base: activate this version |
/admin/knowledge/api/versions/{version_id}/deactivate | POST | Official document knowledge base: deactivate this version |
/admin/knowledge/api/versions/{version_id}/delete | POST | Official document knowledge base: delete this version |
/admin/knowledge/api/versions/{version_id}/reprocess | POST | Official document knowledge base: split into passages again |
/admin/knowledge/api/versions/{version_id}/meta | POST | Official document knowledge base: edit version details (version, date, publisher, source URL) |
/admin/knowledge/api/versions/{version_id}/preview | GET | Official document knowledge base: view the passages it was split into |
/admin/knowledge/api/versions/{version_id}/file | GET | Official document knowledge base: download the original file |
/admin/knowledge/api/search | POST | Official document knowledge base: try a search |
/admin/knowledge/api/embedding | GET / POST | Official document knowledge base: embedding service settings (use_llm_server defaults to true: use the LLM server that official document drafting uses; the key is never returned; GET also returns that server as llm_server and the rebuild progress as rebuild; the screen is on the LLM settings page) |
/admin/knowledge/api/embedding/test | POST | Official document knowledge base: test the embedding service connection |
/admin/knowledge/api/embedding/models | POST | Official document knowledge base: list the embedding models on the server (for the embedding model drop-down; on Ollama only models that can make embeddings are listed; each model carries usage: the prefixes and load settings the system adds automatically, or null if none) |
/admin/knowledge/api/rebuild | POST | Official document knowledge base: rebuild the vector index (in the background) |
/admin/knowledge/api/vectors/disable | POST | Official document knowledge base: turn off vector search (falls back to keyword search) |
/admin/knowledge/api/groups | GET | Official document knowledge base: group list for choosing visible groups |
/admin/knowledge/api/gov/status | GET | Official document knowledge base → Government open data: status of the sources, downloaded files, selection and imports (no outbound connection) |
/admin/knowledge/api/gov/{gid}/search | GET | Official document knowledge base → Government open data: search the downloaded list (q, limit, offset; with browse=1 and no query it returns the whole list, level filters by legal rank, and keys_only=1 returns every code in the range for select-all) |
/admin/knowledge/api/gov/{gid}/selection | GET / POST | Official document knowledge base → Government open data: the selected items (POST {keys, confirm}; a large selection returns 409 need_confirm) |
/admin/knowledge/api/gov/{gid}/selection/reset | POST | Official document knowledge base → Government open data: reset the selection to the default suggestions |
/admin/knowledge/api/gov/packages/{pid} | POST | Official document knowledge base → Government open data: change the download URL / fallback URL |
/admin/knowledge/api/gov/packages/{pid}/reset | POST | Official document knowledge base → Government open data: restore the default URLs |
/admin/knowledge/api/gov/packages/{pid}/upload | POST | Official document knowledge base → Government open data: upload a data file by hand, then import the selected items (processed in the background) |
/admin/knowledge/api/gov/{gid}/download | POST | Official document knowledge base → Government open data: download the lists (in the background; nothing is imported) |
/admin/knowledge/api/gov/{gid}/import | POST | Official document knowledge base → Government open data: import the selected items (in the background) |
/admin/knowledge/api/gov/{gid}/update | POST | Official document knowledge base → Government open data: download and import (the only button on the page): download again and import the selected items, creating new versions only for items that changed; if every download fails but a previous list exists, that list is used (result summary.stale_list) (in the background) |
For the government open data endpoints, {gid} is moj (Laws and Regulations Database) / ndc (National Development Council administrative rules) / ey (Executive Yuan rulings), and {pid} is moj-law, moj-order, ndc-rules-1, ndc-rules-2, ey-mailbox or ey-interp.
Also, the response of GET /admin/knowledge/api/datasets/{dataset_id}/versions has an optional gov field (only on versions imported from government open data: group, group_name, key, license, attribution, notice, abolished).
GitLab CI / GitHub Actions: convert Word documents to PDF automatically
# .gitlab-ci.yml
convert-docs:
script:
- |
for f in docs/*.docx; do
curl -fsSL -X POST "http://jtdt.internal:8765/api/convert-to-pdf" \
-H "Authorization: Bearer $JTDT_TOKEN" \
-F "file=@$f" \
--output "build/$(basename "$f " .docx).pdf"
done
artifacts:
paths: [build/]
Python client: clear PDF annotations in bulk
import requests
from pathlib import Path
API = "http://localhost:8765"
TOKEN = "YOUR_64_HEX_TOKEN"
H = {"Authorization": f "Bearer {TOKEN}"}
for pdf in Path("incoming/").glob("*.pdf"):
with pdf.open("rb") as f:
r = requests.post(
f "{API}/tools/pdf-annotations-strip/api/pdf-annotations-strip",
headers=H,
files={"file": (pdf.name, f, "application/pdf")},
)
r.raise_for_status()
(Path("clean/") / pdf.name).write_bytes(r.content)
print(f "OK {pdf.name}")
Shell: watch for a job to finish and download it
#!/bin/bash
TOKEN="YOUR_TOKEN"
API="http://localhost:8765"
JOB=$(curl -fsSL -X POST "$API/api/llm-review" \
-H "Authorization: Bearer $TOKEN" \
-F "file=@filled.pdf" -F "template_id=vendor_form_v3" \
| jq -r .job_id)
echo "Job: $JOB"
while :; do
S=$(curl -fsSL "$API/api/jobs/$JOB" -H "Authorization: Bearer $TOKEN")
STATE=$(echo "$S" | jq -r .status)
PROG=$(echo "$S" | jq -r .progress)
echo " $STATE $PROG"
[ "$STATE" = "completed" ] && break
[ "$STATE" = "failed" ] && { echo "Failed"; exit 1; }
sleep 2
done
curl -fsSL "$API/api/jobs/$JOB/download" \
-H "Authorization: Bearer $TOKEN" \
--output reviewed.pdf
echo "Saved: reviewed.pdf"
Node.js: sentence translation
const r = await fetch(
'http://localhost:8765/tools/translate-doc/api/translate-doc',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN',
},
body: JSON.stringify({
text: 'Hello world. This is a test.',
source_lang: 'auto',
target_lang: 'zh-TW',
}),
}
);
const j = await r.json();
console.log(j.results);
// [{src: 'Hello world.', translated: '你好,世界。', error: ''}, ...]
13. Managing tokens from the CLI
# 列出
sudo jtdt auth show
# 檔案裡只有雜湊與密文(v1.16.78 起),讀檔看不到 Token 原文;
# 要看原文請到管理頁「API Token」按「顯示」
# 撤銷(CLI 沒提供撤銷,必要時直接清掉檔案後重啟服務):
sudo systemctl stop jt-doc-tools
sudo rm /var/lib/jt-doc-tools/data/api_tokens.json
sudo systemctl start jt-doc-tools
# 重啟後 admin UI 重新核發
14. Rate limits and upload size
There is no built-in rate limit at present. Add one at the reverse proxy (nginx / Caddy) when you deploy:
client_max_body_size 100M(required, otherwise large PDFs are rejected)proxy_read_timeout 900s+proxy_send_timeout 900s(required; a single LLM inference often takes 5-15 minutes, and the 60s default is guaranteed to give a 504)proxy_buffering off(friendly to LLM streaming)- With several layers of nginx (a self-hosted LLM proxy plus jt-doc-tools) every layer needs it; one layer left at the default breaks the whole chain
- If it needs to be exposed publicly, add
limit_req_zoneagainst abuse
See the "reverse proxy" section and the "504 Gateway Timeout troubleshooting" section of OPS.md.
14b. User workspace (session authentication, not a Bearer API)
"My workspace" is a web feature tied to the signed-in session (cookie authentication) and is not part of the public Bearer API, because each file is isolated by account. An administrator must enable it in "workspace settings"; while it is disabled every endpoint below returns 404.
| Endpoint | Method | Description |
|---|---|---|
/workspace | GET | The “My workspace” page |
/workspace/api/list | GET | List your own files (filter with ?accept=pdf,png) plus the quota and retention period; each file also carries preview (whether it has a thumbnail) and kind (pdf / image / office / text / audio / video) |
/workspace/api/count | GET | File count (for the sidebar badge) |
/workspace/save | POST | Save a file: job_id (the server copies the job result) or file (upload the bytes directly). The format is detected from the content: PDF / PNG, office documents, plain text, audio / video recordings (.m4a / .mp3 / .wav / .aac / .ogg / .opus / .flac / .mp4 / .mov / .mkv / .webm); recordings have their own per-file limit (max_audio_mb), and anything larger gets 413 |
/workspace/file/{file_id} | GET | Fetch a file (?dl=1 to download) |
/workspace/thumb/{file_id} | GET | Thumbnail (first PDF page rendered / the PNG itself); plain text and recordings get a 1×1 transparent placeholder (Cache-Control: no-store), so go by preview and do not treat it as a thumbnail |
/workspace/delete | POST | Delete (file_id) |
/workspace/rename | POST | Rename (file_id, name) |
/tools/meeting-transcribe/from-workspace | POST | Hands a recording in your own workspace to the transcription tool (JSON {"file_id": "…"}, no re-upload); the response is the same as /tools/meeting-transcribe/upload. Someone else’s file / not found → 404, not a recording → 400, speech service not set up → 503 |
The quota, per-file limit, recording limit, retention period and the on/off switch are set by an administrator at /admin/workspace (site-wide, with no individual exceptions).
14c. User notifications and inbox (session auth, not the Bearer API)
Same nature as the workspace in §14b: bound to the login session (cookie), not part of the public Bearer API, because the contents are isolated per signed-in user. Requests without a session get 401 / 302.
| Endpoint | Method | Description |
|---|---|---|
/api/my/notify | GET | Read your own notification settings (whether to notify on job completion, and through which channels) |
/api/my/notify | POST | Save your own notification settings |
/api/my/inbox | GET | In-app notification list (unread first) |
/api/my/inbox/seen | POST | Mark as read ( id or all=1 ) |
/api/update-notice/dismiss | POST | "Don't remind me about this version" on the home page new-version notice: {"version": "x.y.z"}, stored in this administrator's own preferences; administrators only (in single-user mode, whoever opens the page) |
/api/my/zulip-link | GET | Zulip link status: the linked account (linked) and any linking in progress (pending: code, expiry, the bot to message, and the Zulip account awaiting confirmation, candidate) |
/api/my/zulip-link/start | POST | Create a one-time linking code (valid for 10 minutes); send it to the notification bot as a Zulip direct message |
/api/my/zulip-link/confirm | POST | Confirm linking to candidate ({"code": "..."}); the link is saved and the code used up in one step |
/api/my/zulip-link/cancel | POST | Cancel the linking in progress |
/api/my/zulip-link | DELETE | Unlink (Zulip notifications go by email address again) |
These are deliberately left out of the Bearer API: they return data belonging to the signed-in user, so calling them with a token makes little sense (a token is bound to a user, but these endpoints are designed for the browser).
15. Change history
The API follows SemVer: a minor release (1.4.x → 1.5.x) is guaranteed backwards compatible; only a major release (1.x → 2.x) may break. Adding an endpoint is not a breaking change.
The full change log is in CHANGELOG.md.