Last updated Feb 13, 2023

User's last active dates

Specifications:

  • Returns user’s last active date for each product listed in Atlassian Administration.
  • Active is defined as viewing a product's page for a minimum of 2 seconds.
  • The data for the last activity may be delayed by up to 24 hours.
  • If the user has not accessed a product, the product_access response field will be empty.

Before you begin

To complete this tutorial, you need the following:

API token ≠ API key:

  • This tutorial uses both API token and API key.
  • API token is used with Basic authentication.
  • API key is used as a Bearer token.

Steps to get user's last active dates

Illustration showing the steps to get users last active dates

Step 1: Get accountId

AccountId is a required path parameter to get last active dates of a user.

1. Get API Token

An API token is needed to get the accountId in the next step. Use the API token to authenticate your script.

Atlassian account API Tokens screen

To create an API token:

  1. Go to your Atlassian account to create API token.
  2. Select Create API token at the top of the screen.
  3. Name the token.
  4. Copy the field values and store them securely - you will not be able to see it again.

2. Get accountId

To get the accountId:

  1. Use the Jira User Search API with the API token and Basic authentication to get the accountId: GET /rest/api/3/users/search.

    1
    2
    curl --request GET \ 
    --url 'https://your-domain.atlassian.net/rest/api/3/users/search' \ 
    --user 'email@example.com:<api_token>' \ 
    --header 'Accept: application/json'
    
  2. Search the results by email address or name of the user to find the correct accountId.

Learn more about the Jira API.

If you don’t have Jira, export a .csv of the user list. Learn how to export users from a site

Step 2: User's last active dates

1. Get API Key and Organization ID

The User's last active dates script, uses an API key as a Bearer access token. It also uses the Organization ID field as a path parameter.

Screen to copy the API Key and Organization ID

To create an API key and get the Organization ID:

  1. Go to Atlassian Administration. Select your organization if you have more than one.
  2. Select Settings > API keys.
  3. Select Create API key on the top right.
  4. Enter a name that you’ll remember to identify the API key.
  5. By default, the key expires one week from today. If you’d like to change the expiration date, pick a new date value under Expires on. You’re unable to select a date longer than a year from the date of creation.
  6. Select Create to save the API key.
  7. Copy the values of Organization ID and API key fields by selecting the copy button. Make sure you store these values in a safe place, as we won't show them to you again.
  8. Select Done. The key will appear in your list of API keys.

Learn more about the API keys.

2. User's last active dates

Use the accountId, API key and Organization ID from the previous steps to get users last active dates: GET /admin/v1/orgs/{orgId}/directory/users/{accountId}/last-active-dates

1
2
curl --request GET \ 
--url 'https://api.atlassian.com/admin/v1/orgs/{orgId}/directory/users/{accountId}/last-active-dates' \
--header 'Authorization: Bearer <access_token>'

Response: check last_active field in the response for each product in the list.

1
2
{
    "data": {
        "product_access": [{
            "id": "ari:cloud:jira-software::site/58d24034-e3ec-11ed-b5ea-0242ac120002",
            "key": "jira-software",
            "last_active": "2023-01-19"
        }, {
            "id": "ari:cloud:confluence::site/58d24034-e3ec-11ed-b5ea-0242ac120002",
            "key": "confluence",
            "last_active": "2023-01-12"
        }],
        "added_to_org": "2023-01-11"
    },
    "links": {
      "next": null
    }
}

If the user has not accessed a product, the product_access response field will be empty. The added_to_org field is available only to customers using the new user management experience. Learn more about the new user management experience.

For more details about the Organization's products, for example to look up the product's URL, use Org Workspaces APIs.

Pagination: The following example demonstrates how to use the cursor received in the links response to fetch the next page.

1
2
curl --request GET \
--url 'https://api.atlassian.com/admin/v1/orgs/{orgId}/directory/users/{accountId}/last-active-dates?cursor={next}' \
--header 'Authorization: Bearer <access_token>'

Make your first request and get started with the User's last active dates API and get more information on error codes.

Rate this page: