Adding users/groups to a repository using REST API 2.0

Akshay b November 30, 2020

I am trying to add existing user/group to a bitbucket repository (public/private) using REST API 2.0. I am not able to find any endpoints available for it! Can anyone help me with it?

This might be a duplicate of the question: https://community.atlassian.com/t5/Bitbucket-questions/Add-user-to-private-repository-via-BitBucket-REST-API-2-0/qaq-p/1169437

But even there no answers are found!!

2 answers

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

Hi @Akshay b and welcome to the community.

At the moment there is no support for adding users/groups to a repo via API 2.0 in Bitbucket Cloud. Until this is implemented, we have temporary support for 1.0 API resources that can do this.

The following endpoint can be used to send an invitation for direct repo access, see POST send an invite:

The following can be used to send an invitation to a user group, see Issue an invitation to a group:

If you want to create a new user group in a workspace, you can use the following endpoint, see POST a new group:

I hope this helps, please feel free to let me know if you have any questions!

Kind regards,
Theodora

Akshay b December 2, 2020

Thanks @Theodora Boudale . I was able to add groups to a repository in a different way. Check out my answer.

Like Lauren Costa Mafi likes this
William M_ August 2, 2023

Hi @Theodora Boudale ,

is your answer still valid? Are these Endpoints still available?

Thank you in advance!

Regards,

William

0 votes
Akshay b December 2, 2020

Hi,

I was able to add groups to a repo via API 2.0 in Bitbucket Cloud. Instead of trying to add groups to a repo directly, I tired to add Branch Permission to a repository. Something like this.

curl --url "https://api.bitbucket.org/2.0/repositories/{WORKSPACE}/branch-restrictions" --user username:password --request POST --header "Content-Type: application/json" --data "{"kind": "push", "pattern": "{branch_name}","groups": [{"name": "{group_name}","type": "group", "slug": "{group_name}"}]}"


By executing this I was able to add the group to my repository and also was able to set branch permission to that group. But there is one issue, Executing this added all the available groups to the repository with admin access.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events