Skip to content

Lookup lists

A lookup list is a CSV you upload to a project and match against from rules with lookup(). The classic case: a hospital panel. The extractor reads hospital.name from the bill; a rule asks whether that name is on your panel list and flags the bill when it is not. Lists are shared by every extractor in the project, versioned on replace, and read by the rules engine in-process, so a lookup costs nothing and never involves the model.

"rules": [
{ "id": "on_panel",
"check": "lookup(\"panel\", hospital.name)",
"message": "Hospital is not on the panel" },
{ "id": "tier_a",
"check": "lookup(\"panel\", hospital.name, \"tier\") == \"A\"",
"when": "lookup(\"panel\", hospital.name)",
"severity": "warning",
"message": "Not a tier A hospital" }
]

The first row is the header; every other non-blank row is one entry. Cells are trimmed. Quoted cells with commas and "" escapes follow RFC 4180. UTF-8 with or without a byte-order mark is expected; Windows-1252 is accepted as a fallback.

name,city,tier
City Care Hospital,Pune,A
Apollo,Chennai,B
Fortis,Delhi,A
Rule Detail
Header Required. Every cell needs a name; names are unique ignoring case; up to 255 characters each
Key column The column lookup() matches against. The first column unless you name another with ?key=<header> on upload (or the key column select in the dashboard)
Matching Both the cell and the value are normalised: surrounding spaces trimmed, runs of whitespace collapsed, case folded. " CITY CARE hospital " matches City Care Hospital. Whole numbers match whether written 123 or 123.0
Duplicate keys The first row with a key wins for the column form; rows with an empty key are ignored
Short rows Padded with empty cells; extra cells beyond the header are dropped
Limit Exceeded
Rows 100,000 413 list_too_large
File size 5 MB 413 list_too_large
Columns 20 413 list_too_large
Name ^[a-z][a-z0-9_-]{0,63}$, unique per project 422 validation_error
Malformed CSV (no header, empty, duplicate headers, unknown key column, binary) 422 list_invalid

Creating a list needs the Pro, Scale or Enterprise plan, or early access. On the free plan PUT /v1/lists/{name} answers 403 plan_limit. Reading, replacing and deleting lists that already exist always work, so a downgrade never breaks a running extractor. See Rate limits and quotas.

Form Returns Notes
lookup("list", value) true / false Whether the normalised value is in the key column. null when the value is null or the list does not exist, so the rule is skipped, never failed
lookup("list", value, "column") the cell, as a string The named column of the row whose key matches, else null (no match, no such column, or no such list)
lookup("list", value, threshold) true / false Close match: the most similar key must score at least threshold (0 to 1) by character similarity after normalisation. 0.85 tolerates a missing “s”, a comma or a reordered suffix; 0.95 only typos. Exact matches always win, and candidates are narrowed by shared words first so large lists stay fast
lookup("list", value, "column", threshold) the cell, as a string The column of the closest row at or above threshold, else null

The list name and the column name must be quoted literals; lookup(panel, x) is a syntax error. This is what lets Deskew know which lists a definition needs before it runs. The value is any expression: a field path, a string, an arithmetic result. A value that is itself a list (items[].code) is null; use a when or compare count() instead.

Skip, do not fail, when the list is missing. A rule that lookup()s a list you have not uploaded (or have deleted) is skipped on every run and the run carries a warning: lookup list 'panel' is not uploaded to this project; rules that use it were skipped. Publishing is not blocked. The dashboard rules editor shows the same warning inline and offers the project’s list names as you type lookup(".

Membership (the common case):

lookup("panel", hospital.name)

Negative list, flag anything that is on it:

!lookup("blocked-vendors", vendor.gstin)

Column read, with a guard so the rule skips off-list hospitals:

{ "id": "tier_a",
"check": "lookup(\"panel\", hospital.name, \"tier\") == \"A\"",
"when": "lookup(\"panel\", hospital.name)" }

Cross-check an extracted value against the list (the printed city must match the panel’s city):

{ "id": "city_matches_panel",
"check": "lookup(\"panel\", hospital.name, \"city\") == hospital.city",
"when": "lookup(\"panel\", hospital.name) && hospital.city != null" }

Numeric column: cells are strings, and comparisons with a number coerce them, so lookup("rates", procedure.code, "max_amount") >= amount works when the column holds plain numbers.

Combine with other functions:

lookup("panel", hospital.name) || matches(hospital.name, '(?i)government')

PUT on an existing name replaces the CSV and bumps version; the previous file is removed. Runs that start after the replace read the new list (the engine caches a list per version, so nothing stale is served). DELETE removes the list; rules that use it skip from the next run on, with the warning above. Both are recorded in the audit log as list.updated and list.deleted (list.created for the first upload).

Extractors → Lookup lists (the button in the Extractors header) lists the project’s lists with rows, columns (key column highlighted), key column, version, size and last update. Upload list takes a CSV, reads its header in the browser, proposes a name from the file name and lets you pick the key column before anything is sent. The same dialog replaces an existing list from its row; Download returns the stored CSV; Delete (owners and admins) asks for confirmation. Members can upload and replace.

In the rules editor, typing lookup(" offers the project’s list names, and a rule that names a list that is not uploaded shows a warning with a link to the panel.

Everything above is available on /v1/lists: list, create or replace (PUT with the CSV as the body or a multipart file), read, download and delete. Keys need extractors:read to read and extractors:write to change.