<@U04UQ68083H> ory kratos i use api /admin/identit...
# ory-copilot
s
@chilly-king-10285 ory kratos i use api /admin/identities?page_size=10&page_token=19727be2-f928-4c71-9dad-0c4bbacadec5 to get list identities but the response show all identities with state = inactive and active. How can i do if i want to get only active identities?
b
A message from kapa.ai
To get only active identities when using the
/admin/identities
endpoint in Ory Kratos, you need to add a query parameter to filter by state. Based on the knowledge sources, you can filter identities by their state using the following approach: Currently, your API call is using pagination parameters (
page_size
and
page_token
), but it doesn't include any filtering for the identity state. According to the documentation, identities can have two states: -
active
- The identity can use self-service flows such as sign-in -
inactive
- The identity can't use self-service flows Unfortunately, the API reference for the
listIdentities
endpoint doesn't explicitly show a parameter for filtering by state in the provided knowledge sources. However, based on the identity state documentation, you can use the identity state to determine whether an identity is active or not. You would need to retrieve all identities and then filter them on your side based on the
state
property in each identity object. Each identity in the response will have a
state
field that is either "active" or "inactive". For reference, the identity state information is documented here: [Identity state](https://www.ory.sh/docs/identities/model/activate-deactivate-user-login-state) If you need to change the state of identities, you can use the SDK as shown in the documentation to activate or deactivate identities.