List database branches
List the branches of a PlanetScale database that is connected to a project.
Name the database by its Unkey id or by its name in PlanetScale. If two databases of the project have the name, you get a 400 and must use the id.
An environment connects to a branch, not to a database. Use this to get the id of the branch before you connect an environment.
The branches come from PlanetScale at the time of the request. Nothing is cached. Results are paginated; when hasMore is true, pass the returned cursor to fetch the next page.
Important: the workspace must have a PlanetScale account connected. Without one you get a 404. If PlanetScale refuses the connection, you get a 412 and must connect PlanetScale 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/*#read(to read the databases of any project)unkey:v1:<workspace_id>:projects/<project_id>/databases/*#read(to read the databases of one project)unkey:v1:<workspace_id>:projects/<project_id>/databases/<database_id>#read(to read 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
The branches of the database.