Confirm if user is inactive by email address via Jira Cloud API

Hello Jira friends,

I am in search of a Jira Cloud API solution that will detect whether a user is active or inactive based on the user’s email address.

As has been discussed on other threads, the Find users endpoint only returns active users, and that is by design.

I tried building a list of all users using the Get all users endpoint, since that includes inactive users, however, that list doesn’t include the user’s email address, so I have no way to cross-reference the email address.

To provide some background, I handle requests to add new users to our Jira environment. I am provided with a list of several email addresses and a group to which I need to add all of the email addresses. I wrote a script that confirms whether each user is already in our Jira system and whether the user is already in the specified group or not. If any users aren’t in the system, it will first invite them and wait for all accounts to be detected in the system before adding the entire list to the assigned group. The script works great except when any user is actually in the system, but has been deactivated. Then the script gets stuck in a loop trying to invite a user who has already been invited. Thus, I am in search of a way to identify a deactivated user by email address.

Any advice would be greatly appreciated,
Greg

Hello @GregLudovici

Since both endpoints return the accountID of the user, I would have thought that the easiest solution would be to use that value as the key / index between the two data sets:

  • Get the list of all users and their accountID
  • Get the list of active users and their accountID
  • Subtract the second list from the first, which would result in a list of inactive users by their accountID
  • Lookup the email addresses of those users based on their accountID

@sunnyape , I’ll give that a shot! Thanks.

@sunnyape, the last step in your suggestion is where I still get stuck. I believe we can only retrieve an accountId based on an email address if the user is active.

This is because the only way (I know of) to find an account by email is using the Find users endpoint, but that endpoint only returns an accountId if the user is active, otherwise it returns an empty list.

As you point out, I can compile a list of deactivated accountIds by cross-referencing all active and inactive users. I have done that, but my list of inactive users is still missing email addresses. This is the last piece of the puzzle, because what I am given is an email address.

Inactive users can only be queried using the Get all users endpoint, and that endpoint doesn’t return email addresses.

Thus I’m left with a list of inactive accountIds, and no way of telling whether any those Ids go with the email in question.

@GregLudovici
If you’ve tested all the Users endpoints, including Get user email , Get user email bulk and Bulk get users, and none of them return the email address of a user who is deactivated, then you are probably going to have to use some sort of externally cached copy of all your users, their accountIDs and their email addresses as your source of truth.

PS. For the Get user email and Get user email bulk endpoints, you need to get special approval from Atlassian for your app to be able to do that.

There are a number of Jira Cloud feature requests related to activating / deactivating users via the REST API. Perhaps you could add your requirement to one of those requests, or create a new one.

Thanks, @sunnyape !
I’ve voted for and watched several of the Jira Cloud feature requests, and I’ve even spoken with one of the API product owners, so I’ll keep my fingers crossed that in time we’ll have the features we need.

In the meantime, I’ve noticed that when I POST to the /rest/api/3/user endpoint to invite a new user to Jira, if the user is in the system, but deactivated, the endpoint will return an error message containing the phrase, “not sure what went wrong”.

While the message isn’t clear, and might sometimes be referring to a different problem, it seems to be a consistent enough flag to help me detect if a user is deactivated at the Invitation Stage of my automation, rather than at the Check if the User is already in the System Stage. My script then removes the offending user from the Invite List and adds them to the Deactivated Users List. At the end of the process, it lists all of the deactivated users so I can go manually reactive them. After that, I can put the list of newly reactivated users through another script to bulk add them to the project access group. It’s not fully automated, but it’s also not leaving me stuck in an infinite loop, so it’s a step in the right direction.

Thanks again for your thoughts and input,
Greg