> ## 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 REST API introduction

> Use the DBHost REST API on Pro and Business to create databases, run backups and restores, manage roles and automate CI with scoped API keys.

The DBHost REST API (`https://dbhost.app/api/v1/`) is authenticated with API keys. Use it from your applications, scripts, and CI/CD pipelines. Paid users can issue either selected-database keys or full-account keys.

## API key scope model

Paid users can create two API key scope types:

* **Selected databases** — Recommended least-privilege option. The key only sees and operates on its assigned databases.
* **Full account access** — Can create and manage every database in the owning account.

Selected-database keys only list their assigned databases. For database-specific routes, out-of-scope access behaves like a missing resource and returns `DATABASE_NOT_FOUND`. Full-account-only routes, such as database creation, return `KEY_SCOPE_DENIED` when used with a selected-database key.

## Base URL

```
https://dbhost.app/api/v1
```

## Common cURL examples

List databases visible to the authenticated key:

```bash theme={null}
curl -H "Authorization: Bearer dbh_your_api_key_here" \
  https://dbhost.app/api/v1/databases
```

Create a database with a full-account key:

```bash theme={null}
curl -X POST https://dbhost.app/api/v1/databases \
  -H "Authorization: Bearer dbh_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"name":"analytics-v2","displayName":"Analytics V2"}'
```

Trigger a backup:

```bash theme={null}
curl -X POST \
  -H "Authorization: Bearer dbh_your_api_key_here" \
  https://dbhost.app/api/v1/databases/<database-id>/backups
```

## Response format

Most successful responses return JSON. File downloads such as backup exports return the raw attachment body, and some delete routes return `204 No Content`.

Asynchronous v1 operations return `202 Accepted`, preserve a human-readable
`message`, and include an `operation` object. Read status with
`GET /api/v1/operations/{id}`. Operation types are `backup`, `restore`,
`delete`, `recover`, and `clone`. Statuses are `queued`, `running`,
`succeeded`, `failed`, and `canceled`.

Errors use a standard envelope:

```json theme={null}
{
  "error": {
    "code": "DATABASE_NOT_FOUND",
    "message": "Database 'foo' does not exist",
    "details": []
  }
}
```

Capacity and pause codes you may see on create, start and connection-cap
requests:

| Status | Code | Meaning |
| - | - | - |
| 503 | `CLUSTER_CAPACITY_FULL` | Measured capacity on the shared host is temporarily full. Nothing was created; retry the same request later |
| 503 | `CLUSTER_ADMISSION_UNAVAILABLE` | Capacity could not be verified. Nothing was created; retry later |
| 503 | `CREATE_ROLLED_BACK` | The database could not be created and the attempt was undone. Nothing was left behind and no plan slot is held; retry the same request |
| 409 | `DATABASE_PAUSED_INACTIVE` | The database was paused for inactivity. Start it with `POST /api/v1/databases/{id}/lifecycle` and `{"action":"start"}` |
| 409 | `DATABASE_OPERATION_IN_PROGRESS` | Another operation (backup, restore, clone or delete) is still running on this database. Nothing was changed; retry when it has finished |
| 409 | `CUSTOM_ROLE_LIMIT_REACHED`, `CUSTOM_ROLE_PENDING`, `CONNECTION_CAP_REQUIRED`, `ROLE_BUDGET_UNAVAILABLE` | An additional role could not be reserved; the message says what to change |

## Rate limits

The v1 API applies route-aware limits after authentication and uses shared
control-plane PostgreSQL buckets so limits remain consistent across serverless
instances. A limited response uses `429 RATE_LIMITED` and includes
`Retry-After` plus the applicable rate-limit headers. Clients should honor
`Retry-After`, add jitter, and avoid retrying non-idempotent requests without an
idempotency key.

Requests are authenticated and rate-limited before their bodies are read.

## Resource overview

Account, access and lifecycle:

* `POST /api/v1/databases/{id}/lifecycle`
* `PATCH /api/v1/databases/{id}/environment`
* `GET|POST /api/v1/databases/{id}/network/allowlist`
* `DELETE /api/v1/databases/{id}/network/allowlist/{entryId}`
* `GET|POST /api/v1/databases/{id}/members`
* `PATCH|DELETE /api/v1/databases/{id}/members/{membershipId}`
* `GET /api/v1/databases/{id}/invitations`
* `POST /api/v1/databases/{id}/invitations/{invitationId}/resend`
* `DELETE /api/v1/databases/{id}/invitations/{invitationId}`
* `GET /api/v1/operations/{id}`
* `GET|POST /api/v1/webhooks`
* `POST /api/v1/webhooks/{id}/rotate`
* `DELETE /api/v1/webhooks/{id}`

Deletion and recovery (see [Delete database](https://docs.dbhost.app/api-reference/databases/delete.md)
and [Deleted databases](https://docs.dbhost.app/api-reference/databases/deleted.md)):

* `DELETE /api/v1/databases/{id}`
* `GET /api/v1/databases/deleted`
* `GET /api/v1/databases/{id}/deletion-backup`
* `POST /api/v1/databases/{id}/recover`

A deleted database can be recovered for seven days. After that, DBHost
permanently deletes it and its deletion backup automatically.

Restore from a DBHost backup of the same database (see
[Restore from a DBHost backup](https://docs.dbhost.app/guides/restore-from-backup.md)):

* `POST /api/v1/databases/{id}/backups/{filename}` for a single-login database
* `POST /api/v1/databases/{id}/legacy-overlay-restores` for a single-login
  database with additional roles
* `POST /api/v1/databases/{id}/managed-restores` for a database with managed SQL roles

Clone:

* `POST /api/v1/databases/{id}/clone` clones a single-login database. A
  database with additional roles is rejected with
  `409 LEGACY_OVERLAY_REQUIRES_V4`.

Customer-uploaded SQL and dump restore endpoints are disabled and return
`409 CUSTOM_RESTORE_UPLOAD_DISABLED` for an authorized database. Use the
database owner role with `psql` or `pg_restore` over TLS instead; see
[Restore your own dump](https://docs.dbhost.app/guides/restore-your-own-dump.md).

Database creation, collaborator/invitation management, and customer webhooks
require a full-account API key. A selected-database key can use
database-specific lifecycle, environment, network, and backup routes only for
its selected active databases.

## Extensions

`GET /api/v1/databases/{id}/extensions` returns the supported extensions
(`citext`, `pg_trgm`, `pgcrypto`) with the version available on the server and
the version installed in the selected database. A selected-database API key
can read only its assigned database.

To install or upgrade one of them on a database with managed SQL roles, send
`POST /api/v1/databases/{id}/extensions/operations` with an exact body
`{"extension":"citext","kind":"install"}` (or `pg_trgm`, `pgcrypto` /
`upgrade`) and a stable `Idempotency-Key` header. The response provides an
operation ID for
`GET /api/v1/databases/{id}/extensions/operations/{operationId}`. Check a
pending or uncertain outcome by that ID; sending a new key requests a
different operation. See [PostgreSQL extensions](https://docs.dbhost.app/guides/postgres-extensions.md).


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