The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can App Password be used to create a branch

Sam Bennett
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 17, 2022

When creating the App Password, I am able to select the permission repository:write. However, whenever I attempt to use:

POST /2.0/repositories/{workspace}/{repo_slug}/refs/branches

all it does is returns the list of branches. I can see that it states:

OAuth 2.0 scopes required:
repository:write
But does that mean that this can only be used through an OAuth request?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 20, 2022

Hey Sam,

App Password can indeed be used to execute API requests such as this one.

You can run the following request to create a branch using the /2.0/repositories API endpoint:

curl https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/refs/branches 
-s -u username:AppPassword -X POST -H "Content-Type: application/json"
-d '{
"name" : "{new_branch_name}",
"target" : {
"hash" : "main"
}
}'

"Main" should be the existing branch or commit hash from where you want to create a new branch.

The API documentation can be found here:

https://developer.atlassian.com/cloud/bitbucket/rest/api-group-refs/#api-repositories-workspace-repo-slug-refs-branches-post

Cheers!

- Ben (Bitbucket Cloud Support)

DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events