Create database branch
Create a branch of a PlanetScale database that is connected to a project. PlanetScale bills the new branch.
The new branch starts from parent, or from the default branch of the database without it. A Postgres branch is created as a single node, without replicas.
The response has the id of the new branch. PlanetScale is still creating the branch when the response comes back. List the branches of the database to see when it is ready.
Important:
- The database and the parent branch must be ready. If one is not, you get a
412. - A branch name that the database already has gets a
409. - If PlanetScale refuses the create, for example because it does not offer the cluster size, you get a
412.
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/*#write(to create a branch of any database)unkey:v1:<workspace_id>:projects/<project_id>/databases/*#write(to create a branch of any database of one project)unkey:v1:<workspace_id>:projects/<project_id>/databases/<database_id>#write(to create a branch of 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
The name of the branch to start from.
Without parent, the branch starts from the default branch of the database.
On Vitess the new branch copies the schema of its parent. On Postgres and Neki it starts empty.
1 - 256^[A-Za-z0-9][A-Za-z0-9._-]*$"main"
Response
The branch is created.