<@U04UQ68083H> is there any way to get an identity...
# ory-copilot
d
@chilly-king-10285 is there any way to get an identity based on email through the REST API?
b
A message from kapa.ai
No, there is no direct way to get an identity based on email through the Ory REST API. The documented API endpoints for retrieving an identity require the identity's ID, not an email or other trait, as the selector. To fetch an identity by email, you would need to list all identities and filter them client-side. The Ory CLI documentation suggests using the list command in combination with jq to filter identities by traits such as email, but this is not available as a direct REST API query parameter. For example, you can use:
Copy code
ory get identity $(ory ls identities --format json | jq -r 'map(select(.recovery_addresses[].value | endswith("@ory.sh"))) | .[].id')
This approach is only available via the CLI and not as a REST API feature. The documentation also acknowledges this limitation and invites users to request such selectors as a feature enhancement[ory get identity](https://www.ory.sh/docs/cli/ory-get-identity#ory-get-identity), [kratos get identity](https://www.ory.sh/docs/kratos/cli/kratos-get-identity#kratos-get-identity). In summary, the REST API does not support querying identities by email directly. You must retrieve all identities and filter them on the client side.