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

# Get Table Schema



## OpenAPI

````yaml https://raw.githubusercontent.com/InsForge/InsForge/main/openapi/tables.yaml get /api/database/tables/{tableName}/schema
openapi: 3.0.3
info:
  title: Insforge Tables API
  version: 1.0.0
servers: []
security: []
paths:
  /api/database/tables/{tableName}/schema:
    get:
      tags:
        - Admin
      summary: Get Table Schema
      parameters:
        - name: tableName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Table schema
          content:
            application/json:
              schema:
                type: object
                properties:
                  table_name:
                    type: string
                  columns:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        type:
                          type: string
                        nullable:
                          type: boolean
                        unique:
                          type: boolean
                        default:
                          type: string
                          nullable: true
                        isPrimaryKey:
                          type: boolean
                  foreignKeys:
                    type: array
                    description: >-
                      Table-level foreign key constraints (one entry per
                      constraint)
                    items:
                      $ref: '#/components/schemas/ForeignKeyConstraint'
              example:
                tableName: posts
                columns:
                  - name: id
                    type: uuid
                    nullable: false
                    unique: true
                    default: gen_random_uuid()
                    isPrimaryKey: true
                  - name: title
                    type: string
                    nullable: false
                    unique: false
                    default: null
                    isPrimaryKey: false
                  - name: userId
                    type: uuid
                    nullable: false
                    unique: false
                    default: null
                    isPrimaryKey: false
                foreignKeys:
                  - constraintName: fk_userId_auth_users_id
                    referenceTable: auth.users
                    referenceColumns:
                      - sourceColumn: userId
                        referenceColumn: id
                    onDelete: CASCADE
                    onUpdate: CASCADE
        '404':
          description: Table not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: TABLE_NOT_FOUND
                message: Table 'nonexistent' does not exist
                statusCode: 404
                nextActions: Check table name and try again
      security:
        - bearerAuth: []
        - apiKey: []
components:
  schemas:
    ForeignKeyConstraint:
      type: object
      description: >-
        A table-level foreign key constraint. One entry per constraint;
        composite keys list multiple column mappings.
      required:
        - referenceTable
        - referenceColumns
        - onDelete
        - onUpdate
      properties:
        constraintName:
          type: string
          description: >-
            Constraint name. Returned when reading the schema; derived by the
            backend on create.
        referenceTable:
          type: string
          minLength: 1
          description: Table being referenced
        referenceColumns:
          type: array
          minItems: 1
          description: Ordered (source → reference) column pairs
          items:
            type: object
            required:
              - sourceColumn
              - referenceColumn
            properties:
              sourceColumn:
                type: string
                description: Column in the current table
              referenceColumn:
                type: string
                description: Column in the referenced table
        onDelete:
          type: string
          enum:
            - CASCADE
            - SET NULL
            - SET DEFAULT
            - NO ACTION
            - RESTRICT
        onUpdate:
          type: string
          enum:
            - CASCADE
            - SET NULL
            - SET DEFAULT
            - NO ACTION
            - RESTRICT
    ErrorResponse:
      type: object
      required:
        - error
        - message
        - statusCode
      properties:
        error:
          type: string
          description: Error code for programmatic handling
        message:
          type: string
          description: Human-readable error message
        statusCode:
          type: integer
          description: HTTP status code
        nextActions:
          type: string
          description: Suggested action to resolve the error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key

````