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

# Create Table

> Adds a new table to an existing database.

Adds a new table with fields to an existing database.

<Note>
  At least one field must be specified. The first field becomes the primary field and must be a supported primary field type. Field names must be unique within the table.
</Note>


## OpenAPI

````yaml help/database/openapi.json POST /bases/{databaseId}/tables
openapi: 3.0.1
info:
  title: Zite DB REST API
  description: >-
    A REST API for managing Zite databases, tables, fields, and records. Build
    database-driven applications with programmatic access to your structured
    data.


    ## What is REST API


    A **REST API** simplifies interaction with your database data, allowing for
    automation and integration. Following RESTful principles, it seamlessly
    connects to retrieve, create, and modify database data.


    ## Getting Started


    ### Authentication

    All API requests require authentication using your Zite API key in the
    Authorization header:

    ```

    Authorization: Bearer YOUR_API_KEY

    ```


    ### Base URL

    https://tables.zite.com/api/v1


    ### Rate Limits

    API requests are rate limited to ensure service quality. Standard rate
    limits apply to all endpoints.


    ### Error Handling

    The API returns standard HTTP status codes and JSON error responses with
    detailed error messages.
  version: 1.0.0
servers:
  - url: https://tables.zite.com/api/v1
    description: Zite DB API
security:
  - bearerAuth: []
tags:
  - name: Databases
    description: Operations for managing databases
  - name: Tables
    description: Operations for managing tables within databases
  - name: Fields
    description: Operations for managing fields within tables
  - name: Records
    description: Operations for managing records within tables
  - name: Webhooks
    description: >-
      Operations for managing webhook subscriptions to receive real-time
      notifications when database events occur
paths:
  /bases/{databaseId}/tables:
    post:
      tags:
        - Tables
      summary: Create table
      description: Adds a new table to an existing database
      operationId: createTable
      parameters:
        - name: databaseId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the database
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTableRequest'
      responses:
        '201':
          description: Table created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Table'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    CreateTableRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          description: Table name
        fields:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/CreateFieldInTable'
          description: Array of field definitions to create with the table
      required:
        - name
        - fields
    Table:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the table
        name:
          type: string
          description: Name of the table
        order:
          type: integer
          description: Display order of the table
        primaryFieldId:
          type: string
          description: ID of the primary field in the table
        fields:
          type: array
          items:
            $ref: '#/components/schemas/Field'
          description: List of fields in the table
        views:
          type: array
          items:
            $ref: '#/components/schemas/View'
          description: List of views in the table
        url:
          type: string
          format: uri
          description: URL to view this table in the app
          example: >-
            https://app.zite.com/database/bad4b276-f604-47ad-86e5-d2ae4f60968f/tbl_abc123
      required:
        - id
        - name
        - order
        - primaryFieldId
        - fields
        - views
        - url
    CreateFieldInTable:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/FieldType'
        name:
          type: string
          minLength: 1
          description: Field name
        template:
          type: object
          description: >-
            Field-specific configuration options. See [Field Types
            Reference](/help/database/api/field-types) for detailed template
            structure by field type.
          additionalProperties: true
      required:
        - type
        - name
        - template
    Field:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the field
        name:
          type: string
          description: Name of the field
        type:
          $ref: '#/components/schemas/FieldType'
        template:
          type: object
          description: >-
            Field-specific configuration options. See [Field Types
            Reference](/help/database/api/field-types) for detailed template
            structure by field type.
          additionalProperties: true
        order:
          type: integer
          description: Display order of the field
      required:
        - id
        - name
        - type
        - template
        - order
    View:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the view
        name:
          type: string
          description: Name of the view
        type:
          type: string
          description: Type of the view (e.g., 'grid')
        config:
          type: object
          properties:
            sorts:
              type: array
              items:
                type: object
              description: Sort configuration for the view
            hiddenFieldIds:
              type: array
              items:
                type: string
              description: Array of field IDs that are hidden in this view
            fieldWidths:
              type: object
              additionalProperties: true
              description: Field width configuration for the view
            orderedFieldIds:
              type: array
              items:
                type: string
              description: Array of field IDs in the order they appear in this view
          required:
            - sorts
            - hiddenFieldIds
            - fieldWidths
            - orderedFieldIds
          description: Configuration object for the view
      required:
        - id
        - name
        - type
        - config
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code
            message:
              type: string
              description: Human-readable error message
          required:
            - code
            - message
      required:
        - error
    FieldType:
      type: string
      enum:
        - single_line_text
        - long_text
        - email
        - url
        - phone_number
        - number
        - currency
        - percent
        - rating
        - duration
        - single_select
        - multiple_select
        - checkbox
        - date
        - datetime
        - attachments
        - linked_record
        - lookup
        - autonumber
        - source
      description: >-
        Field type - see [Field Types Reference](/help/database/api/field-types)
        for complete list of available types and their configurations
  responses:
    BadRequest:
      description: Invalid request data or validation failure
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            invalidRecordId:
              value:
                error:
                  code: INVALID_RECORD_ID
                  message: Record ID is not in valid UUID format
            validationError:
              value:
                error:
                  code: BAD_REQUEST
                  message: Invalid request data or validation failure
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: UNAUTHORIZED
              message: Invalid or missing API key
    NotFound:
      description: Requested resource does not exist
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: NOT_FOUND
              message: Requested resource does not exist
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Enter your Zite API key. Format: Bearer <api_key>'

````