Hi Varshan,
If your requirement is to create or update the App Security navigation (menu) or User Role definitions through an API at runtime, that isn't supported.
Navigation menus and App Security → User Roles are design-time configurations stored in the Mendix model, so they can't be created or modified through a runtime API.
If your goal is to show different menus dynamically, a common approach is to create your own dynamic navigation entity (for example, Menu, MenuItem, and UserRole associations), populate it through an API, and render it using a List View or Gallery with role-based visibility. This gives you API-driven navigation without modifying the actual App Security configuration.
If your requirement is specifically to assign existing roles to users instead, that's a different approach and can be done using System.UserRole.
Kindly mark this as the accepted answer if it helps.
Hi Varshan
Can you please clarify your question.
As far I can understand,
In mendix user roles are defined in design time
The are Defined in Studio Pro ->App Security then the User Roles compiled into the runtime .mdr file
They are not database records.
The entity System.UserRole store the user roles, so you can assign/unassing user roles to existing user.
But can not create new user role at runtime.
My question is do you want to assign existing roles to users, or literally create new role definitions?