> ## Documentation Index
> Fetch the complete documentation index at: https://developers.lighton.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Classify a file and set attributes

> Apply content-type classifications to a file and set attribute values
(metadata) on it. This is how you tag a document with structured metadata
from your content-type schema.

**Typical workflow:**
1. **Classify** the file: `{"action": "classify",
   "content_type_path": "legal:contract:nda"}`
2. **Set attribute values**: `{"action": "set_value",
   "content_type_path": "legal:contract:nda",
   "attribute_name": "jurisdiction", "value": ["FR", "DE"]}`
3. **Read back** with `GET /api/v3/files/{file_id}/facets`

A file can be classified under **multiple content types**. Just call
`classify` for each one. Removing a classification (`unclassify`) cascades:
all attribute values under that content type are removed too.

**Actions:**
- `classify`: assign a content type to the file (idempotent)
- `unclassify`: remove a content type and all its attribute values
- `set_value`: set or update an attribute value (the content type must be classified first)
- `clear_value`: remove an attribute value

**Value types for `set_value`:**
- `text` / `rich-text` → string
- `number` → number or numeric string
- `date` → date string, normalized to `YYYY-MM-DD`
- `boolean` → `true` / `false`
- `select` → one string from `choices`
- `multi-select` → array of strings from `choices`

To clear a value, use `clear_value` (not `set_value` with `null`).

**Prerequisites:** Content types must be set up first. See
`GET /api/v3/content-types/templates` (browse templates) and
`POST /api/v3/content-types` (adopt or create).

Requires edit access to the file.



## OpenAPI

````yaml /api-reference/api-console.yaml post /api/v3/files/{file_id}/facets
openapi: 3.1.0
info:
  title: LightOn API
  version: 3.12.0 (v1)
  description: >-
    LightOn gives you an API to search, parse, and ingest documents at scale.
    Build knowledge-retrieval pipelines without managing vector databases or OCR
    models.
servers:
  - url: https://api.lighton.ai
security: []
tags:
  - name: Ask
    description: >-
      Retrieval-augmented generation: search your indexed corpus and generate an
      LLM answer grounded in the retrieved passages. Supports streaming (SSE)
      and synchronous modes.
  - name: Search
    description: >-
      Hybrid vector + text retrieval over your indexed corpus. Returns ranked
      passages with provenance (file, page range, workspace). Optional reranking
      and vision mode.
  - name: Files
    description: Upload, list, fetch, and delete documents indexed in your workspaces.
  - name: Facets
    description: >-
      Organise documents with hierarchical content types and custom attributes
      per file. Start from starter templates or build your own classification
      schema from scratch.
  - name: Tags
    description: >-
      Manage flat, company-wide labels used to scope search and group content
      across workspaces.
  - name: Workspaces
    description: >-
      Create and manage workspaces — the access-controlled containers your
      documents live in.
  - name: Parse
    description: >-
      Convert documents into structured Markdown — PDFs, images, Office files,
      and HTML. Synchronous endpoint capped at 20 MB / 15 pages.
  - name: Extract
    description: >-
      Pull typed fields out of documents using a JSON Schema you provide. Sync
      mode for small documents (≤20 MB / 15 pages); async mode for larger jobs
      (≤100 MB / 1000 pages) with polling on a job ID.
  - name: API Keys
    description: >-
      Provision and revoke API keys used to authenticate against the Console
      API.
  - name: Budget
    description: >-
      Manage your organization's monthly spend budget and alert thresholds. Set
      a hard cap that blocks API requests when reached, and configure email
      notifications at custom spend percentages.
paths:
  /api/v3/files/{file_id}/facets:
    post:
      tags:
        - Facets
      summary: Classify a file and set attributes
      description: >-
        Apply content-type classifications to a file and set attribute values

        (metadata) on it. This is how you tag a document with structured
        metadata

        from your content-type schema.


        **Typical workflow:**

        1. **Classify** the file: `{"action": "classify",
           "content_type_path": "legal:contract:nda"}`
        2. **Set attribute values**: `{"action": "set_value",
           "content_type_path": "legal:contract:nda",
           "attribute_name": "jurisdiction", "value": ["FR", "DE"]}`
        3. **Read back** with `GET /api/v3/files/{file_id}/facets`


        A file can be classified under **multiple content types**. Just call

        `classify` for each one. Removing a classification (`unclassify`)
        cascades:

        all attribute values under that content type are removed too.


        **Actions:**

        - `classify`: assign a content type to the file (idempotent)

        - `unclassify`: remove a content type and all its attribute values

        - `set_value`: set or update an attribute value (the content type must
        be classified first)

        - `clear_value`: remove an attribute value


        **Value types for `set_value`:**

        - `text` / `rich-text` → string

        - `number` → number or numeric string

        - `date` → date string, normalized to `YYYY-MM-DD`

        - `boolean` → `true` / `false`

        - `select` → one string from `choices`

        - `multi-select` → array of strings from `choices`


        To clear a value, use `clear_value` (not `set_value` with `null`).


        **Prerequisites:** Content types must be set up first. See

        `GET /api/v3/content-types/templates` (browse templates) and

        `POST /api/v3/content-types` (adopt or create).


        Requires edit access to the file.
      operationId: api_v3_files_facets_create
      parameters:
        - in: path
          name: file_id
          schema:
            type: integer
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FileFacetActionRequest'
            examples:
              ClassifyFile:
                value:
                  action: classify
                  content_type_path: legal:contract:nda
                summary: Classify file
              SetTextValue:
                value:
                  action: set_value
                  content_type_path: legal:contract:nda
                  attribute_name: counterparty
                  value: Nimbus Labs
                summary: Set text value
              SetNumberValue:
                value:
                  action: set_value
                  content_type_path: finance:report
                  attribute_name: contract_value
                  value: 50000
                summary: Set number value
              SetDateValue:
                value:
                  action: set_value
                  content_type_path: legal:contract
                  attribute_name: effective_date
                  value: '2024-06-30'
                summary: Set date value
              SetBooleanValue:
                value:
                  action: set_value
                  content_type_path: legal:contract:nda
                  attribute_name: is_mutual
                  value: true
                summary: Set boolean value
              SetSelectValue:
                value:
                  action: set_value
                  content_type_path: tech:specification
                  attribute_name: maturity
                  value: Approved
                summary: Set select value
              SetMulti-selectValue:
                value:
                  action: set_value
                  content_type_path: legal:contract:nda
                  attribute_name: jurisdiction
                  value:
                    - FR
                    - DE
                summary: Set multi-select value
              ClearValue:
                value:
                  action: clear_value
                  content_type_path: legal:contract:nda
                  attribute_name: jurisdiction
                summary: Clear value
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileFacetWriteResponse'
          description: Content type already classified, or attribute value updated
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileFacetWriteResponse'
              examples:
                ContentTypeClassified:
                  value:
                    content_type_path: legal:contract:nda
                    label: Non-Disclosure Agreement
                  summary: Content type classified
                AttributeValueCreated:
                  value:
                    name: jurisdiction
                    value:
                      - FR
                      - DE
                    content_type_path: legal:contract:nda
                  summary: Attribute value created
                BooleanValueSet:
                  value:
                    name: is_mutual
                    value: true
                    content_type_path: legal:contract:nda
                  summary: Boolean value set
          description: Content type classified or attribute value created
        '204':
          description: Content type unclassified or attribute value cleared
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIV3ErrorResponse'
              examples:
                AttributeValueInvalid:
                  value:
                    id: null
                    code: 400
                    error: attribute_value_invalid
                    detail: 'jurisdiction: expected list, got str'
                    doc_url: >-
                      https://developers.lighton.ai/errors#attribute_value_invalid
                  summary: Attribute value invalid
                UnknownContentType:
                  value:
                    id: null
                    code: 400
                    error: content_type_unknown
                    detail: 'Unknown content type path: ''fake:path''.'
                    doc_url: https://developers.lighton.ai/errors#content_type_unknown
                  summary: Unknown content type
                SiblingConflict:
                  value:
                    id: null
                    code: 400
                    error: content_type_sibling_conflict
                    detail: >-
                      Document already has content type 'legal:contract' from
                      the same tree. Unclassify it before assigning
                      'legal:compliance'.
                    doc_url: >-
                      https://developers.lighton.ai/errors#content_type_sibling_conflict
                  summary: Sibling conflict
          description: Validation error or business rule violation
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIV3ErrorResponse'
              examples:
                Forbidden:
                  value:
                    id: null
                    code: 403
                    error: insufficient_permissions
                    detail: You do not have permission to edit this file's facets.
                    doc_url: >-
                      https://developers.lighton.ai/errors#insufficient_permissions
          description: No edit permission
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIV3ErrorResponse'
              examples:
                ContentTypeNotAssigned:
                  value:
                    id: null
                    code: 404
                    error: content_type_not_assigned
                    detail: Content type 'legal:contract' not assigned to document.
                    doc_url: >-
                      https://developers.lighton.ai/errors#content_type_not_assigned
                  summary: Content type not assigned
          description: File or content type not found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIV3ValidationErrorResponse'
              examples:
                ValidationError:
                  value:
                    id: null
                    code: 422
                    error: validation_error
                    detail: One or more fields failed validation.
                    doc_url: https://developers.lighton.ai/errors#validation_error
                    fields:
                      <field_name>:
                        - error: required
                          detail: This field is required.
                  summary: Validation Error
          description: Request body is valid JSON but one or more fields failed validation
      security:
        - bearerAuth: []
components:
  schemas:
    FileFacetActionRequest:
      description: >-
        Write operation for a file's facets (classifications + attribute
        values).


        Explicit verb-noun actions per FAC0012:
          - ``classify`` / ``unclassify``: T2 (file ↔ content type)
          - ``set_value`` / ``clear_value``: T3 (attribute value under an assigned content type)

        Value actions require ``attribute_name``; classification actions require
        only

        ``content_type_path``.
      properties:
        action:
          allOf:
            - $ref: '#/components/schemas/FileFacetActionRequestActionEnum'
          title: Action
        content_type_path:
          description: Assigned content type path, e.g. legal:contract:nda.
          title: Content Type Path
          type: string
        attribute_name:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Attribute identifier in snake_case.
          title: Attribute Name
        value:
          default: null
          description: >-
            Attribute value for set_value. Shape depends on attribute type:
            text/rich-text=string, number=number, date=date string (YYYY-MM-DD),
            boolean=true/false, select=string from choices, multi-select=array
            of strings from choices.
          title: Value
      required:
        - action
        - content_type_path
      title: FileFacetActionRequest
      type: object
    FileFacetWriteResponse:
      oneOf:
        - $ref: '#/components/schemas/AttributeValueResponse'
        - $ref: '#/components/schemas/ContentTypeAssignmentResponse'
    APIV3ErrorResponse:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          description: >-
            Job/resource id when one already exists (useful for async error
            diagnosis); null otherwise.
        code:
          type: integer
          description: HTTP status code
        error:
          type: string
          description: Error code used by the UI as a translation key
        detail:
          type: string
          description: Human-readable error message for developers
        doc_url:
          type: string
          description: Link to the error-code documentation page
      required:
        - code
        - detail
        - doc_url
        - error
        - id
    APIV3ValidationErrorResponse:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          description: >-
            Job/resource id when one already exists (useful for async error
            diagnosis); null otherwise.
        code:
          type: integer
          description: HTTP status code
        error:
          type: string
          description: Error code used by the UI as a translation key
        detail:
          type: string
          description: Human-readable error message for developers
        doc_url:
          type: string
          description: Link to the error-code documentation page
        fields:
          type: object
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/APIV3FieldError'
          description: Field-level validation errors keyed by field name
      required:
        - code
        - detail
        - doc_url
        - error
        - id
    FileFacetActionRequestActionEnum:
      enum:
        - classify
        - unclassify
        - set_value
        - clear_value
      type: string
    AttributeValueResponse:
      properties:
        name:
          title: Name
          type: string
        value:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: boolean
            - items:
                type: string
              type: array
            - type: 'null'
          description: >-
            Attribute value. Shape depends on type: string, number, boolean,
            date string, or array of strings for multi-select.
          title: Value
        content_type_path:
          title: Content Type Path
          type: string
      required:
        - name
        - value
        - content_type_path
      title: AttributeValueResponse
      type: object
    ContentTypeAssignmentResponse:
      properties:
        content_type_path:
          title: Content Type Path
          type: string
        label:
          title: Label
          type: string
      required:
        - content_type_path
        - label
      title: ContentTypeAssignmentResponse
      type: object
    APIV3FieldError:
      type: object
      properties:
        error:
          type: string
          description: Error code / translation key
        detail:
          type: string
          description: Human-readable description of the field error
      required:
        - detail
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your auth token.

````