- Classify: tell LightOn what type this document is (
contract:nda) - Set values: fill in the attribute values for that classification (
counterparty,jurisdiction, …)
Step 1: Upload a document
Before classifying, you need a file. If you already have one, skip this step and use your existingfile_id.
Replace
workspace_id with your own. You can list your workspaces via GET /api/v3/workspaces.upload_file.py
id field: that’s your file_id. Ingestion is asynchronous (status: pending), but you don’t need to wait before classifying.
Step 2: Classify the document
Tell LightOn this file is acontract:nda:
classify_file.py
201 Created (or 200 if already classified, since classify is idempotent). This is lightweight: it only creates the link between the file and the content type path. No attribute values are set yet.
A file can hold classifications from multiple trees, but only one per tree. If you need to reclassify within the same tree, see Rules & constraints for what’s allowed.
Step 3: Set attribute values
Fill in the structured metadata. Notice that you can set attributes likecounterparty and jurisdiction on contract:nda even though they were defined on the parent contract node. This works because inherit_attributes is true in the classification tree you built earlier.
set_values.py
The efficient way: batch everything in one call
In production, always batch the classify + allset_value actions together. This triggers exactly one BM25 reindex, not seven.
batch_apply.py
Step 4: Read back the full facets on a file
read_facets.py
labels: breadcrumb from root to leaf (e.g.["Contract", "Non-Disclosure Agreement"]), useful for display in a UIinherited: true: attributes that came from a parent node (contract), likecounterpartyandjurisdictioninherited: false: attributes defined directly oncontract:nda, likeis_mutualandduration_yearscan_edit: true: whether the current user can modify this file’s facets
Multi-classification: a document with two types
A file can be classified under multiple content types, but only from different trees. You cannot have two classifications from the same tree (see Rules & constraints). For example, if you have a second tree calledregulation, you can classify a file as both contract:nda and regulation:gdpr:
multi_classify.py
Remove a classification or a value
clear_unclassify.py
204 No Content on success. unclassify cascades: it removes the classification and all its attribute values. See Rules & constraints for all cascade behaviors.
Action reference
| Action | What it does |
|---|---|
classify | Assign a content type path to a file (idempotent) |
unclassify | Remove a classification and cascade-delete all its attribute values |
set_value | Set an attribute value on a classified file (idempotent) |
clear_value | Remove a single attribute value |