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

curl example of adding a permission group to a repository

Len Esterhuyse January 19, 2023

Detailed example of adding a permission group to a repository with curl?

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 20, 2023

Hi @Len Esterhuyse,

You can use the following endpoint:

https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-permissions-config-groups-group-slug-put

An example with curl is as follows:

curl -u BitbucketUsername:AppPassword -X PUT -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/<workspace-id>/<repo-slug>/permissions-config/groups/developers -d '{"permission": "write"}'

where

BitbucketUsername is the username of a Bitbucket account with admin permissions to the repo
AppPassword is an app password for this account
<workspace-id> replace with the workspace id where the repo belongs
<repo-slug> replace with your repository slug
developers replace with the group slug of the group you want to add
write is the permission you want to give, it can also be 'read' or 'admin'

If the group already has access to the repo, the group permission will be changed to what you set in this call. Otherwise, the group will be added to the repo with the permissions you set in the call.

Kind regards,
Theodora

Len Esterhuyse January 22, 2023

Thank you very much for the example @Theodora Boudale 

Tweak a bit by escaping last bit  to :

 -d "{\"permission\": \"write\"}"

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events