Skip to content

Manage a database

Once your database exists, you manage its whole lifecycle through the Comwit Cloud product API: check whether it’s healthy, rotate the connection token, pause it, bring it back, look at usage, or delete it for good. A Comwit database is a Turso/libSQL database (powered by Louhi) that your app connects to at https://db.cloud.comwit.io — but you never run management operations against that data host. Every lifecycle action goes through the product API at https://api.cloud.comwit.io.

If you haven’t created a database yet, start with Create and connect a database. To run queries against one, see Run SQL.

Each operation below acts on one specific database. The table shows the API route, what it does, and which authentication scope it needs.

ActionWhat it doesAPI
Get statusRead current health and internalsGET /v1/databases/{database}
Rotate connection tokenIssue a fresh one-time token; old one stops workingPOST /v1/databases/{database}/token/rotate
Issue query tokenMint a short-lived SQL tokenPOST /v1/databases/{database}/query-token
SuspendPause the databasePOST /v1/databases/{database}/suspend
ResumeBring a suspended database backPOST /v1/databases/{database}/resume
Get usageRead usage metricsGET /v1/databases/{database}/usage
DeletePermanently remove the databaseDELETE /v1/databases/{database}

Read the current state of a database to confirm it’s healthy before you connect or deploy against it.

API
GET /v1/databases/{database}

The status response includes a status field plus low-level libSQL/WAL internals — the runner, the generation, and frame numbers — exposed for inspection. You’ll usually only care about status; the rest is there when you need to debug replication or storage behavior.

Your long-lived database token is the durable secret your app uses to connect. Rotate it when it leaks, when you’ve lost it, or on a routine schedule.

API
POST /v1/databases/{database}/token/rotate

Rotation returns a fresh, one-time database_token in the response.

Comwit never stores raw tenant tokens, so a rotation response is the only time you’ll see the new secret. If you lose it, your only recovery is to rotate again.

For transient SQL access (for example, an ad-hoc query from a browser session) mint a short-lived query token instead of exposing your durable database token.

API
POST /v1/databases/{database}/query-token
{ "ttl_seconds": 300, "audience": "sql-console", "reason": "ad-hoc query" }

ttl_seconds is bounded between 1 and 3600. The full query-token flow — including the response shape and how the console SQL editor uses it — is covered in Run SQL.

Suspend pauses a database; resume brings it back.

Suspend
POST /v1/databases/{database}/suspend
Resume
POST /v1/databases/{database}/resume

Use suspend to temporarily stop a database without losing it, then resume when you need it again.

Read usage metrics for a database to understand how much it’s being used.

API
GET /v1/databases/{database}/usage

Deleting permanently removes the database.

API
DELETE /v1/databases/{database}

A few safety rules protect platform-critical databases and your secrets.

Some databases are critical to the platform itself and are protected by the PLATFORM_API_PROTECTED_TENANTS setting (which by default includes louhi-app and comwit-db-synthetic). Against a protected tenant, the following operations are rejected with 403:

  • Suspend
  • Resume
  • Delete
  • Rotate connection token
  • Issue query token

This is a launch safety guard to keep critical infrastructure from being paused or torn down by accident. It is not a substitute for project authorization — your request still has to be authorized for the project regardless.

Comwit does not keep a copy of your raw database token anywhere. The output of create and rotate is the single source of that secret. Treat it accordingly: copy it into your own secret store immediately, and if you lose it, rotate to get a new one.