---
title: "Generate Token"
method: POST
path: "/v1/databases/{db_id}/auth/tokens"
tags: ["Database"]
---

# Generate Token

`POST /v1/databases/{db_id}/auth/tokens`

## Request

- Base URL: `https://api.bunny.net/database`
- URL: `https://api.bunny.net/database/v1/databases/{db_id}/auth/tokens`
- Auth: one of:
  - API key in header `Authorization`
  - API key in header `AccessKey`
- TypeScript: <https://skmtc.dev/bunny/apis/bunny-database-backend-api/docs/v1/databases/:db_id/auth/tokens/post.ts> (a function with typed inputs; its response is checked against the schema)

Generate a Database Auth Token

## Path parameters

- `db_id` string, required: [DatabaseId] is a `db_<ulid>`

## Request body

- GenerateTokenDatabasePayload
  - `expires_at` string, date-time, nullable: The expired at date for the token, if not degined the token won't expire until you invalidate the JWT Secrets. Needs to be a date-time under the [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339)
  - `authorization` 'full-access' | 'read-only', required

## Response `200`

- GenerateTokenDatabaseResponse
  - `token` string, required: The generated JWT for the [Database].
  - `expires_at` string, date-time, nullable: The expired at date for the token. A date-time under the [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339)

## Other responses

- `4XX`: A default error response for most API errors.
- `5XX`: A default error response for most API errors.

---

[API](https://skmtc.dev/bunny/apis/bunny-database-backend-api.md) - [All operations](https://skmtc.dev/bunny/apis/bunny-database-backend-api/llms.txt) - [OpenAPI document](https://skmtc.dev/bunny/apis/bunny-database-backend-api/revisions/f3bb69bad6b6?raw)
