square-napkin-92357
07/03/2025, 9:42 AMProperty username is missing.
i am using this api to update
curl --request POST \
--url '<https://oathkeeper.md-dev.vnsilicon.cloud/proxy/kratos/self-service/settings?flow=89f04514-c254-45dd-91d3-d6560e8d90b7>' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'cookie: {{oryKratosSession}};{{settingFlowCookie}}' \
--cookie '{{oryKratosSession}};{{settingFlowCookie}}' \
--data '// {
// "csrf_token": "{{settingFlowCsrf}}",
// "method": "profile",
// "traits": {
// "email": "<mailto:new-email@example.com|new-email@example.com>",
// "username": "VNSuser001"
// }
// }
{
"csrf_token": "{{settingFlowCsrf}}",
"method": "profile",
"traits": {
"email": "<mailto:new-email@example.com|new-email@example.com>"
}
}'
why did it need username to update? i do not want to update username, i just want to update emailbrief-egg-61061
07/03/2025, 9:42 AMbrief-egg-61061
07/03/2025, 9:42 AMProperty username is missing.
occurs because your identity schema likely requires the username
field to be present in the traits, not just when creating but also when updating the profile. In Ory Kratos, the identity schema defines which fields are required for an identity. If username
is marked as required in your schema, then every update to the profile (even if you only want to change the email) must include the username
field in the payload, otherwise Kratos will reject the request with this error. For example, a schema like this: json { "properties": { "traits": { "type": "object", "properties": { "email": { "type": "string", "format": "email" }, "username": { "type": "string" } }, "required": ["email", "username"], "additionalProperties": false } } }
means both email
and username
are required. When you update, you must send both fields, even if you only want to change one of them. This is standard JSON Schema behavior and is enforced by Kratos during profile updates [Customize identity schemas: Examples](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#username-and-email-and-password). Solution: When updating the profile, always include all required fields from your identity schema in the traits
object. For your case, the payload should look like: json { "csrf_token": "{{settingFlowCsrf}}", "method": "profile", "traits": { "email": "<mailto:new-email@example.com|new-email@example.com>", "username": "VNSuser001" } }
If you do not want username
to be required, you need to update your identity schema and remove username
from the required
array. Otherwise, you must always provide it in update requests [Customize identity schemas: Multiple identifiers](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#multiple-identifiers). Summary: Kratos enforces the identity schema on every update. All required fields must be present in the update payload, even if you are not changing them [Settings and profile updates](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#settings-form-validation).square-napkin-92357
07/03/2025, 9:44 AMbrief-egg-61061
07/03/2025, 9:44 AMbrief-egg-61061
07/03/2025, 9:44 AM