enough-vase-33352
07/22/2025, 7:56 AMbrief-egg-61061
07/22/2025, 7:56 AMbrief-egg-61061
07/22/2025, 7:56 AMbash curl --location --request PATCH "https://$<http://ORY_SLUG.projects.oryapis.com/admin/identities/$IDENTITY_ID|ORY_SLUG.projects.oryapis.com/admin/identities/$IDENTITY_ID>" \ --header "Authorization: Bearer $ORY_API_KEY" \ --header "Content-Type: application/json" \ --data-raw '[ { "op": "replace", "path": "/schema_id", "value": "{new-schema-id}" }, { "op": "remove", "path": "/traits/foo" }, { "op": "add", "path": "/traits/bar", "value": "barfoo" } ]'
- Replace {new-schema-id}
with your new schema ID. - Adjust the traits operations as needed to match your new schema requirements. ### 2. Validate the Update The response should return the updated identity. Make sure the traits now conform to the new schema. ### 3. Repeat for Other Identities If you have multiple identities to update, repeat the process for each one. ### Notes - Using patchIdentity is the recommended way to update identities after a schema change. - Make sure to update the traits so they are valid according to the new schema, otherwise the request will fail validation. - You can also use the Ory SDKs to perform these operations programmatically if you prefer. For more details and example code (including Go SDK usage), see the official documentation: [Update identities to use a new schema](https://www.ory.sh/docs/identities/model/manage-identity-schema#update-identities-to-use-a-new-schema)enough-vase-33352
07/22/2025, 7:57 AMbrief-egg-61061
07/22/2025, 7:57 AMbrief-egg-61061
07/22/2025, 7:57 AMenough-vase-33352
07/22/2025, 7:58 AMbrief-egg-61061
07/22/2025, 7:58 AMbrief-egg-61061
07/22/2025, 7:58 AMpatchIdentity
or updateIdentity
). This is a manual or programmatic process that you need to trigger outside of the login flow [Update identities to use a new schema](https://www.ory.sh/docs/identities/model/manage-identity-schema#update-identities-to-use-a-new-schema). - Settings Flow for User-Editable Traits: If the new schema adds traits that are user-editable (e.g., new profile fields), users can update these themselves via the self-service settings flow. However, this requires the user to actively visit the settings/profile page and submit the new data. The login flow does not prompt for or update these fields automatically [Settings and profile updates](https://www.ory.sh/docs/kratos/self-service/flows/user-settings). - Validation on Write: If a user attempts to update their profile (traits) and the data does not conform to the new schema, the update will fail validation until the required fields are provided [Identity schema best practices](https://www.ory.sh/docs/kratos/manage-identities/best-practices). Summary: After deploying a new schema, you must use the Admin API to update existing users' traits, or rely on users to update their own traits via the settings flow. The login process does not automatically update or prompt for new trait properties introduced by a schema change.enough-vase-33352
07/22/2025, 8:22 AMbrief-egg-61061
07/22/2025, 8:22 AMbrief-egg-61061
07/22/2025, 8:22 AMdepartment
, update your Jsonnet like this: jsonnet local claims = std.extVar('claims'); { identity: { traits: { email: claims.email, [if "department" in claims then "department" else null]: claims.department, // Add other new traits as needed }, }, }
This approach ensures that the new trait is only set if it exists in the incoming claims, making the mapping robust to missing data [Data mapping with Jsonnet](https://www.ory.sh/docs/kratos/reference/jsonnet). 3. Deploy the Updated Mapping: - If you are using Ory Network, encode your updated Jsonnet file in Base64 or host it at a URL, and update your provider configuration to reference the new mapping [Data mapping](https://www.ory.sh/docs/kratos/social-signin/ory#data-mapping). - For Ory Kratos, update the configuration to use the new Jsonnet mapping. 4. Test the Mapping: After deploying, test the flow (e.g., OIDC login or SCIM sync) to ensure the new trait is correctly mapped and stored in the identity. Tip: If you want to make the new trait optional, use the conditional key syntax as shown above. If the trait is required, ensure your schema and mapping always provide a value. For more details and examples, see the official documentation on [Data mapping with Jsonnet](https://www.ory.sh/docs/kratos/reference/jsonnet) and [Social sign-in data mapping](https://www.ory.sh/docs/kratos/social-signin/ory#data-mapping).