Forums

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

Bitbucket Rest API 2.0 get all users with access to repository

Krzysztof Kluska
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!
April 16, 2019

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
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 17, 2019

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

Deleted user June 5, 2019

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 # people like this
amishra80
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!
July 2, 2019

Did you got any answer?

Tran Tien dung
Contributor
August 14, 2019

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

Lester Peabody
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!
May 5, 2021

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

Like Colin_McDermott likes this
Renee
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!
June 13, 2023

Did anyone ever find a way to get all users in a repository?

0 votes
Herbert Lee
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!
July 1, 2021

For anyone who keeps coming back to this question like I have, the accepted answer is NOT correct.  As stated by @[deleted] 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.

tomlankhorst
Contributor
October 1, 2021

"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
AUG Leaders

Atlassian Community Events