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

# Create Database

> Creates a new database in a group for the organization or user.

<RequestExample>
  ```bash cURL theme={null}
  curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases' \
    -H 'Authorization: Bearer TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
        "name": "new-database",
        "group": "default"
    }'
  ```

  ```bash cURL (for upload) theme={null}
  curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases' \
    -H 'Authorization: Bearer TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
        "name": "new-database",
        "group": "default",
        "seed": {
          "type": "database_upload"
        }
    }'
  ```

  ```bash cURL (for encrypted upload) theme={null}
  curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases' \
    -H 'Authorization: Bearer TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
        "name": "new-database",
        "group": "default",
        "seed": {
          "type": "database_upload"
        },
        "remote_encryption": {
          "encryption_key": "BASE64_ENCRYPTION_KEY",
          "encryption_cipher": "aes256gcm"
        }
    }'
  ```

  ```bash cURL (new encrypted database) theme={null}
  curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases' \
    -H 'Authorization: Bearer TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
        "name": "new-database",
        "group": "default",
        "remote_encryption": {
          "encryption_key": "BASE64_ENCRYPTION_KEY",
          "encryption_cipher": "aes256gcm"
        }
    }'
  ```

  ```bash cURL (fork encrypted database) theme={null}
  curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases' \
    -H 'Authorization: Bearer TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
        "name": "new-database",
        "group": "default",
        "seed": {
          "type": "database",
          "name": "source-encrypted-db"
        },
        "remote_encryption": {
          "encryption_key": "BASE64_ENCRYPTION_KEY",
          "encryption_cipher": "aes256gcm"
        }
    }'
  ```

  ```ts Node.js theme={null}
  import { createClient } from "@tursodatabase/api";

  const turso = createClient({
    org: "...",
    token: "",
  });

  const database = await turso.databases.create("new-database", {
    group: "default",
  });
  ```
</RequestExample>


## OpenAPI

````yaml POST /v1/organizations/{organizationSlug}/databases
openapi: 3.0.1
info:
  title: Turso Platform API
  description: API description here
  license:
    name: MIT
  version: 0.1.0
servers:
  - url: https://api.turso.tech
    description: Turso's Platform API
security: []
paths:
  /v1/organizations/{organizationSlug}/databases:
    post:
      summary: Create Database
      description: Creates a new database in a group for the organization or user.
      operationId: createDatabase
      parameters:
        - $ref: '#/components/parameters/organizationSlug'
      requestBody:
        description: Database data to create a new database
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatabaseInput'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  database:
                    $ref: '#/components/schemas/CreateDatabaseOutput'
                    description: The newly created database
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The error message
                    example: group not found
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The error message
                    example: database with name [databaseName] already exists
components:
  parameters:
    organizationSlug:
      in: path
      name: organizationSlug
      required: true
      schema:
        type: string
      description: The slug of the organization or user account.
  schemas:
    CreateDatabaseInput:
      type: object
      properties:
        name:
          type: string
          description: >-
            The name of the new database. Must contain only lowercase letters,
            numbers, dashes. No longer than 64 characters.
        group:
          type: string
          description: >-
            The name of the group where the database should be created. **The
            group must already exist.**
        seed:
          type: object
          properties:
            type:
              type: string
              enum:
                - database
                - database_upload
              description: >-
                The type of seed to be used to create a new database. Use
                `database` to copy from an existing database, or
                `database_upload` to [upload a SQLite database
                file](/api-reference/databases/upload).
              example: database
            name:
              type: string
              description: >-
                The name of the existing database when `database` is used as a
                seed type.
              example: my-db
            timestamp:
              type: string
              description: >-
                A formatted [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
                recovery point to create a database from. This must be within
                the last 24 hours, or 30 days on the scaler plan.
              example: '2023-12-20T09:46:08Z'
        size_limit:
          type: string
          description: >-
            The maximum size of the database in bytes. Values with units are
            also accepted, e.g. 1mb, 256mb, 1gb.
        remote_encryption:
          type: object
          description: >-
            Encryption configuration for the database. Can be used when creating
            a new encrypted database, creating a encrypted database from upload
            (`seed.type = "database_upload"`), or forking from an encrypted
            database (required when the source database is encrypted).
          properties:
            encryption_key:
              type: string
              description: >-
                Base64-encoded encryption key. Key size depends on cipher: 32
                bytes for aes256gcm, chacha20poly1305, aegis256 variants; 16
                bytes for aes128gcm, aegis128l variants.
              example: base64-encoded-key
            encryption_cipher:
              type: string
              enum:
                - aes256gcm
                - aes128gcm
                - chacha20poly1305
                - aegis128l
                - aegis128x2
                - aegis128x4
                - aegis256
                - aegis256x2
                - aegis256x4
              description: The encryption cipher to use.
              example: aes256gcm
      required:
        - name
        - group
    CreateDatabaseOutput:
      type: object
      properties:
        DbId: ce701b1f-e20c-47bb-a913-aead1daf0648
        Hostname: 9bd5459c-5059-48f9-ab28-868751a689b5
        Name: 493e7be6-45f8-4985-907a-abae7a2cd5e0

````