Disconnect database
Disconnect a database from a project, and every environment from the database. The database stays in PlanetScale, and nothing changes there except that the credentials of deployments are deleted.
The response comes at once, and Unkey does the disconnect after it, usually within seconds:
- It deletes the connections of the environments to the database.
- It deletes, in PlanetScale, the credentials that deployments have for the database. A deployment that runs loses its access to the database.
- It removes the database from the project.
Until then, databases.listDatabases still lists the database. Unkey retries a failed delete on its own.
If Unkey has lost its access to PlanetScale while deployments have credentials for the database, it cannot delete them, and you get a 412. Connect PlanetScale again, then send the request again.
The workspace must have the databases, connections and app_v2 flags. Without them you get a 403.
Required Permissions
Your root key must have one of the following permissions:
unkey:v1:<workspace_id>:projects/*/databases/*#delete(to disconnect any database)unkey:v1:<workspace_id>:projects/<project_id>/databases/*#delete(to disconnect any database of one project)unkey:v1:<workspace_id>:projects/<project_id>/databases/<database_id>#delete(to disconnect one database)
Replace <workspace_id> with the authenticated workspace ID.
Authorizations
Unkey uses bearer tokens for authentication. Public integrations use root keys, while the dashboard proxy uses short-lived JWTs. To authenticate, include the token in the Authorization header of each request:
Root keys have specific permissions attached to them, controlling what operations they can perform. Resource permissions use Unkey Resource Names plus actions, like unkey:v1:ws_123:projects/*/keyspaces/*/keys/*#write.
Security best practices:
- Keep root keys secure and never expose them in client-side code
- Use different root keys for different environments
- Rotate keys periodically, especially after team member departures
- Create keys with minimal necessary permissions following least privilege principle
- Monitor key usage with audit logs.
Body
Response
Unkey started the disconnect.