Last Login Information from Bitbucket Cloud User Directory Export

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

  • As a workspace admin, one can export a list of users who are members of your workspace.

  • The list is downloaded as a CSV file and provides you with each user's public name, the email address associated with their Bitbucket Cloud account, the date and time of their last login, whether or not they are connected via 2SV, and whether or not they are present on your Bitbucket Cloud plan.

  • There is a field in particular as mentioned above called Last Login (UTC) which will be explained in detail throughout this article.

Solution

Explanation

In the below section, we will discuss in detail the last login time shown under the column "Last login (UTC)" for the user "John Smith":

Example:

Public name

Email address

Last login (UTC)

Has 2SV

On Plan

John Smith

johnsmith@example.com

2023-03-01T10:51:49

no

yes

  • The last login data for a user is updated every 24 hours for activities that include API activities using an app password and UI activities like login, browsing repositories, creating pull requests, running pipelines, etc

  • For example, the user "John Smith" has a last login shown as 2023-03-01 with time 10:51:49. The date and time of the last login indicate the user's activity in the last 24 hours, which could be either UI-related activity or API requests.

If any event or activity verified which is older than 24 hours from the previous event should be shown in the latest user directory export against the user. For instance, if the user "John Smith" performed a git clone on 2023-03-02 at 11:00:00, which is older than 24 hours from the previous event, it should be shown in the latest user directory CSV export or dump.

Example:

Public name

Email address

Last login (UTC)

Has 2SV

On Plan

John Smith

johnsmith@example.com

2023-03-02T11:00:00

no

yes

The last login should be an indicator of user activity, but it does not give a breakdown or show the actual events. We do have a feature request BCLOUD-21455 to provide such an option to show a log of a user's activity.

Retrieve the last login details using API

To get last accessed details for the users on workspace, we do have an API to retrieve this data: API to get workspace permissions

Sample curl command:

1 2 3 4 curl --request GET \   --url 'https://api.bitbucket.org/2.0/workspaces/{workspace}/permissions' \   --header 'Authorization: Bearer <access_token>' \   --header 'Accept: application/json'

Sample output:

1 2 3 4 5 6 7                 }             },             "added_on": "2024-02-09T16:18:37.523382+00:00",             "permission": "member",             "last_accessed": "2024-09-18T10:13:52.159725+00:00"         },         {

The output provides last accessed field for every user, which means the time when user did their last activity such as push/add comments etc, on the workspace.

Additionally, below is a sample script that provides details such as user name, UUID and last accessed in a CSV file

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 #!/bin/bash # Replace with your actual Bitbucket username and app password USERNAME="YOUR_USER_NAME" APP_PASSWORD="ADD_YOUR_APP_PASSWORD" WORKSPACE="WORKSPACE_NAME" # Initial API URL for fetching workspace permissions API_URL="https://api.bitbucket.org/2.0/workspaces/$WORKSPACE/permissions" # Output CSV file OUTPUT_FILE="bitbucket_permissions.csv" # Check if jq is installed if ! command -v jq &> /dev/null then     echo "jq could not be found, please install it."     exit 1 fi # Initialize CSV with headers echo "nickname,uuid,last_accessed" > "$OUTPUT_FILE" # Function to process each page of results process_page() {     local response="$1"     # Extract nickname, uuid, and last_accessed, and append to the CSV file     echo "$response" | jq -r '.values[] | [.user.nickname, .user.uuid, .last_accessed] | @csv' >> "$OUTPUT_FILE" } # Loop through all pages while [ -n "$API_URL" ]; do     # Fetch the API response for the current page     response=$(curl -s -u "$USERNAME:$APP_PASSWORD" -X GET "$API_URL")     # Process the current page of results     process_page "$response"     # Check if there's a next page and update API_URL, otherwise set it to empty to end the loop     API_URL=$(echo "$response" | jq -r '.next // empty') done echo "CSV file has been created: $OUTPUT_FILE"

(i) Please note this script is not officially supported by Atlassian. Hence we recommend you to review this with your development team before executing it

Please be aware that the last login details exported from the user directory do not include a user's Git operations such as git clone or push. A feature request ticket BCLOUD-22743 has been created for Git operations to be taken into account when calculating the last login details of a user exported from the user directory. 

However, as a workaround, Admins from organizations with managed user accounts can export the last login information for the user's Bitbucket Cloud accounts, including UI, API, and Git operations, by using the admin.atlassian.com portal.

To do this, navigate to admin.atlassian.com, then go to the directory section and select "Managed Accounts". From there, one can export the last login information they need.

Last Login Details

UI Activities (login, browsing repositories, creating pull requests, running pipelines, etc)

Git Operations (git clone, push using Bitbucket cloud HTTPS/SSH URL)

API requests

Exported from workspace settings → user directory, Bitbucket Cloud

✔️

✔️

Exported from admin.atlassian.com → directory, managed accounts

✔️

✔️

✔️

User activity and last commit

If you are looking for a way to view user activity and the last commit dates of a repository, you can explore the 3rd party application Awesome Graphs for Bitbucket.

Note: For any questions or support regarding the 3rd party application above, you can reach out to them through their support channel.

If you find any discrepancies in the last login data of users or require further clarification on this topic, please raise a support ticket or raise a community support ticket for assistance.

Description

Last Login Information from Bitbucket Cloud User Directory Export

Product

Bitbucket Cloud

Updated on April 10, 2025

Still need help?

The Atlassian Community is here for you.