데이터베이스 인증 토큰 생성
지정한 데이터베이스의 인증 토큰을 발급하는 API예요.
출처: 문서
본문
요청 예시:
curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases/{databaseName}/auth/tokens?expiration=2w&authorization=full-access' \
-H 'Authorization: Bearer ***'
Node.js 요청 예시:
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 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/{databaseName}/auth/tokens:
post:
summary: Generate Database Auth Token
description: Generates an authorization token for the specified database.
operationId: createDatabaseToken
parameters:
- $ref: '#/components/parameters/organizationSlug'
- $ref: '#/components/parameters/databaseName'
- name: expiration
in: query
schema:
type: string
default: never
description: Expiration time for the token (e.g., 2w1d30m).
- name: authorization
in: query
schema:
type: string
default: full-access
enum:
- full-access
- read-only
description: Authorization level for the token (full-access or read-only).
requestBody:
description: Additional context such as claims required for the token.
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTokenInput'
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
jwt:
type: string
description: The generated authorization token (JWT).
'400':
description: Bad Request
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: The error message
example: Invalid expiration format
'404':
$ref: '#/components/responses/DatabaseNotFoundResponse'
components:
parameters:
organizationSlug:
in: path
name: organizationSlug
required: true
schema:
type: string
description: The slug of the organization or user account.
databaseName:
name: databaseName
in: path
required: true
schema:
type: string
description: The name of the database.
schemas:
CreateTokenInput:
type: object
properties:
permissions:
type: object
description: The permissions for the token.
properties:
read_attach:
type: object
description: Read `ATTACH` permission for the token.
properties:
databases:
type: array
items:
type: string
responses:
DatabaseNotFoundResponse:
description: Database not found
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: The error message
example: >-
could not find database with name [databaseName]: record not
found