JIRA API - Find users query behavior

I’m trying to understand the behavior of the following endpoint -

GET /rest/api/3/user/search

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-user-search/#api-rest-api-3-user-search-get

The documentation describes the query param as following -

query

string

A query string that is matched against user attributes ( displayName , and emailAddress ) to find relevant users. The string can match the prefix of the attribute’s value. For example, query=john matches a user with a displayName of John Smith and a user with an emailAddress of johnson@example.com . Required, unless accountId or property is specified.

Can this endpoint be used to reliably find a user by email even though the email address may or may not be included in the response?

For example, GET /rest/api/3/user/search?query=user@domain.com

I was worried we may have an issue if a user with the displayName ‘user@gmail.com’ exists.

I tested this scenario by posting a user with this displayName and the user was not included when I queried using GET /rest/api/3/user/search?query=user@domain.com.

Is the behavior of the query to only search by email if string is in an email format.

For example, GET /rest/api/3/user/search?query=domain.com would include the user.

Let me know any further clarification is needed.

The interesting scenario I noticed though was this -

With a user whose displayName ="tmp@domain.com" or any user who’s displayName is the format of an email, querying the search endpoint returns nothing.

GET /rest/api/3/user/search?query=tmp@domain.com
returns an empty array.

I don’t know the source code but it appears that if the query is in an email format, the search endpoint won’t attempt to match a displayName and only attempts to match by email.

It’s an edge case, but I’m just looking to confirm the true behavior of the query param.

I know this is an old thread, but since a bit of the logic used to match query strings is mentioned in below bug ticket I am pasting it here in case anyone can search for similar topics in the future:

1 Like