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

# catalog

> The metadata catalog ingestion extracted from every document: its tables, or one SELECT's rows.

**Cost class: fast.** Answers inline: no job, no credits. Without ``sql``: one table per document
type the workspace holds (invoices, contracts, statements...) with its typed columns, plus
``catalog_document`` over every record. With ``sql``: one read-only SELECT over those tables, its rows
capped and ``truncated`` set when cut. A refused or failing statement answers ``invalid_request`` with
the reason; so does a workspace whose catalog is too large to query whole.

A record is one document section, spreadsheet tab, recording or JSON section, never one printed line:
the entries a listing, register or ledger prints (each credit note in a credit-note report) are not
records of their own. The listing is one record; read it with ``read-file``, or query a tab's rows
with ``run-sql``. Every record carries ``source_path``, the path the other file tools take.



## OpenAPI

````yaml /openapi.json post /v1/workspaces/{workspace_id}/tools/catalog
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/catalog:
    post:
      tags:
        - tools
      summary: catalog
      description: >-
        The metadata catalog ingestion extracted from every document: its
        tables, or one SELECT's rows.


        **Cost class: fast.** Answers inline: no job, no credits. Without
        ``sql``: one table per document

        type the workspace holds (invoices, contracts, statements...) with its
        typed columns, plus

        ``catalog_document`` over every record. With ``sql``: one read-only
        SELECT over those tables, its rows

        capped and ``truncated`` set when cut. A refused or failing statement
        answers ``invalid_request`` with

        the reason; so does a workspace whose catalog is too large to query
        whole.


        A record is one document section, spreadsheet tab, recording or JSON
        section, never one printed line:

        the entries a listing, register or ledger prints (each credit note in a
        credit-note report) are not

        records of their own. The listing is one record; read it with
        ``read-file``, or query a tab's rows

        with ``run-sql``. Every record carries ``source_path``, the path the
        other file tools take.
      operationId: catalog_v1_workspaces__workspace_id__tools_catalog_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/CatalogToolRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogToolResponse'
          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:
    CatalogToolRequest:
      additionalProperties: false
      description: >-
        ``catalog``: no ``sql`` describes the catalog's tables; one ``sql`` runs
        a read-only SELECT over them.
      properties:
        sql:
          anyOf:
            - minLength: 1
              type: string
            - type: 'null'
          description: >-
            One read-only SELECT (or WITH ... SELECT) over the catalog tables;
            omit to list the tables.
          title: Sql
      title: CatalogToolRequest
      type: object
    CatalogToolResponse:
      additionalProperties: false
      description: >-
        A describe fills ``tables``/``empty_tables``; a query fills
        ``columns``/``rows``/``row_count``/``truncated``.
      properties:
        columns:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          description: 'With `sql`: the result''s column names, in order.'
          title: Columns
        empty_tables:
          anyOf:
            - items:
                $ref: '#/components/schemas/CatalogEmptyTable'
              type: array
            - type: 'null'
          description: >-
            Document types with no records here: queryable, every query over
            them is empty.
          title: Empty Tables
        row_count:
          anyOf:
            - type: integer
            - type: 'null'
          description: 'With `sql`: how many rows `rows` holds.'
          title: Row Count
        rows:
          anyOf:
            - items:
                additionalProperties:
                  $ref: '#/components/schemas/JsonValue'
                type: object
              type: array
            - type: 'null'
          description: 'With `sql`: the result rows, each keyed by column name.'
          title: Rows
        tables:
          anyOf:
            - items:
                $ref: '#/components/schemas/CatalogTable'
              type: array
            - type: 'null'
          description: >-
            Without `sql`: `catalog_document` and every document-type table with
            records.
          title: Tables
        truncated:
          anyOf:
            - type: boolean
            - type: 'null'
          description: True when the result had more rows than were returned.
          title: Truncated
      title: CatalogToolResponse
      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
    CatalogEmptyTable:
      additionalProperties: false
      properties:
        columns:
          description: The table's column names; the populated tables describe them.
          items:
            type: string
          title: Columns
          type: array
        document_type:
          description: The document type the table would hold, e.g. `Invoice`.
          title: Document Type
          type: string
        table:
          description: The table's name, as a catalog SELECT spells it.
          title: Table
          type: string
      required:
        - table
        - document_type
        - columns
      title: CatalogEmptyTable
      type: object
    JsonValue: {}
    CatalogTable:
      additionalProperties: false
      properties:
        columns:
          description: Every column the table has, in order.
          items:
            $ref: '#/components/schemas/CatalogTableColumn'
          title: Columns
          type: array
        description:
          description: Which records the table holds.
          title: Description
          type: string
        in_scope_components:
          description: Catalog records (document sections, tabs) the caller may see.
          title: In Scope Components
          type: integer
        table:
          description: The table's name, as a catalog SELECT spells it.
          title: Table
          type: string
      required:
        - table
        - description
        - in_scope_components
        - columns
      title: CatalogTable
      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:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Per-request correlation id; matches the ``X-Request-Id`` header.
            Null only when the error was minted outside any HTTP request, e.g.
            by a worker.
          title: Request Id
        retryable:
          description: Whether retrying the identical request could succeed.
          title: Retryable
          type: boolean
      required:
        - code
        - message
        - retryable
      title: Error
      type: object
    CatalogTableColumn:
      additionalProperties: false
      properties:
        description:
          description: What the column holds, and how to filter on it.
          title: Description
          type: string
        kind:
          description: text, date, money, number, boolean, or identity (`record_id`).
          title: Kind
          type: string
        name:
          description: The column's name, as a catalog SELECT spells it.
          title: Name
          type: string
      required:
        - name
        - kind
        - description
      title: CatalogTableColumn
      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:
        - storage_connection_not_found
        - storage_connection_in_use
        - storage_limit_exceeded
        - storage_conflict
        - storage_auth_required
        - storage_unavailable
        - scan_required
        - scan_rejected
        - scan_unavailable
        - 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
        - ledger_decision_invalid
        - tenant_required
        - partner_required
        - 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
        - ledger_understanding_not_found
        - ledger_table_not_found
        - tenant_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
        - ledger_understanding_in_progress
        - ledger_understanding_version_outdated
        - session_busy
        - tenant_limit_reached
        - range_not_satisfiable
        - result_expired
        - access_denied
        - tenant_disabled
        - access_backstop_violation
        - access_mode_not_implemented
        - rate_limited
        - concurrency_limit_reached
        - quota_exceeded
        - corrupt_file
        - zero_byte_file
        - encrypted_file
        - csv_dialect_ambiguous
        - csv_parse_failed
        - 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
  securitySchemes:
    APIKeyHeader:
      in: header
      name: X-API-Key
      type: apiKey

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.