How to get personal token id list along with username, email address and user key using Database query

Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

The steps outlined in this article are provided AS-IS. This means we've had reports of them working for some customers, under certain circumstances, yet they are not officially supported, nor can we guarantee they'll work for your specific scenario.

You may follow through and validate them on your own non-prod environments prior to production, or fall back to supported alternatives if they don't work out.

We also invite you to contact our Community for matters that are outside Atlassian's scope of support!

Database query to get a list of users with details such as username, email address and user key along with token id for users.

Solution

Warning: Backup your database before proceeding.

Before running any SQL in this article, create a full backup of your Jira database. This is a database-level operation with no undo other than restoring from backup. Only proceed if you're comfortable running SQL directly against the Jira database, and test on a staging or cloned environment first, wherever possible.

Below query will get you username, email address, user key and token id for all the users

⚠️ Below query has been tested with postgreSQL , MySQL and Oracle:

PostgreSQL

SELECT CU.USER_NAME ,CU.EMAIL_ADDRESS ,UM.USER_KEY , AFPT."TOKEN_ID"   FROM CWD_USER CU ,USER_MAPPING UM,"AO_81F455_PERSONAL_TOKEN" AFPT WHERE CU.USER_NAME =UM.USERNAME AND UM.USER_KEY = AFPT."USER_KEY";

Oracle

SELECT CU.USER_NAME ,CU.EMAIL_ADDRESS ,UM.USER_KEY , AFPT."TOKEN_ID" FROM CWD_USER CU ,USER_MAPPING UM,"AO_81F455_PERSONAL_TOKEN" AFPT WHERE CU.USER_NAME =UM.USERNAME AND UM.USER_KEY = AFPT."USER_KEY";

MySQL

SELECT CU.USER_NAME ,CU.EMAIL_ADDRESS ,UM.USER_KEY , AFPT.TOKEN_ID FROM cwd_user CU ,user_mapping UM,AO_81F455_PERSONAL_TOKEN AFPT WHERE CU.USER_NAME =UM.USERNAME AND UM.USER_KEY = AFPT.USER_KEY;

We have one KB article on Confluence Data Model. , which will give you more details in case you wish to modify the above query - depending upon the requirement.

Info

Personal access tokens (PATs) are a secure way to use scripts and integrate external applications with your Atlassian application. If an external system is compromised, you simply revoke the token instead of changing the password and consequently changing it in all scripts and integrations.

Personal access tokens are a safe alternative to using username and password for authentication with various services

More details about Using Personal Access Tokens can be found in the document.

Updated on June 18, 2026

Still need help?

The Atlassian Community is here for you.