<@U04UQ68083H> how do I find all users whose email...
# ory-copilot
v
@chilly-king-10285 how do I find all users whose email ends with @example.com?
b
A message from kapa.ai
Currently, Ory does not support searching for all users whose email ends with a specific domain (e.g., @example.com) directly via the Users Management UI or the API using a domain filter. This limitation is confirmed in a recent GitHub issue, where users reported that even with fuzzy search enabled, searching by domain (such as "gmail.com") does not return all users with emails from that domain. The only available workaround mentioned is filtering users by organization ID, not by email domain. There is no built-in API parameter to filter identities by email domain at this time [Identities cannot be search by domain](https://github.com/ory/network/issues/405). If you need to find all users with a specific email domain, you would need to: 1. List all identities using the API (with pagination as needed). 2. Filter the results client-side by checking if the email trait ends with @example.com. There is no direct server-side filter for email domain in the current Ory API or Console.
v
How do I assign an organization id to my users?
@chilly-king-10285 How do I assign an organization_id to my users?
b
A message from kapa.ai
To assign an
organization_id
to your users (identities) in Ory, you need to set the
organization_id
property when creating or updating an identity. This can be done via the Ory APIs. When creating a new identity: Include the
organization_id
field in your request payload and set it to the ID of the organization you want the user to belong to. When updating an existing identity: You can update the identity's data and set or change the
organization_id
field. Example (JSON payload for creating or updating an identity):
Copy code
json {   "schema_id": "<preset://email>",   "traits": {     "email": "<mailto:user@example.com|user@example.com>"   },   "organization_id": "your-organization-uuid" }
This approach is useful for pre-provisioning identities in an organization, ensuring that the user is associated with the correct organization before they log in for the first time [Pre-provisioning identities in an organization](https://www.ory.sh/docs/kratos/organizations#pre-provisioning-identities-in-an-organization). You can use the Ory API endpoints for creating or updating identities to set this field.
v
@chilly-king-10285 and I can use this field without SSO?
b
A message from kapa.ai
Yes, you can use the
organization_id
field for your users (identities) without requiring SSO. The documentation states that after creating an organization, you can pre-provision identities in it by setting the
organization_id
property, either when creating the identity or by updating the identity's data using the Ory APIs. This is described as useful for creating related data in your system before the user logs in for the first time, and there is no requirement that SSO be enabled for this functionality [Pre-provisioning identities in an organization](https://www.ory.sh/docs/kratos/organizations#pre-provisioning-identities-in-an-organization). So, the
organization_id
field can be used independently of SSO features.