Zum Hauptinhalt springen
Mehrsprachige Guides für TursoDB, MVCC & KI-Agenten Engine-Guide →
Turso Cloud API-Referenz Ressourcen Datenbanken

Datenbank erstellen

Erstellt eine neue Datenbank in einer Gruppe für die Organisation oder den Benutzer.

POST https://api.turso.tech/v1/organizations/{organizationSlug}/databases
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"
  }'
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"
      }
  }'
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"
      }
  }'
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"
      }
  }'
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"
      }
  }'
import { createClient } from "@tursodatabase/api";

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

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

OpenAPI

openapi: 3.0.1
info:
  title: Turso Platform API
  description: API-Beschreibung hier
  license:
    name: MIT
  version: 0.1.0
servers:
  - url: https://api.turso.tech
    description: Die Platform API von Turso
security: []
paths:
  /v1/organizations/{organizationSlug}/databases:
    post:
      summary: Datenbank erstellen
      description: Erstellt eine neue Datenbank in einer Gruppe für die Organisation oder den Benutzer.
      operationId: createDatabase
      parameters:
        - $ref: '#/components/parameters/organizationSlug'
      requestBody:
        description: Datenbankdaten zum Erstellen einer neuen Datenbank
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatabaseInput'
      responses:
        '200':
          description: Erfolgreiche Antwort
          content:
            application/json:
              schema:
                type: object
                properties:
                  database:
                    $ref: '#/components/schemas/CreateDatabaseOutput'
                    description: Die neu erstellte Datenbank
        '400':
          description: Ungültige Anfrage
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Die Fehlermeldung
                    example: group not found
        '409':
          description: Konflikt
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Die Fehlermeldung
                    example: database with name [databaseName] already exists
components:
  parameters:
    organizationSlug:
      in: path
      name: organizationSlug
      required: true
      schema:
        type: string
      description: Der Slug der Organisation oder des Benutzerkontos.
  schemas:
    CreateDatabaseInput:
      type: object
      properties:
        name:
          type: string
          description: >-
            Der Name der neuen Datenbank. Darf nur Kleinbuchstaben, Zahlen und
            Bindestriche enthalten. Höchstens 64 Zeichen lang.
        group:
          type: string
          description: >-
            Der Name der Gruppe, in der die Datenbank erstellt werden soll.
            **Die Gruppe muss bereits existieren.**
        seed:
          type: object
          properties:
            type:
              type: string
              enum:
                - database
                - database_upload
              description: >-
                Der Typ des Seeds, der zum Erstellen einer neuen Datenbank
                verwendet wird. Verwenden Sie `database`, um von einer
                vorhandenen Datenbank zu kopieren, oder `database_upload`, um
                [eine SQLite-Datenbankdatei hochzuladen](/api-reference/databases/upload).
              example: database
            name:
              type: string
              description: >-
                Der Name der vorhandenen Datenbank, wenn `database` als
                Seed-Typ verwendet wird.
              example: my-db
            timestamp:
              type: string
              description: >-
                Ein formatierter Wiederherstellungspunkt nach
                [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), von dem aus
                eine Datenbank erstellt werden soll. Dieser muss innerhalb der
                letzten 24 Stunden liegen, bzw. innerhalb von 30 Tagen beim
                Scaler-Plan.
              example: '2023-12-20T09:46:08Z'
        size_limit:
          type: string
          description: >-
            Die maximale Größe der Datenbank in Bytes. Werte mit Einheiten
            werden ebenfalls akzeptiert, z. B. 1mb, 256mb, 1gb.
        remote_encryption:
          type: object
          description: >-
            Verschlüsselungskonfiguration für die Datenbank. Kann beim Erstellen
            einer neuen verschlüsselten Datenbank, beim Erstellen einer
            verschlüsselten Datenbank aus einem Upload
            (`seed.type = "database_upload"`) oder beim Forken einer
            verschlüsselten Datenbank verwendet werden (erforderlich, wenn die
            Quelldatenbank verschlüsselt ist).
          properties:
            encryption_key:
              type: string
              description: >-
                Base64-kodierter Verschlüsselungsschlüssel. Die Schlüsselgröße
                hängt vom Cipher ab: 32 Bytes für aes256gcm, chacha20poly1305,
                aegis256-Varianten; 16 Bytes für aes128gcm, aegis128l-Varianten.
              example: base64-encoded-key
            encryption_cipher:
              type: string
              enum:
                - aes256gcm
                - aes128gcm
                - chacha20poly1305
                - aegis128l
                - aegis128x2
                - aegis128x4
                - aegis256
                - aegis256x2
                - aegis256x4
              description: Der zu verwendende Verschlüsselungs-Cipher.
              example: aes256gcm
      required:
        - name
        - group
    CreateDatabaseOutput:
      type: object
      properties:
        DbId: 5a8c09f1-4a9f-4578-8c02-e8fca44e59f1
        Hostname: cf6ddb6b-f2b7-45fc-b51f-a007a9ed3012
        Name: 6d1244f4-a64f-4073-a0c0-c3df36d162ad
Synchronisiert aus der offiziellen Turso-Dokumentation ( tursodatabase/turso-docs · MIT-Lizenz) Offizielle Doku ↗
Suche
Esc zum Schließen · Betrieben mit Pagefind