<@U04UQ68083H> how can i find identities by list u...
# ory-copilot
s
@chilly-king-10285 how can i find identities by list username?
b
A message from kapa.ai
To find identities by a list of usernames in Ory, you can use the Ory Identities API's listIdentities endpoint with the credentials_identifier query parameter. However, this parameter only supports an exact match for a single identifier (username or email) at a time, not a list of usernames in a single request. If you have multiple usernames, you will need to make separate requests for each username using the credentials_identifier parameter. For example:
Copy code
GET /admin/identities?credentials_identifier=username1 GET /admin/identities?credentials_identifier=username2 ...
Alternatively, if you already have the IDs of the identities, you can use the ids query parameter to retrieve multiple identities in a single request:
Copy code
GET /admin/identities?ids=id1&id2&id3
But there is no built-in way to search for multiple usernames in a single API call. You would need to loop through your list of usernames and make individual requests for each one, or first fetch all identities and filter them client-side. Here are the relevant parameters from the API: - credentials_identifier: The identifier (username, email) of the credentials to look up using exact match. Only one value can be used per request. - ids: Retrieve multiple identities by their IDs (not usernames) in a single request. This does not support searching by username directly. Reference: [Ory API Reference – listIdentities parameters](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json)
s
@chilly-king-10285 can i use preview_credentials_identifier_similar?
b
A message from kapa.ai
Yes, you can use the preview_credentials_identifier_similar query parameter to perform a similarity (fuzzy) search for identities by a partial identifier, such as a username or email. This allows you to find identities where the identifier partially matches the value you provide. However, please note the following important limitations: - This parameter is experimental and may change or be removed in future releases without any migration path. - Only one of credentials_identifier (exact match) and preview_credentials_identifier_similar (similarity search) can be used per request. - The behavior is not guaranteed to be consistent or deterministic. Example usage:
Copy code
GET /admin/identities?preview_credentials_identifier_similar=partial_username
This will return identities whose credentials identifiers (e.g., usernames or emails) partially match the string you provide. Caution: Since this is an experimental feature, do not rely on it for production-critical workflows, as it may change or be removed at any time without notice. For more details, see the API documentation: > preview_credentials_identifier_similar: This is an EXPERIMENTAL parameter that WILL CHANGE. Do NOT rely on consistent, deterministic behavior. THIS PARAMETER WILL BE REMOVED IN AN UPCOMING RELEASE WITHOUT ANY MIGRATION PATH. CredentialsIdentifierSimilar is the (partial) identifier (username, email) of the credentials to look up using similarity search. Only one of CredentialsIdentifier and CredentialsIdentifierSimilar can be used. [Ory API Reference – listIdentities parameters](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json)