Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to change the name of the default branch when creating a repo via bitbucket cloud API

Andre Pilakis January 31, 2023

Hello, I am attempting to create a bitbucket via the bitbucket cloud API as per:

I have been unsuccessful in being able to create a repo with the main branch named "main", rather than "Master". This is the request I am using:


curl --request POST \
  --url$workspace/$repo_name \
  --header 'Content-Type: application/json' \
  --user $username:$password \
  --data '{
  "project": {"key": "$key"},
  "mainbranch": {"name": "main", "type": "branch"}
Yet whenever I create the branch, the main branch is still called master.

1 answer

0 votes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 2, 2023

G'day, @Andre Pilakis and Welcome to Community!

I understand you wish to create a repository with a new default branch via the Create Repository API endpoint. However, I discover that the API endpoint does not support changing the default branch name when creating a new repository. This is only available in the UI.

We do have an existing feature request on this that I highly suggest you Watch and Vote to get an update at:

Update API endpoint to allow changing main branch name


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events