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

# Get Schema

> Get the schema for a knowledge base



## OpenAPI

````yaml GET /orgs/{org_id}/k2/{kb_id}/schema
openapi: 3.1.0
info:
  title: Timbal Platform API
  description: Public API documentation for the Timbal platform
  license:
    name: ''
  version: 2.0.0
servers:
  - url: https://api.timbal.ai
    description: Production
  - url: https://api.dev.timbal.ai
    description: Development
security: []
tags:
  - name: ace
    description: Action Control Engine (ACE) operations
  - name: alarms
    description: Metric series and threshold alarms
  - name: analytics
    description: Org and project analytics
  - name: billing
    description: Subscriptions, usage, and payment-related operations
  - name: channels
    description: Delivery channels alarms notify through
  - name: content
    description: Re-sign stored content URLs
  - name: files
    description: File operations
  - name: iam
    description: IAM — actions, roles, users, and authorization introspection
  - name: k2
    description: Knowledge Bases v2 operations
  - name: orgs
    description: Organization operations
  - name: projects
    description: Project operations
  - name: runs
    description: Execution operations
  - name: templates
    description: Public project template catalog
  - name: users
    description: Authenticated user profile
paths:
  /orgs/{org_id}/k2/{kb_id}/schema:
    get:
      tags:
        - k2
      description: Get the schema for a knowledge base
      operationId: handler
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
        - name: format
          in: query
          description: 'Response format: "structured" (default) or "sql"'
          required: false
          schema:
            type: string
            enum:
              - structured
              - sql
      responses:
        '200':
          description: Schema
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/K2Schema'
                    description: >-
                      Structured schema with tables, columns, indexes, and
                      constraints (default)
                  - $ref: '#/components/schemas/K2SchemaSql'
                    description: SQL DDL statements (CREATE TABLE, CREATE INDEX, etc.)
                description: >-
                  Response for the schema endpoint — structured (default) or SQL
                  DDL.
      security:
        - bearer_auth: []
components:
  schemas:
    K2Schema:
      type: object
      required:
        - tables
      properties:
        tables:
          type: array
          items:
            $ref: '#/components/schemas/K2Table'
    K2SchemaSql:
      type: object
      required:
        - statements
      properties:
        statements:
          type: array
          items:
            type: string
          description: DDL statements (CREATE TABLE, CREATE INDEX, etc.)
    K2Table:
      type: object
      required:
        - name
        - source
        - columns
        - indexes
        - constraints
        - estimated_row_count
      properties:
        columns:
          type: array
          items:
            $ref: '#/components/schemas/K2Column'
        constraints:
          type: array
          items:
            $ref: '#/components/schemas/K2Constraint'
        estimated_row_count:
          type: integer
          format: int64
          minimum: 0
        indexes:
          type: array
          items:
            $ref: '#/components/schemas/K2Index'
        name:
          type: string
        schema:
          type:
            - string
            - 'null'
        source:
          $ref: '#/components/schemas/K2TableSource'
    K2Column:
      type: object
      required:
        - name
        - data_type
        - is_nullable
      properties:
        data_type:
          type: string
        is_nullable:
          type: boolean
        name:
          type: string
    K2Constraint:
      type: object
      required:
        - constraint_type
      properties:
        columns:
          type: array
          items:
            type: string
          description: Columns involved (for PK, UNIQUE, NOT_NULL). Empty for CHECK.
        constraint_type:
          $ref: '#/components/schemas/K2ConstraintType'
        expression:
          type:
            - string
            - 'null'
          description: CHECK expression, if applicable.
        foreign_keys:
          type: array
          items:
            $ref: '#/components/schemas/K2ForeignKey'
          description: Foreign key references, if applicable.
    K2Index:
      type: object
      required:
        - name
        - table_name
        - columns
        - is_unique
      properties:
        columns:
          type: array
          items:
            type: string
        is_unique:
          type: boolean
        name:
          type: string
        table_name:
          type: string
    K2TableSource:
      type: string
      enum:
        - primary
        - vectors
    K2ConstraintType:
      type: string
      enum:
        - PRIMARY_KEY
        - UNIQUE
        - FOREIGN_KEY
        - CHECK
        - NOT_NULL
    K2ForeignKey:
      type: object
      required:
        - column
        - ref_table
        - ref_column
      properties:
        column:
          type: string
        ref_column:
          type: string
        ref_table:
          type: string
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: >-
        Timbal API key. Obtain your API key from the Timbal platform settings.
        See [Authentication](/api-reference/authentication) for more
        information.

````