Databases

/api/v1 operations for databases. See HTTP API for authentication, the error envelope, and rate limits.

Operations

GET /api/v1/databases

List databases

Returns the organization's non-deleted production databases. Responses never include usage data or connection credentials.

Auth: API key required.

Operation ID: listDatabases

Responses:

CLI: khotan databases list

POST /api/v1/databases

Create a database

Provisions a production Postgres database synchronously and responds 201 with the persisted record whether provisioning ends ready or failed; branch on the returned status. This operation is not idempotent: retrying a request that already succeeded provisions a second database. Omit regionId to use the default region.

Auth: API key required.

Operation ID: createDatabase

Request body (application/json, required):

Responses:

CLI: khotan databases create

GET /api/v1/databases/{databaseId}

Get a database

Returns one database's record, including status and failure state when present. Responses never include usage data or connection credentials.

Auth: API key required.

Operation ID: getDatabase

Path parameters:

Responses:

CLI: khotan databases get

DELETE /api/v1/databases/{databaseId}

Delete a database

Tears down the provider project, then soft-deletes the record — the same semantics as deleting from the dashboard. Deletion is permanent. Returns 403 resource_protected when the database has deletion protection enabled; protection can only be removed from the dashboard.

Auth: API key required.

Operation ID: deleteDatabase

Path parameters:

Responses:

CLI: khotan databases delete

PUT /api/v1/databases/{databaseId}/tags

Set a database's tags

Replaces a database's tag list with the submitted list and returns the stored list. Tags are normalized to lowercase slugs, so Live is stored as live. Send an empty list to remove every tag. Requires an API key whose role is owner or developer.

Auth: API key required.

Operation ID: setDatabaseTags

Path parameters:

Request body (application/json, required):

Responses:

CLI: khotan databases tags set

GET /api/v1/databases/{databaseId}/connection

Get the connection URI

Returns the full Postgres connection URI for a ready database. The URI grants complete read/write access to the database; treat it as a secret. Responds 404 until the database is ready. All schema and row access happens directly over Postgres using this URI — the API never proxies SQL.

Auth: API key required.

Operation ID: getDatabaseConnection

Path parameters:

Responses:

CLI: khotan databases connection

POST /api/v1/databases/{databaseId}/rotate-credentials

Rotate database credentials

Resets the database role password through the provider and returns the new connection URI; the previous URI stops authenticating immediately. Rotation drops any live connections or pools still using the old credentials — plan to reconnect. Rotation is idempotent: if a rotation reports a persistence failure, rotating again issues a fresh working connection string.

Auth: API key required.

Operation ID: rotateDatabaseCredentials

Path parameters:

Responses:

CLI: khotan databases rotate-credentials

GET /api/v1/databases/{databaseId}/branches

List database branches

Returns the database's non-deleted branches. Responses never include connection credentials.

Auth: API key required.

Operation ID: listDatabaseBranches

Path parameters:

Responses:

CLI: khotan databases branches list

POST /api/v1/databases/{databaseId}/branches

Create a database branch

Branches a ready database synchronously and responds 201 with the persisted record whether provisioning ends ready or failed; branch on the returned status. Omit parentBranchId to branch from the database root. Expiration: omit expiresAt and noExpiry for the ephemeral default, pass expiresAt (ISO 8601) for an explicit expiry, or noExpiry true for a non-expiring branch. This operation is not idempotent.

Auth: API key required.

Operation ID: createDatabaseBranch

Path parameters:

Request body (application/json, required):

Responses:

CLI: khotan databases branches create

GET /api/v1/databases/{databaseId}/branches/{branchId}

Get a database branch

Returns one branch's record, including status and failure state when present. Responses never include connection credentials.

Auth: API key required.

Operation ID: getDatabaseBranch

Path parameters:

Responses:

CLI: khotan databases branches get

DELETE /api/v1/databases/{databaseId}/branches/{branchId}

Delete a database branch

Tears down the provider branch and its compute, then soft-deletes the record. Deletion is permanent. Returns 409 branch_has_children when the branch still has child branches; delete the descendants first.

Auth: API key required.

Operation ID: deleteDatabaseBranch

Path parameters:

Responses:

CLI: khotan databases branches delete

GET /api/v1/databases/{databaseId}/branches/{branchId}/connection

Get a branch connection URI

Returns the full Postgres connection URI for a ready branch. The URI grants complete read/write access to the branch; treat it as a secret. Responds 404 until the branch is ready. All schema and row access happens directly over Postgres using this URI — the API never proxies SQL.

Auth: API key required.

Operation ID: getDatabaseBranchConnection

Path parameters:

Responses:

CLI: khotan databases branches connection

POST /api/v1/databases/{databaseId}/branches/{branchId}/rotate-credentials

Rotate branch credentials

Resets the branch role password through the provider and returns the new connection URI; the previous URI stops authenticating immediately. Rotation drops any live connections or pools still using the old credentials — plan to reconnect. Rotation is idempotent: if a rotation reports a persistence failure, rotating again issues a fresh working connection string.

Auth: API key required.

Operation ID: rotateDatabaseBranchCredentials

Path parameters:

Responses:

CLI: khotan databases branches rotate-credentials

POST /api/v1/databases/{databaseId}/branches/{branchId}/schema-promotions

Plan a database schema promotion

Compares a ready branch schema against the production database schema, records a schema-only promotion plan, validates generated SQL on a temporary provider branch, and returns the persisted plan. It never copies branch data to production.

Auth: API key required.

Operation ID: planDatabaseSchemaPromotion

Path parameters:

Responses:

CLI: khotan databases schema-promotions plan

GET /api/v1/databases/{databaseId}/schema-promotions/{promotionId}

Get a database schema promotion

Returns the recorded schema promotion plan, including SQL, summary, blocked changes, and failure state.

Auth: API key required.

Operation ID: getDatabaseSchemaPromotion

Path parameters:

Responses:

CLI: khotan databases schema-promotions get

POST /api/v1/databases/{databaseId}/schema-promotions/{promotionId}/apply

Apply a database schema promotion

Applies the exact reviewed schema-only promotion SQL to the production database. The stored source and target schema hashes must still match, otherwise the request fails with 409.

Auth: API key required.

Operation ID: applyDatabaseSchemaPromotion

Path parameters:

Responses:

CLI: khotan databases schema-promotions apply