> ## 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 define content types and attributes

> Execute multiple content-type 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., content type not found, permission denied), 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/content-types` 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 (deletes).

See `POST /api/v3/content-types` for available actions and their fields.



## OpenAPI

````yaml /api-reference/api-console.yaml post /api/v3/content-types/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/content-types/batch:
    post:
      tags:
        - Facets
      summary: Batch define content types and attributes
      description: >-
        Execute multiple content-type 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., content type not found, permission denied),
        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/content-types` 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 (deletes).


        See `POST /api/v3/content-types` for available actions and their fields.
      operationId: api_v3_content_types_batch_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContentTypeBatchRequest'
            examples:
              AdoptAndDefineAttribute:
                value:
                  actions:
                    - action: adopt
                      content_types:
                        - legal
                    - action: define_attribute
                      content_type_path: legal
                      name: owner
                      attribute_type: text
                summary: Adopt and define attribute
              BuildATreeFromScratch:
                value:
                  actions:
                    - action: define_content_type
                      code: compliance
                      label: Compliance
                    - action: define_content_type
                      parent_path: compliance
                      code: audit-report
                      label: Audit Report
                    - action: define_attribute
                      content_type_path: compliance
                      name: auditor
                      attribute_type: text
                summary: Build a tree from scratch
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchResponse'
              examples:
                MixedStatuses:
                  value:
                    results:
                      - status: 200
                        data:
                          content_types:
                            - path: legal
                              code: legal
                              label: Legal
                      - status: 201
                        data:
                          name: owner
                          label: Owner
                          type: text
                          required: false
                          description: ''
                          choices: []
                  summary: Mixed statuses
                DeleteResult(nullData):
                  value:
                    results:
                      - status: 204
                        data: null
                  summary: Delete result (null data)
          description: All actions executed successfully
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIV3BatchErrorResponse'
              examples:
                ContentTypeNotFound(withIndex):
                  value:
                    id: null
                    code: 404
                    error: content_type_not_found
                    detail: Content type 'nonexistent' not found for this company.
                    doc_url: >-
                      https://developers.lighton.ai/errors#content_type_not_found
                    index: 1
                  summary: Content type not found (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/APIV3BatchErrorResponse'
              examples:
                PermissionDenied(withIndex):
                  value:
                    id: null
                    code: 403
                    error: insufficient_permissions
                    detail: Permission denied for action 'undefine_content_type'.
                    doc_url: >-
                      https://developers.lighton.ai/errors#insufficient_permissions
                    index: 1
                  summary: Permission denied (with index)
          description: Permission denied for action
        '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:
    ContentTypeBatchRequest:
      description: |-
        Batch request for content-type schema operations.

        All actions are validated upfront before any execution begins.
      properties:
        actions:
          items:
            $ref: '#/components/schemas/ContentTypeActionRequest'
          maxItems: 50
          minItems: 1
          title: Actions
          type: array
      required:
        - actions
      title: ContentTypeBatchRequest
      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
    ContentTypeActionRequest:
      description: >-
        Request body for POST /api/v3/content-types.


        Action-dispatched per FAC0012. Every action is idempotent.


        Schema-side verb family:
          - ``adopt`` — bulk import from the Pydantic seed catalog.
          - ``define_content_type`` / ``undefine_content_type`` — CRUD on tree nodes.
          - ``define_attribute`` / ``undefine_attribute`` — CRUD on attribute columns.

        Fields are validated per action in ``validate_fields_for_action`` —
        top-level

        optionality mirrors the union of action shapes, so consumers only need a

        single Pydantic class (friendly to drf-spectacular), but the validator

        enforces the narrow contract per action, the same pattern used by

        ``FileFacetActionRequest``.
      properties:
        action:
          allOf:
            - $ref: '#/components/schemas/ContentTypeActionRequestActionEnum'
          title: Action
        content_types:
          default: []
          items:
            type: string
          title: Content Types
          type: array
        parent_path:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Parent Path
        code:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Code
        content_type_path:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Colon-separated content type path.
          title: Content Type Path
        label:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Human-readable label for the node or attribute.
          title: Label
        description:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Optional descriptive text for the node or attribute.
          title: Description
        inherit_attributes:
          anyOf:
            - type: boolean
            - type: 'null'
          default: null
          description: >-
            Whether child content types inherit attributes from ancestors.
            Defaults to true on create.
          title: Inherit Attributes
        name:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Attribute identifier in snake_case.
          title: Name
        attribute_type:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Public attribute type. Supported values: text, number, date,
            boolean, select, multi-select, rich-text. Accepted aliases:
            multi_select, multiselect, rich_text, richtext.
          title: Attribute Type
        required:
          anyOf:
            - type: boolean
            - type: 'null'
          default: null
          description: Whether the attribute is required. Defaults to false.
          title: Required
        choices:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          default: null
          description: >-
            Required for select and multi-select attributes. Must be omitted for
            all other types.
          title: Choices
      required:
        - action
      title: ContentTypeActionRequest
      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
    ContentTypeActionRequestActionEnum:
      enum:
        - adopt
        - define_content_type
        - undefine_content_type
        - define_attribute
        - undefine_attribute
      type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your auth token.

````