<@U04UQ68083H> can i search for a particular ident...
# ory-copilot
b
@chilly-king-10285 can i search for a particular identity by an identity trait in Kratos admin API? self hosted
b
A message from kapa.ai
Based on the knowledge sources provided, there isn't a direct way to search for identities by specific traits using the Kratos Admin API. The API allows listing identities with some filtering options, but filtering by traits isn't explicitly mentioned. From the documentation, we can see that the
/admin/identities
endpoint allows listing identities, but with limited filtering capabilities: > Lists all [identities](https://www.ory.sh/docs/kratos/concepts/identity-user-model) in the system. Note: filters cannot be combined. [Ory API Reference](https://www.ory.sh/docs/reference/api) There's also a GitHub issue that discusses the limitations of the current identity filtering capabilities: > Ory has a list identities API which retrieves a list of identities with the option of filtering by a credential type (username, email), but does not allow filtering by ids in a batch. The issue suggests some workarounds: 1. Poll Ory periodically for the list of identities and store them in-memory 2. Use webhooks to keep your data in sync with Ory 3. Make parallel requests to get individual identities (suggested by an Ory team member) For self-hosted Kratos, you might need to implement one of these workarounds or consider extending the API functionality yourself if you need this capability. If you need to retrieve a specific identity and you know its ID, you can use the
GetIdentity
endpoint as shown in the Go SDK examples:
Copy code
go getIdentity, r, err := apiClient.IdentityApi.GetIdentity(context.Background(), identityId).Execute() if err != nil {     fmt.Fprintf(os.Stderr, "Error when calling `FrontendApi.GetIdentity``: %v\n", err)     fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } fmt.Fprintf(os.Stdout, "Email for identity with id %v. Traits %v\n", identityId, getIdentity.Traits)