<@U04UQ68083H> How can I create and use multiple i...
# ory-copilot
h
@chilly-king-10285 How can I create and use multiple identity schemas on ory network?
c
A message from kapa.ai
Creating and using multiple identity schemas in Ory Network involves several steps. Here's a step-by-step guide: 1. Create Identity Schemas: To create a custom identity schema, sign in to the Ory Console and select Identity Schema. Choose a preset schema or an empty template as your starting point. Enable the "Customize Identity Schema" option to edit the schema. Adjust the schema to your needs by adding, removing, or adjusting traits. Define the name of the custom schema in the "Identity Model Schema" text box and click "Update" to save[^1^]. 2. Encode and Update Your Schema: After creating your schema, encode it to Base64 and export it to a variable. Then, update your project's configuration[^1^].
Copy code
bash # Encode your schema to Base64 and export it to a variable.   schema=$(cat {path-to-json-with-identity-schema} | base64)      # Update your project's configuration.   ory patch identity-config {your-project-id} \    --replace '/identity/default_schema_id="{unique-schema-id}"' \    --replace '/identity/schemas=[{"id":"{unique-schema-id}","url":"base64://'$schema'"}]'
3. Version the Identity Schema: It can be useful to version the Identity Schema. This is especially helpful if you use custom Identity Schemas as it helps to keep track of changes. You can copy the Identity Schema directly from the Ory Network console or get it from the config file you pulled earlier[^2^]. 4. Use Multiple Identifiers: You can have multiple identifiers in your identity schema. For example, you could have a username and an email address that the user can use to sign in[^5^]. 5. Update Identity Schemas: To update an identity schema, you must create a new revision of that schema. You can't update existing identity schemas by editing them[^4^]. 6. Update Identities to Use a New Schema: Updating the identity schema of a project can result in inconsistencies between the new schema and the identities created with the old schema. You can patch identities after updating the identity schema[^6^]. Remember, depending on your setup, you can benefit from defining different identity schemas for different groups of users, such as customer support and end users[^1^]. [^1^]: [Manage Identities - Identity Schema](https://www.ory.sh/docs/kratos/manage-identities/identity-schema) [^2^]: [Manage Ory Network Configuration in Git - Identity Schema](https://www.ory.sh/docs/guides/gitops#identity-schema) [^4^]: [Update Identity Schemas](https://www.ory.sh/docs/identities/model/manage-identity-schema#update-identity-schemas) [^5^]: [Multiple Identifiers](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#multiple-identifiers) [^6^]: [Update Identities to Use a New Schema](https://www.ory.sh/docs/identities/model/manage-identity-schema#update-identities-to-use-a-new-schema)
h
How do I define different identity schemas for different groups of users
@chilly-king-10285 How do I define different identity schemas for different groups of users
c
A message from kapa.ai
Defining different identity schemas for different groups of users in Ory involves creating multiple identity schemas and assigning them to the respective user groups. Here's a step-by-step guide: 1. Create Identity Schemas: To create a custom identity schema, sign in to the Ory Console and select Identity Schema. Choose a preset schema or an empty template as your starting point. Enable the "Customize Identity Schema" option to edit the schema. Adjust the schema to your needs by adding, removing, or adjusting traits. Define the name of the custom schema in the "Identity Model Schema" text box and click "Update" to save[^1^]. 2. Encode and Update Your Schema: After creating your schema, encode it to Base64 and export it to a variable. Then, update your project's configuration[^1^].
Copy code
bash # Encode your schema to Base64 and export it to a variable.   schema=$(cat {{path-to-json-with-identity-schema}} | base64)      # Update your project's configuration.   ory patch identity-config {{your-project-id}} \    --replace '/identity/default_schema_id="{{unique-schema-id}}"' \    --replace '/identity/schemas=[{{"id":"{{unique-schema-id}}","url":"base64://'$schema'"}}]'
3. Repeat the Process for Each User Group: Repeat the process for each user group, creating a unique identity schema tailored to the specific needs and requirements of each group[^1^]. 4. Assign the Identity Schemas: Assign the created identity schemas to the respective user groups. This process will depend on your specific setup and user management system. Remember, the identity schema not only defines the data model of your identities, but also controls business logic and allows you to define which field is used as the identifier when logging in and which fields are used to verify or recover the user's identity[^1^]. [^1^]: [Manage Identities - Identity Schema](https://www.ory.sh/docs/kratos/manage-identities/identity-schema)