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,363,572
Community Members
 
Community Events
168
Community Groups

How to invite Atlassian user to Bitbucket Cloud via API?

Edited

Hi guys,

While automating user creation in the Atlassian Cloud, I stumbled upon a problem.
Creating an Atlassian account for a user works good. The user is able to access Jira and Confluence.

However, I do not know how to invite a user to Bitbucket via API. What I want to do is add the user to a workspace and some groups within it. I presumed that if I added a user to a group, then they would gain access to the workspace as well.

That is why I tried to use groups endpoint (https://support.atlassian.com/bitbucket-cloud/docs/groups-endpoint/).

However, it requires a UUID. And I do not know how I can get that, if the user is not invited to the Bitbucket cloud yet.

Is there any way to do that via API? Thanks in advance for all the suggestions

1 answer

1 accepted

0 votes
Answer accepted
Caroline R Atlassian Team Jan 12, 2022

Hi, @Michał Łątkowski! Welcome to the community! 

In order to find the UUI of a member of your workspace, you can run the following API call:

$ curl -X GET -u <username>:<AppPassword> "https://api.bitbucket.org/2.0/workspaces/<workspace>/members?fields=values.user.display_name,values.user.uuid"

You can also replace the UUID for the email-id:

 curl --request PUT --user username:AppPassword --header "Content-Type: application/json" https://api.bitbucket.org/1.0/groups/{workspace-id}/{group-slug}/members/{email-id} --data '{}'    

You just need to replace the workspace ID, the corresponding group slug, and the email id of the user you would like to add to this group.

However, if these users do not have a Bitbucket account yet, you will receive an error message saying "No user with validated email address".

So, if you want to add users who do not have a Bitbucket account yet, we recommend that you use the following API call:

 curl  -X PUT -u username:password https://api.bitbucket.org/1.0/users/{workspace_ID}/invitations \
  --header "Content-Type: application/json" \
  --data '{"email":"EMAIL ID","group_slug":"my-group"}'

I hope this helps, but do let me know if you have any questions. 

Kind regards,
Caroline

Caroline, thank you so much for your detailed explanation :) 

Have a nice day!

Kind regards,

Michał

Caroline R Atlassian Team Jan 13, 2022

Hi, Michał! 

I'm glad to help! Please don't hesitate to create new questions in our community if needed. 

Have a nice day too! 

Kind regards,
Caroline 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events