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

Bitbucket API and user permissions

Sbani
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 24, 2024

Hello, my team is currently on a process of trying to automate the process of project and repo creation, also user permissions. Currently we are looking at branch restriction and how we can better protect our branch merges. Here are some of the questions we'd like to know regarding bitbucket.

1. Do you recommend project or repo level branch restrictions? If project how can we automate seeing they is no API for project level branch restrictions

2.  What else is the purpose of a project other than user/group security and branch permissions.

3. For adding permissions we either require a group slug or user uuid but they is no API to get those, how can we automate the process of adding permission.

 

Your response would be highly appreciated.

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 27, 2024

Hi @Sbani and welcome to the community!

 

1. Do you recommend project or repo level branch restrictions? If project how can we automate seeing they is no API for project level branch restrictions

Project branch restrictions are useful if you want to apply one or more branch restrictions to all repos of a project. You cannot make exceptions for one or a couple of repos in the project, so if you want a certain restriction to apply only to some repos of a project, repository branch restrictions are the way to go.

If automation is important for your team, then repo branch restrictions may be best, since there is no API for project ones. We have the following feature request that you can vote for and watch:

 

2.  What else is the purpose of a project other than user/group security and branch permissions.

A project can act like a folder, if you want to group some repositories of your workspace.

Their other function is to set any the following, for all repos belonging to one project:

  • user permissions
  • access keys
  • access tokens
  • branch restrictions
  • branching model
  • merge strategies
  • default reviewers for PRs

If you want any of the above to be the same for all repos in a project, it's easier to set them in one place (the project), instead of in each repository.

 

3. For adding permissions we either require a group slug or user uuid but they is no API to get those, how can we automate the process of adding permission.

Assuming that we are talking about a user that already has access to the workspace, you can use the following API endpoint to get a list of users with access to the workspace (the user UUID is included in the response for each user):

 

For groups, the automation options depend on whether the Bitbucket workspace has user administration in https://admin.atlassian.com/ or not.

 

Workspaces with user administration in bitbucket.org

You can use the groups endpoint from version 1 of our API to get all groups in a workspace:

Look at the section with the title GET a list of groups. The group slug is included in the response for each of the workspace's user groups.

 

Workspaces with user administration in admin.atlassian.com

Assuming that you want to use this API endpoint to add a group to a project, you will need to use the group ID (instead of the group slug) for a workspace administered in admin.atlassian.com.

You can use the following API endpoint to get all groups in an Atlassian organization and the response will include the group ID for each group:

 

Please feel free to reach out if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events