A role is a permission set: which objects an app can read or write, which fields it can see, and which platform-level capabilities it can use. Every app’s logic functions and front components inherit the permissions of the role marked withDocumentation Index
Fetch the complete documentation index at: https://docs.twenty.com/llms.txt
Use this file to discover all available pages before exploring further.
defineApplicationRole() (see The default function role below).
src/roles/restricted-company-role.ts
The default function role
When you scaffold a new app, the CLI creates a default role file declared withdefineApplicationRole():
src/roles/default-role.ts
defineApplicationRole() is a thin wrapper around defineRole() that flags the role used as your application’s default at install time. Validation is identical to defineRole, but the build pipeline auto-wires its universalIdentifier into the application manifest’s defaultRoleUniversalIdentifier — so you do not need to reference it from defineApplication yourself.
Notes:
- Exactly one
defineApplicationRole(...)is allowed per app — the manifest build will fail if it finds more than one. - Use
defineRole()(notdefineApplicationRole()) for any additional roles your app ships. - Setting
defaultRoleUniversalIdentifierexplicitly ondefineApplication()is still supported for backward compatibility, but is deprecated in favor ofdefineApplicationRole().
Best practices
- Start from the scaffolded role, then progressively restrict it — the default grants broad read access, which is rarely what you want in production.
- Replace
objectPermissionsandfieldPermissionswith the exact objects and fields your functions actually need. permissionFlagscontrol access to platform-level capabilities. Keep them minimal.- See a working example:
hello-world/src/roles/function-role.ts.