Out of the box, you can do from the Keycloak Admin API for the endpoint:
GET /{realm}/users
one can read that :
Get users Returns a list of users, filtered according to query
parameters
those (optional) query parameters being:
- briefRepresentation (boolean);
- email (string);
- first (string);
- firstName (string);
- lastName (string);
- max (Maximum results size (defaults to 100)) (integer);
- search (A String contained in username, first or last name, or email);
- username (string).
As you can see you cannot search for custom attributes. A not so great solution is to get all the users (max=-1), and filter afterwards by the custom attribute.
The other option is to extend Keycloak functionality by adding your own custom Service Provider Interfaces (SPI) and adding your custom endpoint. There you can take advantage of the searchForUserByUserAttribute method from the UserQueryProvider interface.