Skip to main content
DBHost CLI is published as @dbhost-app/cli for Pro and Business accounts.

Install

Run the CLI directly with npx:
Or install it globally:
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:
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:
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:
Use the id column from the list output with dbhost databases get <id>. Create a database:
Or pass the display name as the second argument:
Trigger a backup:
Download a backup file:
Delete a backup file:
Reset a database password:
Repair ownership after a pg_dump restore (fixes permission denied from the app role):
Wait for an asynchronous operation:
Manage lifecycle and environment metadata:
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:

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. 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. The CLI has no restore or database deletion command. Use the dashboard or the API; see Restore from a DBHost backup.