> ## Documentation Index
> Fetch the complete documentation index at: https://docs.servbase.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Databases

> List databases and database users, create and delete databases, change passwords and read connection details.

| Method | Path | Scope |
| - | - | - |
| `GET` | [`/db/list`](#list-databases) | `databases:read` |
| `GET` | [`/db/accounts`](#list-database-users) | `databases:read` |
| `GET` | [`/db/{db_id}/credentials`](#get-credentials) | `databases:credentials` |
| `POST` | [`/db/new`](#create-a-database) | `databases:create` |
| `POST` | [`/db/{db_id}/password`](#change-the-password) | `databases:update` |
| `DELETE` | [`/db/{db_id}`](#delete-a-database) | `databases:delete` |

A database belongs to a **database user** (MySQL, PostgreSQL or Redis), and the user decides its engine. Create database users in the dashboard; the API creates databases for existing users. `db_id` is the database's UUID (`db_uid` in responses).

## List databases

`GET /db/list`

```bash theme={null}
curl https://api.servbase.net/db/list -H "Authorization: Bearer $SERVBASE_API_KEY"
```

```json Response theme={null}
{
  "success": true,
  "items": [
    {
      "db_uid": "0b8f2d64-91a3-4e57-b2c8-7f1e3d9a6c42",
      "account_uid": "c4e91a27-5d3b-4f80-a6e2-19b7c3d5f8a0",
      "db_name": "u7f3_shop",
      "db_type": "postgresql",
      "db_user": "u7f3_app",
      "db_host": "<database host>",
      "db_port": 5432,
      "status": "active",
      "created_at": "2026-10-02 03:15:20",
      "storage_usage": { "used_mb": 18, "total_mb": 500, "remaining_mb": 482, "is_limit_reached": false }
    }
  ],
  "quota": { "databases_used": 1, "databases_total": 5, "databases_remaining": 4, "db_storage_mb_per_database": 500 }
}
```

Passwords are never part of the list. Read them with [Get credentials](#get-credentials).

## List database users

`GET /db/accounts`

```json Response theme={null}
{
  "success": true,
  "items": [
    {
      "account_uid": "c4e91a27-5d3b-4f80-a6e2-19b7c3d5f8a0",
      "db_type": "postgresql",
      "db_user": "u7f3_app",
      "db_host": "<database host>",
      "db_port": 5432,
      "is_enabled": true,
      "status": "active",
      "created_at": "2026-10-02 03:14:02",
      "database_usage": { "used": 1, "total": 3 }
    }
  ],
  "quota": { "sql_accounts_used": 1, "sql_accounts_total": 2, "databases_used": 1, "databases_total": 5 }
}
```

## Get credentials

`GET /db/{db_id}/credentials`

Returns the connection details, including the password. Use a key with only this scope, limited to the database it needs.

```bash cURL theme={null}
curl https://api.servbase.net/db/$DB_ID/credentials -H "Authorization: Bearer $SERVBASE_API_KEY"
```

```python Python theme={null}
c = requests.get(
    f"https://api.servbase.net/db/{db_id}/credentials",
    headers={"Authorization": f"Bearer {API_KEY}"},
    timeout=30,
).json()
dsn = f"postgresql://{c['db_user']}:{c['db_password']}@{c['db_host']}:{c['db_port']}/{c['db_name']}?sslmode=require"
```

```json Response theme={null}
{
  "success": true,
  "db_uid": "0b8f2d64-91a3-4e57-b2c8-7f1e3d9a6c42",
  "db_name": "u7f3_shop",
  "db_type": "postgresql",
  "db_user": "u7f3_app",
  "db_host": "<database host>",
  "db_port": 5432,
  "db_password": "<password>"
}
```

> [!WARNING]
>
> Never print or log the password. Connections from outside your Servbase apps must use TLS.

## Create a database

`POST /db/new`

**db\_name** `string` *required*

The database name. Servbase adds your workspace's prefix and, if the name is taken, a number (for example `u7f3_shop_staging_2`). Use the `db_name` in the response.

**account\_uid** `string` *required*

The database user that owns the new database. Its engine (MySQL, PostgreSQL or Redis) is used.

```bash cURL theme={null}
curl -X POST https://api.servbase.net/db/new \
  -H "Authorization: Bearer $SERVBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"db_name": "shop_staging", "account_uid": "c4e91a27-5d3b-4f80-a6e2-19b7c3d5f8a0"}'
```

```javascript JavaScript theme={null}
const res = await fetch("https://api.servbase.net/db/new", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SERVBASE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ db_name: "shop_staging", account_uid: accountUid }),
});
const db = await res.json();
```

```json Response theme={null}
{
  "success": true,
  "db_id": "9d3a71c5-28e4-4b6f-8a10-c2f5e7b9d413",
  "db_name": "u7f3_shop_staging",
  "db_type": "postgresql",
  "db_user": "u7f3_app",
  "db_host": "<database host>",
  "db_port": 5432,
  "storage_quota_mb": 500,
  "storage_used_mb": 0,
  "created_at": "2026-11-15 09:02:41"
}
```

Creating a database fails with `400` or `403` when the workspace has reached its database limit.

## Change the password

`POST /db/{db_id}/password`

**new\_password** `string` *required*

8 to 256 characters, without control characters.

```bash theme={null}
curl -X POST https://api.servbase.net/db/$DB_ID/password \
  -H "Authorization: Bearer $SERVBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"new_password\": \"$(openssl rand -base64 24 | tr -d '/+=')\"}"
```

```json Response theme={null}
{ "success": true, "db_uid": "0b8f2d64-91a3-4e57-b2c8-7f1e3d9a6c42" }
```

Apps connected to the database are not updated automatically: change their variables and restart them.

## Delete a database

`DELETE /db/{db_id}`

Deletes the database and all of its data. This cannot be undone.

```bash theme={null}
curl -X DELETE https://api.servbase.net/db/$DB_ID -H "Authorization: Bearer $SERVBASE_API_KEY"
```

```json Response theme={null}
{ "success": true, "db_uid": "0b8f2d64-91a3-4e57-b2c8-7f1e3d9a6c42" }
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.