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

# DBHost CLI reference

> Install the @dbhost-app/cli package and manage DBHost databases, backups, roles, extensions and access from the terminal on Pro and Business.

DBHost CLI is published as `@dbhost-app/cli` for Pro and Business accounts.

## Install

Run the CLI directly with `npx`:

```bash theme={null}
npx @dbhost-app/cli@latest --help
```

Or install it globally:

```bash theme={null}
npm install -g @dbhost-app/cli
dbhost --help
```

DBHost CLI supports macOS and Linux with Node.js 18 or later.

## Authenticate

Create an API key from **Settings** in the dashboard, then log in:

```bash theme={null}
dbhost auth login --api-key dbh_your_api_key_here
```

The CLI stores the API key locally so you do not need to pass it on every command.

Paid plans support two API key scopes:

* `Selected databases` limits the key to only the databases you choose
* `Full account access` can create and manage every database in your account

`Selected databases` is the recommended default. A `Full account access` key is required for database creation, database recovery, collaborator/member/invitation administration, and webhook administration.

Selected-database keys only list the databases they can access. If you use a database-specific command against an out-of-scope database, the API responds as if the resource were missing.

If you prefer environment variables:

```bash theme={null}
export DBHOST_API_KEY=dbh_your_api_key_here
export DBHOST_API_URL=https://dbhost.app/api/v1
```

> [!WARNING]
>
> Local tests and smoke runs for mutating commands must set `DBHOST_API_URL` to
> an explicit local test server. They fail closed rather than using the
> production default. This rule does not authorize a production CLI mutation.

## Common commands

List databases:

```bash theme={null}
dbhost databases list
```

Use the `id` column from the list output with `dbhost databases get <id>`.

Create a database:

```bash theme={null}
dbhost databases create analytics-v2 --display-name "Analytics V2"
```

Or pass the display name as the second argument:

```bash theme={null}
dbhost databases create analytics-v2 "Analytics V2"
```

Trigger a backup:

```bash theme={null}
dbhost backups trigger <database-id>
```

Download a backup file:

```bash theme={null}
dbhost backups download <database-id> 20260326_222551.sql.gz
```

Delete a backup file:

```bash theme={null}
dbhost backups delete <database-id> 20260326_222551.sql.gz --yes
```

Reset a database password:

```bash theme={null}
dbhost databases reset-password <database-id>
```

Repair ownership after a pg\_dump restore (fixes `permission denied` from the app role):

```bash theme={null}
dbhost databases repair-ownership <database-id>
```

Wait for an asynchronous operation:

```bash theme={null}
dbhost operations wait <operation-id>
```

Manage lifecycle and environment metadata:

```bash theme={null}
dbhost databases stop <database-id>
dbhost databases environment <database-id> staging
```

Use `dbhost backups list <database-id>` to discover the `filename` value before you download or delete a specific backup. Downloads save to `./<filename>` by default; pass `--output` to write the file somewhere else.

## JSON output

Add `--json` to any command for machine-readable output:

```bash theme={null}
dbhost databases list --json
dbhost backups list <database-id> --json
```

## Command reference

Run `dbhost --version` and `dbhost <group> --help` to see what your installed
version supports. Some commands below, including `pgcrypto` for extensions, the
`databases migration*` commands, `databases events`, `databases access-audit`
and the additional-role credential commands, require CLI 0.3.7 or newer.

* `dbhost auth login [--api-key KEY] [--base-url URL]`
* `dbhost auth logout`
* `dbhost databases list [--json]`
* `dbhost databases get <id> [--json]`
* `dbhost databases extensions <id> [--json]`
* `dbhost databases extensions install|upgrade <id> <citext|pg_trgm|pgcrypto> --idempotency-key KEY [--json]`
* `dbhost databases extensions status <id> <operation-id> [--json]`
* `dbhost databases create <name> [display-name] [--display-name "My App"] [--environment production|staging|development|other] [--scheduled-backup none|daily] [--json]`
* `dbhost databases start|stop|restart <id> [--json]`
* `dbhost databases environment <id> <production|staging|development|other|none> [--json]`
* `dbhost databases limits <id> [--json]`
* `dbhost databases limits-set <id> <cap> --idempotency-key KEY [--json]`
* `dbhost databases timeouts <id> [--json]`
* `dbhost databases timeouts-set <id> <standard|balanced|short> --idempotency-key KEY [--json]`
* `dbhost databases migration <id> [--json]`
* `dbhost databases migration-request <id> <public-ip> [second-public-ip] --ttl-minutes 10-120 [--connections 1|2] [--statement-seconds 60-1800] [--lock-seconds 1-30] --idempotency-key KEY [--json]`
* `dbhost databases migration-credentials <id> --show-secret [--json]`
* `dbhost databases migration-revoke <id> --yes [--json]`
* `dbhost databases events <id> [--limit 1-100] [--cursor CURSOR] [--json]`
* `dbhost databases access-audit <id> [--json]`
* `dbhost databases reset-password <id> [--idempotency-key KEY] [--json]`
* `dbhost databases delete <id> <internal-name> --yes --idempotency-key KEY [--no-wait] [--timeout SECONDS] [--poll-interval SECONDS] [--json]`
* `dbhost databases recover <id> --yes --idempotency-key KEY [--connection-cap 2-24] [--no-wait] [--timeout SECONDS] [--poll-interval SECONDS] [--json]`
* `dbhost databases repair-ownership <id> [--json]`
* `dbhost backups list <database-id> [--json]`
* `dbhost backups trigger <database-id> [--no-wait] [--timeout SECONDS] [--poll-interval SECONDS] [--json]`
* `dbhost backups download <database-id> <filename> [--output PATH] [--json]`
* `dbhost backups delete <database-id> <filename> [--yes] [--json]`
* `dbhost operations get <operation-id> [--json]`
* `dbhost operations wait <operation-id> [--timeout SECONDS] [--poll-interval SECONDS] [--json]`
* `dbhost network list <database-id> [--json]`
* `dbhost network add <database-id> <cidr> [label] [--json]`
* `dbhost network remove <database-id> <entry-id> [--json]`
* `dbhost members list <database-id> [--json]`
* `dbhost members add <database-id> <email> <admin|developer|viewer> [--json]`
* `dbhost members update <database-id> <membership-id> <admin|developer|viewer> [--json]`
* `dbhost members remove <database-id> <membership-id> [--json]`
* `dbhost invitations list <database-id> [--json]`
* `dbhost invitations resend|revoke <database-id> <invitation-id> [--json]`
* `dbhost webhooks list [--json]`
* `dbhost webhooks create <https-url> [database-id] [--json]`
* `dbhost webhooks rotate|disable <webhook-id> [--json]`
* `dbhost managed create <name> [--display-name "My App"] [--environment production|staging|development|other] [--scheduled-backup none|daily] --idempotency-key KEY [--json]`
* `dbhost managed clone <source-id> <backup-id> <name> [--display-name "Clone"] --idempotency-key KEY [--json]`
* `dbhost managed roles <database-id> [--json]`
* `dbhost managed credential <database-id> <owner|runtime|readonly> --show-secret [--json]`
* `dbhost managed rotate|revoke <database-id> <owner|runtime|readonly> --idempotency-key KEY --confirm-disconnect [--json]`
* `dbhost managed get-change <database-id> <operation-id> [--json]`
* `dbhost managed reconcile-change <database-id> <operation-id> --confirm-disconnect [--json]`
* `dbhost managed custom-limit|legacy-limit <database-id> <role-id> <limit> --idempotency-key KEY [--json]`
* `dbhost managed custom-continue-limit|legacy-continue-limit <database-id> <role-id> <operation-id> [--json]`
* `dbhost managed custom-rename <database-id> <role-id> --display-name "maintenance" [--json]`
* `dbhost managed custom-roles <database-id> [--json]`
* `dbhost managed custom-rotate|custom-revoke <database-id> <role-id> --idempotency-key KEY --confirm-disconnect [--json]`
* `dbhost managed custom-get-change <database-id> <role-id> <operation-id> [--json]`
* `dbhost managed custom-reconcile-change <database-id> <role-id> <operation-id> --confirm-disconnect [--json]`
* `dbhost managed custom-delete <database-id> <role-id> --yes [--json]`
* `dbhost managed custom-create <database-id> <connection-limit> --display-name "maintenance" --access-profile custom|read_only|read_write --idempotency-key KEY [--json]`
* `dbhost managed legacy-create <database-id> <connection-limit> --display-name "reader" --access-profile custom|read_only|read_write --idempotency-key KEY [--json]`
* `dbhost managed custom-credential <database-id> <role-id> --show-secret [--json]`
* `dbhost managed legacy-opt-in <database-id> [--json]`
* `dbhost managed legacy-roles <database-id> [--json]`
* `dbhost managed legacy-credential <database-id> <role-id> --show-secret [--json]`
* `dbhost managed legacy-rotate|legacy-revoke <database-id> <role-id> --idempotency-key KEY --confirm-disconnect [--json]`
* `dbhost managed legacy-get-change <database-id> <role-id> <operation-id> [--json]`
* `dbhost managed legacy-reconcile-change <database-id> <role-id> <operation-id> --confirm-disconnect [--json]`
* `dbhost managed legacy-remove <database-id> <role-id> [--json]`

Notes:

* `databases create --environment development|other` also needs `--scheduled-backup none|daily`; production always keeps daily backups.
* `databases migration-request` defaults to `--connections 1 --statement-seconds 600 --lock-seconds 5`.
* `databases limits-set` changes the server connection cap shared by all roles of one database, within the range `databases limits` reports as `allowedServerConnectionCap`. New databases start at their plan default: Free 2, Pro 3, Business 4, development 2.
* `--access-profile read_only|read_write|custom` matches Read only, Read & write and Custom in the dashboard.
* `<connection-limit>` is the role's own PostgreSQL connection limit: 1-20 for `legacy-create`; `custom-create` accepts 1 or more and the API checks it against the database's role budget. All roles still share the server connection cap set with `databases limits-set`.
* Managed commands return once; reuse the same idempotency key to reconcile.

Exit codes:

* `0`: Success
* `1`: API, network or other runtime error
* `2`: Usage or validation error; nothing was sent to the API

With `--json`, errors are written to stderr as `{"error":{"code","message"}}`.

`dbhost databases extensions <id> --json` lists the supported extensions for
one database. On a database with managed SQL roles, `install` and `upgrade`
submit one asynchronous operation for `citext`, `pg_trgm`, or `pgcrypto`
(`pgcrypto` needs CLI 0.3.7 or newer); use `status` with the returned
operation ID. Keep the same idempotency key if the first response is
uncertain. See [PostgreSQL extensions](https://docs.dbhost.app/guides/postgres-extensions.md).

`dbhost databases create` uses the single-login creation API. For a new
database with separate managed SQL roles, choose the checkbox in the
dashboard (all plans) or use the managed-create API with a full-account key on
Pro or Business. The `dbhost managed custom-*` commands manage additional
roles on a database with managed SQL roles; see
[Database roles](https://docs.dbhost.app/guides/database-roles.md).

The CLI has no restore or database deletion command. Use the dashboard or the
API; see [Restore from a DBHost backup](https://docs.dbhost.app/guides/restore-from-backup.md).


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