Delete/Remove user from bitbucket cloud using Bitbucket API
Asked by Mayank:

I intend to delete users from the Bitbucket cloud programmatically using the bitbucket api  
but can't seem to find the right endpoint,please help me find or provide the right api  
also i would like to delete by passing email associated with the account is there a way to do that?


Answers:
author: Patrik S
body: Hello [@Mayank](/t5/user/viewprofilepage/user-id/5124814) ,

Currently, you can only remove a user from your bitbucket workspace using the public API endpoint below :

* <https://support.atlassian.com/bitbucket-cloud/docs/groups-endpoint/#DELETE-a-member>

We have an open feature request to implement the ability to delete users from the workspace, both from the user groups and direct access. You can access the feature using the following link :

* <https://jira.atlassian.com/browse/BCLOUD-19896>

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with [this policy](https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html) in mind.

As a workaround, you can also use the below Python script to remove user access.

* <https://bitbucket.org/bbcloud-support-scripts/remove-user-access/src/master/>

![](https://getsupport.atlassian.com/images/icons/emoticons/information.png) The above script was produced by an individual within our support team and is not directly supported by Atlassian or our Support team as a whole. This is provided on a best efforts basis and is provided AS IS to try to assist you as much as possible. We recommend you have your dev team review it and ensure you understand what it is attempting to accomplish before executing it. If you would like to change or add functionality to the script, feel free to do so at your end.

Thank you, [@Mayank](/t5/user/viewprofilepage/user-id/5124814) .

Patrik S

comments: author: Mayank
body: Thankyou,i have one more query , currently using App password to authenticate api access using token but it is not authenticating and sends 404 error on each request i make.  
Below is the sample code

```
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
import json

url = "https://api.bitbucket.org/2.0/user/permissions/repositories"

headers = {
  "Accept": "application/json",
  "Authorization": "Bearer <access token>"
}

response = requests.request(
   "GET",
   url,
   headers=headers
)

print(response)
```


author: Patrik S
body: Hello [@Mayank](/t5/user/viewprofilepage/user-id/5124814) ,

From the snippet you shared, it seems like your code is currently configured to use Bearer tokens in the Authorization header, which requires you to [use OAuth 2.0](https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/) and get an access token.

The other type of authentication is called Basic Auth, which uses your bitbucket username and an app password as the credentials for the Authentication head. To use basic auth you will need to configure the headers to be like the below :

```
"Authorization": "Basic <encoded credentials>"
```

Where the \<*encoded credentials\>* placeholder needs to be replaced by the base 64 encoded of your bitbucket username and app password separated by a colon.

For example :

```
mybbusername:myapppassword
```

base 64 encoding would generate

```
bXliYnVzZXJuYW1lOm15YXBwcGFzc3dvcmQ=
```

And the resulting Authorization header would be

```
"Authorization": "Basic bXliYnVzZXJuYW1lOm15YXBwcGFzc3dvcmQ="
```

Hope that helps! Let me know in case you have any questions.

Thank you, [@Mayank](/t5/user/viewprofilepage/user-id/5124814) !

Patrik S


author: noman jalal
body: i also have same issue, i only have email address of user and uuid of my workspace , which end points i will use??


Tags: bitbucket-cloud

cloud