Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,478 views 4 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you