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

# Create Database

> Creates a new database with tables and fields.

> [!NOTE]
>
> * `tables` is optional: omit it to create an empty database
> * Each table requires at least one field
> * `lookup` and `rollup` fields can't be created here. Add them with [Create Field](https://developers.zite.com/api/fields/create-field.md) once the database exists
> * Table names must be unique within your database
> * Field names must be unique within each table
> * Field types must match the [Field Types Reference](https://developers.zite.com/api/field-types.md)


## OpenAPI

````yaml api/openapi.json POST /bases
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

    Requests are limited to 30 per second per database. Responses carry
    `RateLimit-*` headers, and a request over the limit returns `429 Too Many
    Requests` with a `Retry-After` header and the body `{ "statusCode": 429,
    "error": "Too Many Requests", "message": "..." }`.


    ### Error Handling

    The API returns standard HTTP status codes. Error bodies have the shape `{
    "error": { "code", "message" } }`, except `429` responses (see Rate Limits).
  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
  - name: SQL
    description: Run read-only SQL queries against a database and inspect its SQL schema
paths:
  /bases:
    post:
      tags:
        - Databases
      summary: Create database
      description: Creates a new database with tables and fields
      operationId: createDatabase
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatabaseRequest'
      responses:
        '201':
          description: Database created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Database'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    CreateDatabaseRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          description: Database name
        tables:
          type: array
          items:
            $ref: '#/components/schemas/CreateTableInDatabase'
          description: >-
            Tables to create with the database. Optional: omit it (or send an
            empty array) to create an empty database.
      required:
        - name
    Database:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the database
          example: cd6ff4eff7845d96
        name:
          type: string
          description: Name of the database
        tables:
          type: array
          items:
            $ref: '#/components/schemas/Table'
          description: List of tables in the database
        createdAt:
          type: string
          format: date-time
          description: ISO timestamp of when the database was created
          example: '2025-10-18T02:08:14.784Z'
        updatedAt:
          type: string
          format: date-time
          description: ISO timestamp of when the database was last updated
          example: '2025-10-18T02:08:14.784Z'
        workspaceId:
          type: integer
          description: >-
            ID of the workspace that owns this database. Omitted when the
            database has none.
        url:
          type: string
          format: uri
          description: URL to view this database in the app
          example: https://app.zite.com/database/cd6ff4eff7845d96
      required:
        - id
        - name
        - tables
        - createdAt
        - updatedAt
        - url
    CreateTableInDatabase:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          description: Table name
        fields:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/CreateFieldInTable'
          description: >-
            Fields to create with the table. The first field becomes the primary
            field. `lookup` and `rollup` fields cannot be created here: create
            the table first, then add them with Create Field.
      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/cd6ff4eff7845d96/tbl_abc123
      required:
        - id
        - name
        - order
        - primaryFieldId
        - fields
        - views
        - url
    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
    CreateFieldInTable:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/FieldType'
        name:
          type: string
          minLength: 1
          description: Field name
        template:
          type: object
          additionalProperties: true
          description: >-
            Field-specific configuration. Optional, except for `linked_record`,
            `lookup`, `rollup`, and `formula`; `source` needs an empty object
            (`{}`). See [Field types](/api/field-types) for the template of each
            type.
      required:
        - type
        - name
    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](/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
    FieldType:
      type: string
      enum:
        - single_line_text
        - long_text
        - rich_text
        - email
        - url
        - phone_number
        - number
        - currency
        - percent
        - rating
        - duration
        - single_select
        - multiple_select
        - checkbox
        - date
        - datetime
        - attachments
        - linked_record
        - lookup
        - rollup
        - formula
        - autonumber
        - source
        - created_at
        - updated_at
        - created_by
        - updated_by
        - user
      description: >-
        Field type. See [Field types](/api/field-types) for the value shape and
        template of each type.
  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
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Enter your Zite API key. Format: Bearer <api_key>'

````

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