> ## 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.

# Batch classify and set attribute values

> Execute multiple file facet actions in a single request.

All actions are **validated upfront** before any execution begins. If any
action has invalid fields, the entire batch is rejected with a 422 response
and no actions are executed.

On **domain errors** (e.g., unknown content type, sibling conflict), the
batch fails fast at the failing action. The error response includes an
`"index"` field (0-based) indicating which action caused the failure.
Actions before the failing index are committed; their results are not
returned. All verbs are idempotent — it is safe to re-send the entire
batch after fixing the error.

**Request:** `{"actions": [<action>, <action>, ...]}`

Each action object follows the same schema as the single-action
`POST /api/v3/files/{file_id}/facets` endpoint. Maximum 50 actions per batch.

**Response:** `{"results": [{"status": <code>, "data": <body|null>}, ...]}`

Results are in the same order as the input actions. The `data` key is
`null` for 204 actions (unclassify, clear_value).

See `POST /api/v3/files/{file_id}/facets` for available actions and their fields.

Requires edit access to the file.



## OpenAPI

````yaml /api-reference/api-console.yaml post /api/v3/files/{file_id}/facets/batch
openapi: 3.1.0
info:
  title: LightOn API
  version: 3.13.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/batch:
    post:
      tags:
        - Facets
      summary: Batch classify and set attribute values
      description: >-
        Execute multiple file facet actions in a single request.


        All actions are **validated upfront** before any execution begins. If
        any

        action has invalid fields, the entire batch is rejected with a 422
        response

        and no actions are executed.


        On **domain errors** (e.g., unknown content type, sibling conflict), the

        batch fails fast at the failing action. The error response includes an

        `"index"` field (0-based) indicating which action caused the failure.

        Actions before the failing index are committed; their results are not

        returned. All verbs are idempotent — it is safe to re-send the entire

        batch after fixing the error.


        **Request:** `{"actions": [<action>, <action>, ...]}`


        Each action object follows the same schema as the single-action

        `POST /api/v3/files/{file_id}/facets` endpoint. Maximum 50 actions per
        batch.


        **Response:** `{"results": [{"status": <code>, "data": <body|null>},
        ...]}`


        Results are in the same order as the input actions. The `data` key is

        `null` for 204 actions (unclassify, clear_value).


        See `POST /api/v3/files/{file_id}/facets` for available actions and
        their fields.


        Requires edit access to the file.
      operationId: api_v3_files_facets_batch_create
      parameters:
        - in: path
          name: file_id
          schema:
            type: integer
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FileFacetBatchRequest'
            examples:
              ClassifyAndSetAttributes:
                value:
                  actions:
                    - action: classify
                      content_type_path: legal:contract:nda
                    - action: set_value
                      content_type_path: legal:contract:nda
                      attribute_name: jurisdiction
                      value:
                        - FR
                        - DE
                    - action: set_value
                      content_type_path: legal:contract:nda
                      attribute_name: counterparty
                      value: Nimbus Labs
                summary: Classify and set attributes
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchResponse'
              examples:
                Classify+SetValues:
                  value:
                    results:
                      - status: 201
                        data:
                          content_type_path: legal:contract:nda
                          label: Non-Disclosure Agreement
                      - status: 201
                        data:
                          name: jurisdiction
                          value:
                            - FR
                            - DE
                          content_type_path: legal:contract:nda
                      - status: 201
                        data:
                          name: counterparty
                          value: Nimbus Labs
                          content_type_path: legal:contract:nda
                  summary: Classify + set values
          description: All actions executed successfully
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIV3BatchErrorResponse'
              examples:
                UnknownContentType(withIndex):
                  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
                    index: 1
                  summary: Unknown content type (with index)
          description: Domain error with action index
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIV3ErrorResponse'
              examples:
                Unauthorized:
                  value:
                    id: null
                    code: 401
                    error: unauthorized
                    detail: >-
                      Authentication credentials were not provided or are
                      invalid.
                    doc_url: https://developers.lighton.ai/errors#unauthorized
          description: Authentication credentials were not provided or are invalid
        '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 perform this action.
                    doc_url: >-
                      https://developers.lighton.ai/errors#insufficient_permissions
          description: Insufficient permissions
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIV3BatchErrorResponse'
              examples:
                NotFound:
                  value:
                    id: null
                    code: 404
                    error: not_found
                    detail: Document not found.
                    doc_url: https://developers.lighton.ai/errors#not_found
                  summary: Not found
          description: File 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:
    FileFacetBatchRequest:
      description: |-
        Batch request for file facet operations.

        All actions are validated upfront before any execution begins.
      properties:
        actions:
          items:
            $ref: '#/components/schemas/FileFacetActionRequest'
          maxItems: 50
          minItems: 1
          title: Actions
          type: array
      required:
        - actions
      title: FileFacetBatchRequest
      type: object
    BatchResponse:
      properties:
        results:
          items:
            $ref: '#/components/schemas/BatchResultItem'
          title: Results
          type: array
      required:
        - results
      title: BatchResponse
      type: object
    APIV3BatchErrorResponse:
      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
        index:
          type: integer
          description: 0-based position of the failing action in the batch.
      required:
        - code
        - detail
        - doc_url
        - error
        - id
    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
    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
    BatchResultItem:
      properties:
        status:
          title: Status
          type: integer
        data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          title: Data
      required:
        - status
      title: BatchResultItem
      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
    FileFacetActionRequestActionEnum:
      enum:
        - classify
        - unclassify
        - set_value
        - clear_value
      type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your auth token.

````