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

# query_tables

> Answer a natural-language question over uploaded table files — one or several.

**Cost class: slow.**

``paths`` is a list of selection rows — ``{"path": ...}`` for a whole file,
``{"path": ..., "component": <tab>}`` for one tab of one workbook (repeat
the path to select several tabs).  Every path must be a **table file** —
a spreadsheet (xlsx, xls, xlsm, xlsb, ods) or record file (csv, tsv,
parquet, jsonl, ndjson, json); a document, media, or image path is
refused with ``invalid_request`` naming ``qa-file``.  Every tab is askable whatever its ingestion produced:
selections whose tabs all have extracted rows are answered by the SQL
engine — the answer keeps full result parquet storage outside the response
and returns bounded previews plus authenticated workspace result-file
citations — while a selection holding tabs with only a rendered sheet is
answered by a QA agent that reads renderings and queries row extractions
together (no result previews on that lane; citations quote the sheets).

``component`` names are workbook-local — the same strings ``file-metadata``
and ``filtered-search`` publish as ``component``, matched exact-name first,
then the unambiguous sanitized alias.  A name that matches nothing on its
own workbook — or any ``component`` on a single-table upload
(csv/jsonl/parquet), which has no named parts — is ``invalid_request``.  A
selected tab with no usable content at all is reported in ``unavailable``
rather than silently dropped.



## OpenAPI

````yaml /openapi.json post /v1/workspaces/{workspace_id}/tools/query-tables
openapi: 3.1.0
info:
  description: >-
    Document intelligence: parse, split, classify, extract, and ground files, or
    build a searchable workspace. Authenticate with ``X-API-Key``.
  title: NDI Platform API
  version: 0.1.0
servers:
  - url: https://ndi-api.nace.ai
security: []
tags: []
paths:
  /v1/workspaces/{workspace_id}/tools/query-tables:
    post:
      tags:
        - tools
      summary: query_tables
      description: >-
        Answer a natural-language question over uploaded table files — one or
        several.


        **Cost class: slow.**


        ``paths`` is a list of selection rows — ``{"path": ...}`` for a whole
        file,

        ``{"path": ..., "component": <tab>}`` for one tab of one workbook
        (repeat

        the path to select several tabs).  Every path must be a **table file** —

        a spreadsheet (xlsx, xls, xlsm, xlsb, ods) or record file (csv, tsv,

        parquet, jsonl, ndjson, json); a document, media, or image path is

        refused with ``invalid_request`` naming ``qa-file``.  Every tab is
        askable whatever its ingestion produced:

        selections whose tabs all have extracted rows are answered by the SQL

        engine — the answer keeps full result parquet storage outside the
        response

        and returns bounded previews plus authenticated workspace result-file

        citations — while a selection holding tabs with only a rendered sheet is

        answered by a QA agent that reads renderings and queries row extractions

        together (no result previews on that lane; citations quote the sheets).


        ``component`` names are workbook-local — the same strings
        ``file-metadata``

        and ``filtered-search`` publish as ``component``, matched exact-name
        first,

        then the unambiguous sanitized alias.  A name that matches nothing on
        its

        own workbook — or any ``component`` on a single-table upload

        (csv/jsonl/parquet), which has no named parts — is ``invalid_request``. 
        A

        selected tab with no usable content at all is reported in
        ``unavailable``

        rather than silently dropped.
      operationId: query_tables_v1_workspaces__workspace_id__tools_query_tables_post
      parameters:
        - description: Workspace identifier.
          in: path
          name: workspace_id
          required: true
          schema:
            description: Workspace identifier.
            format: uuid
            title: Workspace Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryTablesRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryTablesResponse'
          description: Successful Response
        '504':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Gateway Timeout
        default:
          content:
            application/json:
              example:
                error:
                  code: invalid_request
                  detail: null
                  message: >-
                    Request body has extra fields that this operation does not
                    accept.
                  request_id: req-01j9k2n3p4q5r6s7t8v9
                  retryable: false
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: >-
            Typed error envelope used by every 4xx and 5xx. ``error.code``
            distinguishes the failure; HTTP status is a consequence of the code.
      security:
        - APIKeyHeader: []
components:
  schemas:
    QueryTablesRequest:
      additionalProperties: false
      description: |-
        Question over a bounded set of workspace-uploaded table selections.

        Every row's ``path`` must name a **table file** — a spreadsheet (xlsx,
        xls, xlsm, xlsb, ods) or record file (csv, tsv, parquet, jsonl, ndjson,
        json); a document, media, or image path is refused with
        ``invalid_request`` naming ``qa-file``. Every tab is
        askable whatever its ingestion produced — extracted rows, a rendered
        sheet, or both.
      properties:
        include_citations:
          default: true
          title: Include Citations
          type: boolean
        paths:
          items:
            $ref: '#/components/schemas/QueryTableSelection'
          maxItems: 32
          minItems: 1
          title: Paths
          type: array
        query:
          maxLength: 4096
          minLength: 1
          title: Query
          type: string
      required:
        - paths
        - query
      title: QueryTablesRequest
      type: object
    QueryTablesResponse:
      additionalProperties: false
      description: >-
        Answer, provenance, unavailable inputs, and retained result previews.


        Two lanes fill this shape. An all-queryable selection runs the SQL
        engine

        and returns everything: ``tables`` previews, ``result_citations``, and
        SQL

        receipts in ``citations``. A selection holding tabs without extracted
        rows

        runs a QA agent over the files' rendered sheets and row extractions

        together — the answer and quoted ``citations`` are filled, while

        ``tables`` and ``result_citations`` stay empty (no SQL results exist to

        retain). ``unavailable`` reports selections with no usable content on

        either lane.


        ``job_id`` is the durable job row created for this run; retrieve it via

        ``GET /v1/jobs/{job_id}`` to inspect or replay the stored answer.
      properties:
        answer:
          title: Answer
          type: string
        citations:
          default: []
          items:
            $ref: '#/components/schemas/Evidence'
          title: Citations
          type: array
        confidence:
          anyOf:
            - $ref: '#/components/schemas/ConfidenceLevel'
            - type: 'null'
          description: >-
            The engine's self-graded confidence in the answer — how well the
            queried tables support it, on the shared six-level scale (certain /
            very_high / high / medium / low / speculative). Null when the engine
            could not grade (a timeout's partial answer, a legacy run).
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        job_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          title: Job Id
        result_citations:
          default: []
          items:
            $ref: '#/components/schemas/QueryTableCitation'
          title: Result Citations
          type: array
        result_materialization_error:
          anyOf:
            - type: string
            - type: 'null'
          title: Result Materialization Error
        tables:
          default: []
          items:
            $ref: '#/components/schemas/QueryTablePreview'
          title: Tables
          type: array
        timed_out:
          default: false
          title: Timed Out
          type: boolean
        unavailable:
          default: []
          items:
            $ref: '#/components/schemas/UnavailableTable'
          title: Unavailable
          type: array
      required:
        - answer
      title: QueryTablesResponse
      type: object
    ErrorEnvelope:
      description: Every non-2xx body on ``/v1``.
      example:
        error:
          code: invalid_request
          detail: null
          message: Request body has extra fields that this operation does not accept.
          request_id: req-01j9k2n3p4q5r6s7t8v9
          retryable: false
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      title: ErrorEnvelope
      type: object
    QueryTableSelection:
      additionalProperties: false
      description: >-
        One selection row: a whole table file, or one tab of one workbook.


        ``component`` is workbook-local vocabulary — the same strings

        ``file-metadata`` publishes as ``component`` and ``qa-file`` accepts as

        ``component=``, matched exact-name first, then the unambiguous sanitized

        alias. There is deliberately no cross-file component filter: the same
        tab

        name in two workbooks is two rows. Naming a component of a single-table

        upload (csv/jsonl/parquet — one table, no named parts) is refused rather

        than silently ignored: the caller selected something that does not
        exist,

        and answering anyway would answer a different question.
      properties:
        component:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            One tab of this workbook. Omit to select the whole file. Repeat the
            path in another row to select several tabs.
          title: Component
        path:
          title: Path
          type: string
      required:
        - path
      title: QueryTableSelection
      type: object
    Evidence:
      additionalProperties: false
      description: >-
        The citation primitive.


        Every result that asserts something about a document or the corpus
        carries

        it. A synthesised sentence with no evidence behind it is a bug, not a

        degraded mode.


        ``path`` is always the uploaded **source** path — that is what every
        external

        audience (``/v1`` bodies, the console, the search-agent result) is
        shown. The

        two ``exclude=True`` fields below are the host's internal twin of it,
        for the

        audience that must not see source paths at all (the agent's tools
        address

        ingestion derivatives); they are never serialized, so the ``/v1`` wire
        shape

        is exactly what it was before they existed.


        ``component`` closes the loop from a hit back to the file tools: it is
        the

        public component name of the hit — exactly the vocabulary
        ``file-metadata``

        lists and ``qa-file`` / ``read-file`` accept as ``component=`` (the tab
        name

        for a spreadsheet, the section/subcategory for a split document).
        ``None``

        means a single-component file or that attribution was unavailable.


        ``locator`` is present only when the producer actually located the
        snippet.

        ``None`` is not a degraded mode: an engine that answered from a whole

        component (the QA agent's quotes, the DuckDB agent's SQL receipts)
        asserts

        the file and ``component``, nothing finer. Pinning such a snippet to a

        region — a page bbox, a sheet cell range — is a separate ``ground`` call
        on

        ``path`` with ``snippet`` as the target text (and ``component`` as the

        ``sheet`` hint when the file is a spreadsheet).
      properties:
        component:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Public component of the hit, in the vocabulary file-metadata lists
            and qa-file/read-file accept as component= (tab name for
            spreadsheets, section for split documents); None for a
            single-component file or when attribution is unavailable.
          title: Component
        file_id:
          format: uuid
          title: File Id
          type: string
        locator:
          anyOf:
            - discriminator:
                mapping:
                  audio_range:
                    $ref: '#/components/schemas/AudioRange'
                  json_pointer:
                    $ref: '#/components/schemas/JsonPointer'
                  jsonl_record:
                    $ref: '#/components/schemas/JsonlRecord'
                  row_range:
                    $ref: '#/components/schemas/RowRange'
                  spreadsheet_range:
                    $ref: '#/components/schemas/SpreadsheetRange'
                  text_range:
                    $ref: '#/components/schemas/TextRange'
                  visual_region:
                    $ref: '#/components/schemas/VisualRegion'
                propertyName: kind
              oneOf:
                - $ref: '#/components/schemas/TextRange'
                - $ref: '#/components/schemas/VisualRegion'
                - $ref: '#/components/schemas/SpreadsheetRange'
                - $ref: '#/components/schemas/JsonlRecord'
                - $ref: '#/components/schemas/JsonPointer'
                - $ref: '#/components/schemas/AudioRange'
                - $ref: '#/components/schemas/RowRange'
            - type: 'null'
          description: >-
            Where the snippet sits, when the producer located it. None means the
            citation is component-level: ground the snippet against path
            (sheet=component for spreadsheets) to place it.
          title: Locator
        page:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            The 1-based page the producer attributed the snippet to when it
            produced no locator; None when unknown or when the locator already
            carries the page.
          title: Page
        path:
          title: Path
          type: string
        relevance_score:
          title: Relevance Score
          type: number
        snippet:
          title: Snippet
          type: string
        why:
          description: Which retrieval leg matched, or which graph path led here.
          title: Why
          type: string
      required:
        - file_id
        - path
        - relevance_score
        - snippet
        - why
      title: Evidence
      type: object
    ConfidenceLevel:
      description: How well the retrieved evidence supports the answer, worst-case wins.
      enum:
        - certain
        - very_high
        - high
        - medium
        - low
        - speculative
      title: ConfidenceLevel
      type: string
    QueryTableCitation:
      additionalProperties: false
      description: Provenance for one generated TablesQA result file.
      properties:
        grounding:
          anyOf:
            - $ref: '#/components/schemas/TableQueryGrounding'
            - type: 'null'
          description: >-
            Exact source regions and bounded receipt data when capture-time
            provenance was available.
        result_file:
          $ref: '#/components/schemas/QueryTableResultFile'
        source_paths:
          items:
            type: string
          title: Source Paths
          type: array
        sql:
          title: Sql
          type: string
      required:
        - result_file
        - source_paths
        - sql
      title: QueryTableCitation
      type: object
    QueryTablePreview:
      additionalProperties: false
      description: One retained result table with a bounded inline preview.
      properties:
        columns:
          default: []
          items:
            $ref: '#/components/schemas/QueryTableColumn'
          maxItems: 50
          title: Columns
          type: array
        handle:
          title: Handle
          type: string
        path:
          anyOf:
            - type: string
            - type: 'null'
          title: Path
        preview_truncated:
          default: false
          title: Preview Truncated
          type: boolean
        row_count:
          title: Row Count
          type: integer
        rows:
          default: []
          items:
            additionalProperties:
              type: string
            type: object
          maxItems: 20
          title: Rows
          type: array
      required:
        - handle
        - row_count
      title: QueryTablePreview
      type: object
    UnavailableTable:
      additionalProperties: false
      description: >-
        A requested path (or one of its ingested sheets) that could not be
        queried.


        ``error_kind`` is ``None`` only when the failure happened before ingest

        could even classify it (an access or resolution error, which raises as a

        typed HTTP error instead of reaching this list).


        Lives here rather than beside the tool responses because a stored job

        result reports the same unusable inputs the synchronous response did —
        one

        definition, so a reopened run cannot describe them differently.
      properties:
        error:
          title: Error
          type: string
        error_kind:
          anyOf:
            - enum:
                - conversion_rejected
                - conversion_failed
                - profile_rejected
                - profile_failed
              type: string
            - type: 'null'
          title: Error Kind
        path:
          title: Path
          type: string
      required:
        - path
        - error
      title: UnavailableTable
      type: object
    Error:
      description: The error object, per spec 12 §1.8.
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        detail:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: Structured payload, when the code carries one.
          title: Detail
        message:
          description: Human- and model-readable; says what to do differently.
          title: Message
          type: string
        request_id:
          description: Per-request correlation id; matches the ``X-Request-Id`` header.
          title: Request Id
          type: string
        retryable:
          description: Whether retrying the identical request could succeed.
          title: Retryable
          type: boolean
      required:
        - code
        - message
        - retryable
        - request_id
      title: Error
      type: object
    AudioRange:
      additionalProperties: false
      properties:
        end_ms:
          title: End Ms
          type: integer
        kind:
          const: audio_range
          default: audio_range
          title: Kind
          type: string
        start_ms:
          title: Start Ms
          type: integer
      required:
        - start_ms
        - end_ms
      title: AudioRange
      type: object
    JsonPointer:
      additionalProperties: false
      description: An RFC 6901 pointer into a JSON source; an empty string means the root.
      properties:
        kind:
          const: json_pointer
          default: json_pointer
          title: Kind
          type: string
        pointer:
          pattern: ^(?:$|/)
          title: Pointer
          type: string
      required:
        - pointer
      title: JsonPointer
      type: object
    JsonlRecord:
      additionalProperties: false
      properties:
        column:
          anyOf:
            - type: string
            - type: 'null'
          title: Column
        kind:
          const: jsonl_record
          default: jsonl_record
          title: Kind
          type: string
        row_offset:
          title: Row Offset
          type: integer
      required:
        - row_offset
      title: JsonlRecord
      type: object
    RowRange:
      additionalProperties: false
      description: A 0-based inclusive row run on a parquet table.
      properties:
        column:
          anyOf:
            - type: string
            - type: 'null'
          title: Column
        end_row:
          minimum: 0
          title: End Row
          type: integer
        kind:
          const: row_range
          default: row_range
          title: Kind
          type: string
        start_row:
          minimum: 0
          title: Start Row
          type: integer
      required:
        - start_row
        - end_row
      title: RowRange
      type: object
    SpreadsheetRange:
      additionalProperties: false
      properties:
        a1_range:
          title: A1 Range
          type: string
        kind:
          const: spreadsheet_range
          default: spreadsheet_range
          title: Kind
          type: string
        sheet:
          title: Sheet
          type: string
      required:
        - sheet
        - a1_range
      title: SpreadsheetRange
      type: object
    TextRange:
      additionalProperties: false
      description: >-
        A character span in a derivative's text, with the page(s) it falls on.


        ``pages`` is every page the span overlaps — a chunk that straddles a
        page

        marker belongs to both, and a reader handed only the first would miss
        the

        part of the span that carries the match. ``page`` is the first of them,

        kept because most producers and consumers only ever deal in one page.
      properties:
        char_end:
          title: Char End
          type: integer
        char_start:
          title: Char Start
          type: integer
        kind:
          const: text_range
          default: text_range
          title: Kind
          type: string
        page:
          anyOf:
            - type: integer
            - type: 'null'
          title: Page
        pages:
          items:
            type: integer
          title: Pages
          type: array
      required:
        - char_start
        - char_end
      title: TextRange
      type: object
    VisualRegion:
      additionalProperties: false
      properties:
        bbox:
          maxItems: 4
          minItems: 4
          prefixItems:
            - type: number
            - type: number
            - type: number
            - type: number
          title: Bbox
          type: array
        kind:
          const: visual_region
          default: visual_region
          title: Kind
          type: string
        page:
          title: Page
          type: integer
      required:
        - page
        - bbox
      title: VisualRegion
      type: object
    TableQueryGrounding:
      additionalProperties: false
      description: >-
        One SQL query executed against the caller's tables while answering.


        The grounding behind a computed evidence: when the agent answers a

        count/sum/join question it runs a SQL agent over the uploaded tables,
        and

        this is the receipt — the query text and a bounded preview of what it

        returned. Attached to the evidence it grounds rather than published

        globally, so a computed figure and its computation travel together.


        ``source_paths`` name uploaded files, resolved server-side through the

        caller's access gate exactly like ``source_path`` on the evidence
        itself.
      properties:
        columns:
          items:
            $ref: '#/components/schemas/TableQueryColumn'
          title: Columns
          type: array
        grounding_reason:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Qualification on grounding_status, when present. Set for
            'unavailable' (explains why proof was not possible) and for 'exact'
            when capture succeeded but the source regions are broader than the
            minimal contributing set (e.g.
            'regions_broad:narrowing_specs_unavailable'). None when grounding is
            fully exact or absent.
          title: Grounding Reason
        grounding_status:
          anyOf:
            - enum:
                - exact
                - unavailable
                - zero_result
              type: string
            - type: 'null'
          description: >-
            Capture-time provenance status behind this query's regions. 'exact':
            the exact-provenance sidecar proved every row the query read, so its
            'provenance'-basis regions are trustworthy (source regions may be
            broader than the minimal contributing set when grounding_reason
            carries a 'regions_broad:…' qualifier). 'unavailable': no exact
            proof could be captured (a legacy result, or a statement shape the
            capturer cannot instrument) — no 'provenance'-basis regions are
            attached, never a guessed whole-table span. 'zero_result': the query
            matched no rows, so there is nothing to ground. None on legacy
            payloads and on a query with no unclaimed table left to ground.
          title: Grounding Status
        preview_truncated:
          default: false
          description: Whether the preview cut rows or columns.
          title: Preview Truncated
          type: boolean
        regions:
          description: >-
            Original-file coordinates for the verified claims whose source file
            has an addressable grid.
          items:
            discriminator:
              mapping:
                row_range:
                  $ref: '#/components/schemas/RowRangeQueryRegion'
                sheet:
                  $ref: '#/components/schemas/SheetQueryRegion'
              propertyName: kind
            oneOf:
              - $ref: '#/components/schemas/SheetQueryRegion'
              - $ref: '#/components/schemas/RowRangeQueryRegion'
          title: Regions
          type: array
        result_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Stable identity of the stored query result behind this receipt. Lets
            the grounding-rows endpoint replay this exact query for matched-row
            pages beyond the regions' inline runs.
          title: Result Id
        row_count:
          default: 0
          description: Rows in the query's full result, not in the preview below.
          title: Row Count
          type: integer
        rows:
          description: >-
            Leading result rows, values rendered as text — a bounded preview,
            never the full result.
          items:
            additionalProperties:
              type: string
            type: object
          title: Rows
          type: array
        source_paths:
          description: >-
            The uploaded table files this query read — directly, or through a
            prior result it built on — e.g. 'planning/FS GF Custom.xlsx'.
          items:
            type: string
          title: Source Paths
          type: array
        sql:
          title: Sql
          type: string
        supports_answer:
          default: true
          description: >-
            False for exploratory SQL the tables engine ran but did not mark as
            part of the answer's calculation trail.
          title: Supports Answer
          type: boolean
        verified:
          default: false
          description: >-
            True when at least one claim behind this query passed mechanical
            verification against the source data. Independent of 'regions': a
            source without an addressable grid verifies but cannot be pointed
            at, so an empty 'regions' never means unverified.
          title: Verified
          type: boolean
      required:
        - sql
      title: TableQueryGrounding
      type: object
    QueryTableResultFile:
      additionalProperties: false
      description: A workspace-visible Parquet file retained from a TablesQA query.
      properties:
        download_url:
          title: Download Url
          type: string
        download_url_expires_at:
          format: date-time
          title: Download Url Expires At
          type: string
        file_id:
          format: uuid
          title: File Id
          type: string
        file_name:
          title: File Name
          type: string
        format:
          const: parquet
          title: Format
          type: string
        handle:
          title: Handle
          type: string
        path:
          title: Path
          type: string
        preview_url:
          title: Preview Url
          type: string
        row_count:
          title: Row Count
          type: integer
      required:
        - file_id
        - handle
        - path
        - file_name
        - format
        - row_count
        - download_url
        - preview_url
        - download_url_expires_at
      title: QueryTableResultFile
      type: object
    QueryTableColumn:
      additionalProperties: false
      description: One public column in a retained result preview.
      properties:
        data_type:
          title: Data Type
          type: string
        name:
          title: Name
          type: string
      required:
        - name
        - data_type
      title: QueryTableColumn
      type: object
    ErrorCode:
      description: |-
        Every error the ``/v1`` surface can return.

        Clients must treat this as an **open** enum: a new member is an additive
        change (spec 12 §9), and a client that crashes on an unknown code makes
        every future error a breaking change.
      enum:
        - invalid_request
        - unsupported_file_type
        - file_too_large
        - invalid_schema
        - invalid_sql
        - invalid_path_prefix
        - command_not_permitted
        - batch_too_large
        - domain_validation_failed
        - default_label_required
        - wait_required_for_zero_retention
        - workspace_not_found
        - file_not_found
        - job_not_found
        - upload_not_found
        - node_not_found
        - schema_not_found
        - domain_not_found
        - session_not_found
        - access_label_not_found
        - path_conflict
        - schema_version_conflict
        - access_label_name_taken
        - workspace_name_taken
        - access_label_in_use
        - upload_expired
        - file_not_ingested
        - workspace_deleting
        - workspace_not_deletable
        - ingestion_in_progress
        - job_not_cancellable
        - confirmation_required
        - domain_not_published
        - domain_in_use
        - reserved_domain_slug
        - kg_not_built
        - kg_build_in_progress
        - session_busy
        - range_not_satisfiable
        - result_expired
        - access_denied
        - access_backstop_violation
        - access_mode_not_implemented
        - rate_limited
        - concurrency_limit_reached
        - quota_exceeded
        - corrupt_file
        - zero_byte_file
        - encrypted_file
        - parse_failed
        - ocr_failed
        - conversion_failed
        - sheetless_workbook
        - unplayable_media
        - unclassified_pages
        - job_cancelled
        - job_timeout
        - upstream_unavailable
        - internal_error
        - unauthorized
        - not_implemented
      title: ErrorCode
      type: string
    TableQueryColumn:
      additionalProperties: false
      description: One column of an executed SQL query's result preview.
      properties:
        data_type:
          title: Data Type
          type: string
        name:
          title: Name
          type: string
      required:
        - name
        - data_type
      title: TableQueryColumn
      type: object
    RowRangeQueryRegion:
      additionalProperties: false
      description: >-
        A verified region on a pageable tabular artifact, addressed by row
        number.


        A parquet upload stored as-is uses its own row order. A jsonl or parquet

        derivative uses the queried artifact's row order; ``derivative_path``
        names

        that artifact when it differs from the caller-facing ``source_path``.
      properties:
        basis:
          default: verified
          description: >-
            How this region was established. 'verified': a claim whose cited
            value was mechanically re-computed from exactly these rows.
            'inputs': one table's contribution to a derived (multi-table) figure
            — the rows were verified to match the claim's filters, but the
            figure itself is not re-computable from this table alone.
            'provenance': no claim covered this query, so the region records
            what the query's captured provenance proved it read — never a
            whole-table guess. Absent on legacy payloads, which are all
            'verified'.
          enum:
            - verified
            - inputs
            - provenance
          title: Basis
          type: string
        bounding:
          default: false
          description: >-
            True when this is a bounding range over a large match set rather
            than exact runs.
          title: Bounding
          type: boolean
        columns:
          description: Cited column names, in table order.
          items:
            type: string
          title: Columns
          type: array
        derivative_path:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Pageable derivative (parquet or jsonl) when it is not the uploaded
            source itself.
          title: Derivative Path
        end_row:
          description: Last row of the run, 0-based and inclusive.
          title: End Row
          type: integer
        filter_columns:
          description: >-
            Columns the verified claim filtered on to select these rows, minus
            any already in columns. Empty on legacy payloads.
          items:
            type: string
          title: Filter Columns
          type: array
        kind:
          const: row_range
          default: row_range
          title: Kind
          type: string
        matched_rows:
          default: 0
          description: How many source rows the region covers.
          title: Matched Rows
          type: integer
        read_columns:
          description: >-
            Columns the query read from this table (output lineage), minus any
            already in columns or filter_columns. Populated on a
            'provenance'-basis region only; empty otherwise and on legacy
            payloads.
          items:
            type: string
          title: Read Columns
          type: array
        region_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          description: >-
            Opaque identity for paging this exact region when a receipt has
            several regions on one file.
          title: Region Id
        runs:
          description: >-
            Exact matched-row runs inside the span, so a bounding range stays
            pageable as matches only. May cover fewer than matched_rows when the
            verifier truncated its run list; empty on legacy payloads.
          items:
            $ref: '#/components/schemas/ArtifactRowRun'
          title: Runs
          type: array
        runs_replayable:
          default: false
          description: >-
            True only when grounding-rows can reconstruct this exact region
            predicate for pages beyond runs. Regions without a safe replay fail
            closed instead of returning broader rows.
          title: Runs Replayable
          type: boolean
        runs_truncated:
          default: false
          description: >-
            True when runs is an exact ordered prefix of matched islands and
            more matched rows exist. Later pages require guarded replay; false
            when the runs are complete or on legacy payloads.
          title: Runs Truncated
          type: boolean
        scan_index:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Which scan of the query read these rows, when the region records one
            scan rather than the whole table. A query can read one file more
            than once — a narrow CTE and a broad one, say — and each such scan
            grounds separately, so this identifies the scan to replay for
            further row pages. Absent on a whole-table span, on verified
            regions, and on legacy payloads.
          title: Scan Index
        scan_label:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            The scan named the way the query spells it: 'main query', 'CTE
            <name>', or 'subquery <n>'. Present exactly when scan_index is.
          title: Scan Label
        source_path:
          description: Uploaded file path this region belongs to.
          title: Source Path
          type: string
        start_row:
          description: First row of the run, 0-based and inclusive.
          title: Start Row
          type: integer
      required:
        - source_path
        - start_row
        - end_row
      title: RowRangeQueryRegion
      type: object
    SheetQueryRegion:
      additionalProperties: false
      description: >-
        A verified region on a source file with an addressable grid.


        Coordinates are expressed in the caller's uploaded workbook or CSV,
        never

        in the internal parquet derivative.
      properties:
        a1_range:
          description: A1 range on the original sheet, e.g. 'B12:D15'.
          title: A1 Range
          type: string
        basis:
          default: verified
          description: >-
            How this region was established. 'verified': a claim whose cited
            value was mechanically re-computed from exactly these rows.
            'inputs': one table's contribution to a derived (multi-table) figure
            — the rows were verified to match the claim's filters, but the
            figure itself is not re-computable from this table alone.
            'provenance': no claim covered this query, so the region records
            what the query's captured provenance proved it read — never a
            whole-table guess. Absent on legacy payloads, which are all
            'verified'.
          enum:
            - verified
            - inputs
            - provenance
          title: Basis
          type: string
        bounding:
          default: false
          description: >-
            True when this is a bounding box over a large match set rather than
            exact runs.
          title: Bounding
          type: boolean
        kind:
          const: sheet
          default: sheet
          title: Kind
          type: string
        matched_rows:
          default: 0
          description: How many source rows the region covers.
          title: Matched Rows
          type: integer
        scan_index:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Which scan of the query read these rows, when the region records one
            scan rather than the whole table. A query can read one file more
            than once — a narrow CTE and a broad one, say — and each such scan
            grounds separately, so this identifies the scan to replay for
            further row pages. Absent on a whole-table span, on verified
            regions, and on legacy payloads.
          title: Scan Index
        scan_label:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            The scan named the way the query spells it: 'main query', 'CTE
            <name>', or 'subquery <n>'. Present exactly when scan_index is.
          title: Scan Label
        sheet_name:
          anyOf:
            - type: string
            - type: 'null'
          description: Workbook tab, when applicable.
          title: Sheet Name
        source_path:
          description: Uploaded file path this region points at.
          title: Source Path
          type: string
      required:
        - source_path
        - a1_range
      title: SheetQueryRegion
      type: object
    ArtifactRowRun:
      additionalProperties: false
      description: One inclusive 0-based run of matched rows in the pageable artifact.
      properties:
        end:
          description: Last matched row of the run, 0-based and inclusive.
          title: End
          type: integer
        start:
          description: First matched row of the run, 0-based and inclusive.
          title: Start
          type: integer
      required:
        - start
        - end
      title: ArtifactRowRun
      type: object
  securitySchemes:
    APIKeyHeader:
      in: header
      name: X-API-Key
      type: apiKey

````