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

Datenbank-Auth-Token generieren

Generiert ein Autorisierungstoken für die angegebene Datenbank.

POST https://api.turso.tech/v1/organizations/{organizationSlug}/databases/{databaseName}/auth/tokens
curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases/{databaseName}/auth/tokens?expiration=2w&authorization=full-access' \
  -H 'Authorization: Bearer TOKEN'
import { createClient } from "@tursodatabase/api";

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

const token = await turso.databases.createToken("my-db", {
  expiration: "2w",
  authorization: "full-access",
});
{
  "jwt": "TOKEN"
}

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: Turso's Platform API
security: []
paths:
  /v1/organizations/{organizationSlug}/databases/{databaseName}/auth/tokens:
    post:
      summary: Datenbank-Auth-Token generieren
      description: Generiert ein Autorisierungstoken für die angegebene Datenbank.
      operationId: createDatabaseToken
      parameters:
        - $ref: '#/components/parameters/organizationSlug'
        - $ref: '#/components/parameters/databaseName'
        - name: expiration
          in: query
          schema:
            type: string
            default: never
          description: Ablaufzeit für das Token (z. B. 2w1d30m).
        - name: authorization
          in: query
          schema:
            type: string
            default: full-access
            enum:
              - full-access
              - read-only
          description: Autorisierungsstufe für das Token (full-access oder read-only).
      requestBody:
        description: Zusätzlicher Kontext wie für das Token erforderliche Claims.
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTokenInput'
      responses:
        '200':
          description: Erfolgreiche Antwort
          content:
            application/json:
              schema:
                type: object
                properties:
                  jwt:
                    type: string
                    description: Das generierte Autorisierungstoken (JWT).
        '400':
          description: Ungültige Anfrage
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Die Fehlermeldung
                    example: Invalid expiration format
        '404':
          $ref: '#/components/responses/DatabaseNotFoundResponse'
components:
  parameters:
    organizationSlug:
      in: path
      name: organizationSlug
      required: true
      schema:
        type: string
      description: Der Slug der Organisation oder des Benutzerkontos.
    databaseName:
      name: databaseName
      in: path
      required: true
      schema:
        type: string
      description: Der Name der Datenbank.
  schemas:
    CreateTokenInput:
      type: object
      properties:
        permissions:
          type: object
          description: Die Berechtigungen für das Token.
          properties:
            read_attach:
              type: object
              description: Leseberechtigung `ATTACH` für das Token.
              properties:
                databases:
                  type: array
                  items:
                    type: string
  responses:
    DatabaseNotFoundResponse:
      description: Datenbank nicht gefunden
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                description: Die Fehlermeldung
                example: >-
                  could not find database with name [databaseName]: record not
                  found
Synchronisiert aus der offiziellen Turso-Dokumentation ( tursodatabase/turso-docs · MIT-Lizenz) Offizielle Doku ↗
Suche
Esc zum Schließen · Betrieben mit Pagefind