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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,460,427
Community Members
 
Community Events
176
Community Groups

Bitbucket Rest API 2.0 get all users with access to repository

Hi,

is there a way to get from bitbucket REST API 2.0 list of all users that have access to the repository?

Basically, the same data that is presented on the web page in "User and group access" in the admin section for the repository.

I have tried something like https://api.bitbucket.org/2.0/repositories/{name}/sample-repo/access but this resource does not exist.

Thank you

2 answers

1 accepted

0 votes
Answer accepted

Hello Krzysztof,

Using the Bitbucket v2 REST API does offer more endpoints then its v1 counterpart. Using the API to access which users are within a repo is a bit more straight forward now. The best option to see which users are within a repo is to use the /2.0/user/permissions/repositories endpoint. This endpoint will allow you to see all users with their permission level granted to your repositories. This endpoint does allow for additional filtering using the following examples:

q=repository.name="geordi" or q=permission>"read"

sort=repository.name

I hope this proves helpful in your quest to gather all users within a repo.

Regards,
Stephen Sifers

When I try this endpoint, I get the repositories the connected user can access, not the users in a repository (I believe this is consistent with the doc: https://developer.atlassian.com/bitbucket/api/2/reference/resource/user/permissions/repositories).

Am I missing something?

Like amishra80 likes this

Did you got any answer?

Well, this endpoint not return all users have access in specific repositories, do you have another measures?

How is this the accepted answer? It doesn't answer the question at all.

Like Colin_McDermott likes this

For anyone who keeps coming back to this question like I have, the accepted answer is NOT correct.  As stated by @Marc Verstaen the accepted answer only returns the caller's permissions, not the permissions of the users that have access to a repository.

To get that information, you need to use either the /2.0/workspaces/{workspace}/permissions/repositories endpoint, which will return all repository permissions within your workspace, or the /2.0/workspaces/{workspace}/permissions/repositories/{repo_slug} endpoint, which will return all the permissions for the specified repository.

"Permissions returned are effective permissions: the highest level of permission the user has. "

Why can't we retrieve the actual permissions on a repository like they are listed on the "User and group access" page? Now, I somehow have to use a deprecated 1.0 API to get groups and their users. Then use this endpoint to get effective permissions, and then use an unreliable diff to figure out direct permissions.

I would like to see a simple endpoint that just returns repository permissions like shown on the configuration page: groups and users.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events