How to use the groups API in Bitbucket API v1 to retrieve group details
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
This document will provide some examples on how to use the Groups v1 API and some caveats around it. The documentation for the API can be found here -
Examples
Example 1 - Retrieve a specific group's details
You can use the API endpoint to retrieve a specific group's details -
curl -X GET --user <username>:<app-password> "https://api.bitbucket.org/1.0/groups?group=<workspace-ID>/<group-name>"
However, there is a caveat around this API -
- If you are calling the API on a personal workspace, it will retrieve the details for all the groups
- If you are calling the API on a shared workspace, it will only retrieve the details if the credentials of the user calling (App Password in the above example) is a member of the group
- If you are not a member of the group, it will return a 200 status code but an empty response
To know more about shared and personal workspaces, you can refer to this KB -
Example 2 - Retrieve list of all groups
If you simply want to retrieve a full list of all groups in the workspace, you can use the below endpoint -
curl -X GET --user <username>:<app-password> "https://api.bitbucket.org/1.0/groups/<workspace-ID>"