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

How to allow Workspace/Project Access Token to have write permissions in a (protected) branch

Sumanta Chakraborty April 6, 2023

I believe is very similar to the issue I am hitting.

I have a workspace access token, and I also am protecting the release branch.

The workspace access token can create tags, but not a release branch. How do I give that permission to the token?

The workaround in that ticket is to use OAuth... and I did not want my jenkins/TeamCity based CI CD pipeline script to have to go through that hassle. Is there another way? How do we create protected branches from non-atlassian CI/CD?


To be clear, I am trying to create a branch.

PS build> invoke-restmethod -Method 'POST' -uri "$workspace/$slug/refs/branches" -Headers $headers -Body $body
invoke-restmethod : {"type": "error", "error": {"message": "You are not allowed to create a branch that matches the pattern \"release/*\".", "code":
At line:1 char:1
+ invoke-restmethod -Method 'POST' -uri " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
PS build>

PS build> $headers

Name Value
---- -----
Authorization Bearer XXXXXX..
Content-Type application/json
Accept application/json

PS build> $body
"name": "release/XXXX",
"target": {
"hash": "HEAD"
PS build>

2 answers

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2023

Hello @Sumanta Chakraborty ,

Thank you for reaching out to Atlassian Community!

I've noticed that you have also opened an internal ticket with us, as you have an active Bitbucket subscription, and one of our support engineers is already working with you on that ticket.

I would just like to share here as well, in case others are interested in the same feature, that currently Workspace/Project/Repository Access tokens (WATs, PATs and RATs) are not available to be added in the branch permissions. We have a feature request open to implement this functionality, which can be accessed using the following link : 

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with this policy in mind.

The current workaround is using basic auth with an App Password to authenticate the request.

Thank you, @Sumanta Chakraborty !

Patrik S

0 votes
Sumanta Chakraborty April 6, 2023

Looking for guidance...

Sumanta Chakraborty April 6, 2023

Basic auth of user kind of works - but I get Rate limited continuously.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events