Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

NoteDescriptionCan be deleted
PrimaryThe default user e-mail in Stash.No
Automatically Linked

Counterparts of already existing e-mails differing only in case.

No
UnmarkedE-mails manually added by the user.Yes

Via REST API
Talk
idtalk-685

The REST API for managing user aliases is located at <bitbucket-host>/rest/awesome-graphs/latest/emails

Via this REST API it is possible to view, add, delete email aliases of Bitbucket Server users. Regular users can perform these operations with their own aliases while Bitbucket system administrators can manage aliases of other users as well.

Viewing aliases

Here is the curl command for viewing your own user aliases:

Talk
idtalk-688

Code Block
curl -u username:password http://bitbucket-host/bitbucket/rest/awesome-graphs/latest/emails

For administrators, to view user aliases of others, the curl command needs to include an additional parameter 'user', which value is the username of the user whose alias an administrator wants to view:

Code Block
curl -u username:password -G -d user=john http://bitbucket-host/bitbucket/rest/awesome-graphs/latest/emails

Below is an example of  the response:

Code Block
{
  "start": 0,
  "limit": 25,
  "size": 2,
  "isLastPage": true,
  "values": [
    {"email": "john.smith@gmail.com", "automatically": false},  
    {"email": "John.Smith@gmail.com", "automatically": true}
  ]
}

An alias has 2 fields: 

  • email - user email address
  • automatically:
    • 'false' means that an alias is added manually by a user or via REST API; 
    • 'true' means that an alias was automatically linked by Awesome Graphs, which happens when a new email alias is being added and the add-on detects that such an email already exists in the database, but differs in case (e.g., John.Johnson@stiltsoft.com and john.johnson@stiltsoft.com), and adds this detected email as an automatically linked alias.

Adding aliases

Here is the curl command for a user to add a new alias for him/herself:

Talk
idtalk-690

Code Block
curl -u username:password -X PUT -G -d email=jsmith@example.com http://bitbucket-host/bitbucket/rest/awesome-graphs/latest/emails

For administrators, to add a user alias for another user, the curl command is supposed to include an additional parameter 'user', which value is the username of the user for whom an administrator needs to add an alias:

Code Block
curl -u username:password -X PUT -G -d user=john -d email=jsmith@example.com http://bitbucket-host/bitbucket/rest/awesome-graphs/latest/emails

When you attempt to add an email address that is already used (by another Bitbucket user or already linked as an alias), you will see the response with display name and the link to the user profile of the current owner of this alias:

Code Block
{"name": "User", "link": "http://bitbucket-host/bitbucket/users/user"}

Deleting aliases

Here is the curl command for deleting your own alias:

Code Block
curl -u username:password -X DELETE -G -d email=jsmith@example.com http://bitbucket-host/bitbucket/rest/awesome-graphs/latest/emails

For administrators, to delete an alias of another user, the curl command is supposed to include an additional parameter 'user', which value is the username of the user whose alias an administrator needs to delete:

Code Block
curl -u username:password -X DELETE -G -d user=john -d email=jsmith@example.com http://bitbucket-host/bitbucket/rest/awesome-graphs/latest/emails
Info

When deleting aliases, it is not possible to delete automatically linked aliases. But when deleting an alias that was added manually or via REST API, a case insensitive search is performed that deletes all found aliases.

In case adding or deleting of aliases is successful, you will get a 200 status code to your HTTP request. When a not existing username is used, you will get a 204 status code.