Skip to main content

Document Display Names

Give documents readable names: choose a rule, preview a script on real filenames, draft one from a plain instruction, check coverage, and apply it to every document.

Filenames from scanners and mail systems are often unreadable: a GUID, a date stamp, a sender prefix. A display name rule turns each filename into a readable name that review screens and lists show instead. The rule has three modes: off (no readable names, the default), default (Talonic tidies the filename) and lua (your own short script decides).

A script reads record.filename and calls record:set('display_name', value). Before you save one, POST /v1/documents/display-name-rule/preview runs it over a sample of your real filenames and shows what it would produce, without saving anything. If you would rather describe the rule in words ("drop the GUID in front of the name"), POST /v1/documents/display-name-rule/generate-script drafts a script from your instruction, using your own filenames as examples. It also saves nothing.

Saving a rule with PATCH /v1/documents/display-name-rule applies it to documents from then on. To rename the documents you already have, call POST /v1/documents/display-name-rule/backfill, which overwrites their readable names. GET /v1/documents/display-name-rule/coverage reports how many documents carry a readable name, how many differ from their filename, and a sample still showing the raw filename.

The reads need the read scope (or documents:read), and any member may call them. Setting, previewing, drafting and applying the rule need documents:write, and the key's person must be an Admin of the workspace, as in the web app; anyone else gets 403 insufficient_role.

GET/v1/documents/display-name-rule

Response fields

modestringoff, default or lua.
scriptstring | nullThe script, when there is one.
check_failingbooleanTrue when the last check of the script found a syntax error.
last_check_errorstring | nullThat syntax error.
check_pendingbooleanTrue until the first check of a newly saved script has answered. Wait for it before backfill.
check_requested_atstring | nullWhen the pending check was requested.
samples[]arrayUp to 10 { filename, display_name } pairs from stored documents.
PATCH/v1/documents/display-name-rule

Body parameters

mode*stringoff, default or lua.
scriptstringThe script, up to 20,000 characters. Required for lua; in the other modes it is kept as a draft.
POST/v1/documents/display-name-rule/preview

Body parameters

lua_script*stringThe script to try, up to 20,000 characters.
sample_sizeintegerHow many real filenames to try it on, 1 to 200. Default: 50

Preview a script

curl -X POST https://api.talonic.com/v1/documents/display-name-rule/preview \
  -H "Authorization: Bearer $TALONIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"lua_script": "record:set(\"display_name\", (record.filename:gsub(\"^%x+%-\", \"\")))", "sample_size": 20}'
POST/v1/documents/display-name-rule/generate-script

Body parameters

instruction*stringThe rule in your own words, up to 2000 characters.
sample_sizeintegerHow many of your filenames to use as examples, 1 to 200. Default: 40
GET/v1/documents/display-name-rule/coverage
POST/v1/documents/display-name-rule/backfill
Backfill overwrites the readable name of every document. Preview the rule first, and wait until check_pending is false on GET /v1/documents/display-name-rule before you apply a newly saved script.

Frequently asked questions

Does a display name replace the filename?+
No. The filename stays as it is and is always returned. The display name is shown beside or instead of it on review screens and lists, and is returned as display_name on run document lists and assembly groups.
What does a script look like?+
A short Lua chunk that reads record.filename and calls record:set('display_name', value). If it sets nothing, the document keeps showing its filename. Use preview to try it on real filenames first.
Does saving a rule rename my existing documents?+
No. A saved rule names documents from then on. Call backfill to apply it to the documents you already have; it overwrites their readable names.