Getting user roles into tokens with Zitadel

Zitadel can return project roles to your application in ID tokens and userinfo when the right scopes and project settings are in place. This page explains the options, the setup sequence, and why administrator roles belong behind an API call.

On this page

How user roles reach an application through Zitadel tokens

An application team has to decide whether a signed-in user's roles travel inside the token or get fetched when the application needs them. In Zitadel, the answer starts with the structure. An instance holds organizations, and each organization holds projects. A project groups the applications, the project roles and the grants that assign those roles to users. A project role is a named permission, such as editor or viewer, defined once in the project. A grant then gives a user or a user from another organization a set of those roles. Before you design any role claims, map who owns each project, which organization its users belong to, and which grants will exist.

Put roles in the token when the application uses them to make routine decisions, such as which menus to show or which top-level pages a user may open, and when the role set is small and changes slowly. A token is a snapshot. If an administrator removes a grant, the old role stays valid until the token expires or is refreshed, so keep token lifetimes short and confirm them with your security team. Confirm in your project settings whether role assertion is enabled for ID tokens and userinfo, and which scopes your client requests to receive them. Use a separate permission check at request time for decisions that depend on data the identity provider does not hold, such as whether a user may edit one specific invoice.

How a role claim moves from a grant to your application

The flow starts with an administrator creating a project grant that assigns a role to a user in an organization. When the user signs in, the application requests the roles scope, and Zitadel adds the role claims to the ID token or serves them from userinfo. The application reads the claim from the token it received. An administrator change made later reaches the application only when it is read from the API, so the trust boundary sits between the application and Zitadel, where the claim is checked.

Role claims reach the application through the token at sign-in, while later admin changes need an API call.

Which token and project settings fit which role model

This table compares where role claims can be asserted (ID token, userinfo and access token) and which project settings control whether roles reach the application. Read each row against your own consumers: the question is which party reads the roles, how long a revoked role stays visible, and what the application does with the claim. The main takeaway is that the choice trades convenience and offline validation against how quickly a role change takes effect.

OptionWhen it fitsWhat it exposesWhat changes when a role is revoked
Roles in the ID tokenA single web or mobile client that reads roles once at sign-in to build its menus and screensRoles are visible to the client application and stored in its session; the token is for the client, not for APIsThe client keeps the old roles until the session or ID token is refreshed, so revocation is delayed for that session
Roles in userinfoA client that prefers a small ID token and fetches roles on demand from the userinfo endpointRoles are returned only when the client calls userinfo with a valid access token; the token itself stays smallerA fresh userinfo call reflects current grants, so revocation takes effect at the next call; cached copies in the client still lag
Roles in the access tokenAn API that authorizes requests from roles carried in the token, validated locally or through introspectionRoles travel with every API call, so any service that receives the token can read themLocally validated JWTs keep the old roles until expiry; introspection or shorter token lifetimes shorten the window
Project setting: assert roles on authenticationApplications that need roles in the ID token or userinfo for the signed-in userControls whether role claims are added to the tokens issued to that project's applicationsChanging the setting affects new tokens only; confirm whether existing sessions pick up the change
Project setting: check roles on authorizationProjects where a user without a matching grant should be refused before the application sees the loginBlocks sign-in for users lacking a role in the project, so the application never receives their tokenRevoking the last role can stop new logins, but existing sessions depend on token lifetime and client behavior
Roles across organizationsMulti-tenant products where a project is granted to customer organizations and each organization assigns its own usersRole keys are defined in the owning project; each granting organization sees only the roles it was givenRemoving a project grant or a role from an organization changes what is asserted for that tenant at the next token issue
Administrator rolesPlatform or tenant administrators who manage Zitadel itself, not the applicationAdministrator permissions are managed through the Zitadel API, not asserted as application role claimsChanges apply through the management API and are audited there; do not rely on a token claim to carry administrator rights

How the role model changes in single-organization and multi-organization setups

When one company runs its own workforce inside a single Zitadel organization, projects, users and grants all sit in that one organization. Project roles are defined on the project, and a grant assigns them to users or groups in the same organization. Because every user and role comes from one place, role names are unique in practice and the application can read them from its own organization's tokens without further decisions.

  • Role scope: Roles are declared on the project and granted within the organization that owns it, so the role key is the only identifier the application needs.
  • Duplicate names: A duplicate role name is unlikely here because one team controls the project, but it still needs a naming convention such as billing:admin so future projects do not collide.
  • Trusted organization: The application trusts the single organization configured as its issuer, and it should reject tokens whose organization context does not match.
  • Administrator roles: Keep platform administrator roles out of the application token and manage them through the management API, as covered elsewhere on this page.
  • Change control: Each new role or grant changes what every user receives, so review grants as part of your access process.

Before you rely on this model, confirm in your Zitadel instance which organization your application's issuer and project belong to, and test a user from each group to see the roles that actually arrive.

Setting up role claims in Zitadel step by step

This sequence takes a Zitadel project from creation to a verified ID token that carries the user's project roles, so a relying application can make authorization decisions from the claim. Each step ends with a check you can run before moving on.

  1. Create the project in the organization

    In the Zitadel Console, open the organization that owns the application and create a project. The project is the container for the application, its role keys and the grants that assign roles to users, so it must sit in the organization where your users are managed. Confirm the exact menu path and labels for your Zitadel version, since the Console changes between releases. Done means the project appears in the organization's project list with the name you intend to keep, because renaming later can confuse teams reading the audit trail.

  2. Define the role keys

    Inside the project, add the roles your application will check, such as an admin or a viewer role. Each role has a key, which is the string that appears in the token, and a display name for administrators. Choose keys that are stable and descriptive, because relying applications will match on them and renaming a key later breaks every check. Done means each intended role is listed in the project with its key, and you have written the keys down so the application code uses the same spelling.

  3. Create the application under the project

    Add a web application to the project and choose the OIDC application type and authentication method that match your client, such as code flow with PKCE for a single-page app or a confidential client for a server-side app. Register the redirect URIs exactly as the application will call them. Done means the application shows a client ID and the redirect URIs you entered, and a test sign-in attempt reaches the Zitadel login page without a redirect error.

  4. Enable the project setting that asserts roles

    Open the project settings and turn on the option that asserts roles into tokens, so Zitadel includes the project's roles in the tokens it issues for this project's applications. Without this setting, the role scope in the request has nothing to return. Confirm the label for this option in your version of the Console. Done means the setting is saved and you can see it enabled on the project, which you will confirm again when you decode a token in the final step.

  5. Request the role scope in the client

    Update the client's authorization request so it asks for the role scope that Zitadel documents for project roles, alongside openid, profile and email. Keep the request explicit in configuration rather than relying on defaults in a library. Done means the authorization URL your application generates contains the scope, which you can confirm by inspecting the request in the browser or in your application logs.

  6. Grant roles to users

    Create a grant that links the project to a user (or to a group of users in your process) and selects the roles that user should hold. Grants are the assignments that decide what a token contains, so a user with no grant will sign in successfully but receive no project roles. Done means the user's grant appears on their record in the Console with the expected roles selected. Use a test user for this step so you can see the effect without changing production access.

  7. Sign in and confirm the claim arrives

    Sign in as the test user through the application and capture the ID token it receives. Decode the token payload, or call the userinfo endpoint with the access token, and look for the role claim with the keys you defined and the expected values. Use a token decoder for inspection only, and never paste production tokens into public tools. Done means the role claim appears with the granted roles, and a user without the grant shows no roles. Record the result so the expected output is available when the application team tests later changes.

Why administrator roles need an API call instead of token claims

Role claims in an ID token or access token are a snapshot taken at sign-in. If an administrator loses a role, the claim stays in every token already issued until that token expires or is refreshed, so a token alone cannot prove that the person still holds the permission. For application roles, that lag is usually acceptable because the consequence is limited to the application's own data. For administrative actions on Zitadel itself, such as creating or suspending organizations, changing users, or editing projects and grants, the check should happen at the moment of the action. The application should call the relevant Zitadel API with a service identity, and Zitadel decides whether that action is allowed based on current state.

In practice, the admin console or internal tool passes the signed-in user's identity into the request, and the service account performs the call with its own least-privilege role. Zitadel's management endpoints then answer with the permissions in effect at that moment. Plan the service account's scope separately from the human roles, record which user triggered each call in your own audit log, and decide how the tool behaves when a check cannot be completed. Failing closed is the safer default for administrative writes, while read-only views may tolerate a short cached result. Confirm the exact role and grant model your Zitadel version uses before you write the authorization code, because the names and endpoints differ between releases.

The trade-off is latency and dependency. Every administrative action now waits on a network call to Zitadel, and if Zitadel is unavailable, those actions stop, even though the user's token may still look valid. Measure the round-trip time from the tool's network location to your Zitadel deployment, and decide whether the check runs on every request or only on writes. Keep the call limited to administrative operations so that ordinary application traffic continues to rely on local token validation. The Zitadel APIs introduction describes the interfaces available for these calls, and it is the right starting point for choosing which ones your tool needs.

Security risks when roles are copied into tokens

Roles placed in tokens are a copy of a decision made elsewhere, so the copy can drift from the source. The risks below all come from that gap: stale values, excess exposure, name collisions, oversized tokens, mixed-up administrator rights and leaked token contents. Each one needs a control and a check in your own Zitadel setup before the claims reach production services.

Stale role claims after revocation

A role claim is fixed at the moment the token is issued. If an administrator removes a grant, a user who still holds an unexpired access or ID token keeps the old role until that token expires. Set short access token lifetimes for applications that rely on roles, and make sure every protected API checks roles on each request rather than trusting values cached in a session. In your environment, revoke a test grant, then confirm the old token is refused or the role is gone after a fresh login. Revocation of existing tokens behavior should be confirmed against the Zitadel version you run.

Zitadel API docs

Over-broad roles exposed to every client

Within a project, roles are shared by every application in that project. If a project contains a customer portal and a back-office tool, a role meant for the back office can appear in the portal's tokens and reach its APIs. Limit role claims per application where Zitadel allows it, keep unrelated applications in separate projects, and list which roles each client receives. Check by signing in to each application as a user with the most privileged role and reviewing the decoded tokens for anything the client does not need.

Role names that collide across organizations

Role keys such as admin or editor are only labels inside a project. When customers belong to different organizations and the same project is granted to them, a role name that means one thing to one customer can be read as a different permission by a service that matches on the bare name. Use role keys that include a clear namespace, and have each API check the organization or grant context alongside the role. Test with two organizations holding the same role key and confirm the API denies access the second organization should not have.

Tokens carrying more data than needed

Role claims can be joined with other data such as organization details, metadata or user attributes. Each extra field is readable by any service that receives the token and is copied into logs, caches and downstream calls. Ask each receiving service which claims it actually uses, and remove the rest from the token configuration. Verify by decoding a token issued to each client and checking that every field has a named consumer. Token size should be reviewed when many roles are assigned to one user.

Administrator roles mistaken for application roles

Instance and organization administrator rights in Zitadel are managed through the management APIs and console, not through project role claims. A team that adds an admin role to a project and reads it from the token can accidentally grant platform-level control to an application user. Keep administrator permissions out of application role claims, and have administrative actions authorized by a call to the management API with a service account that has least-privilege access. Confirm by listing which identities can perform admin actions and checking that none of them depend on a role claim.

Organizations docs

Logs that record token contents

Gateways, reverse proxies and application frameworks often log request headers or the full decoded token when debugging. Role claims, user identifiers and organization data then persist in log stores with their own retention and access rules, which may be wider than the identity system's. Turn off payload logging for authorization headers, set a retention period for logs that might contain claims, and restrict who can read them. Verify by triggering an error in a test client and searching the log store for the bearer token value and role names.

Questions teams ask before building role claims

How much effort do role claims take compared with building a custom permission service?

Role claims are usually less work than a custom permission service because Zitadel already stores projects, roles and grants and can place them in tokens, so your team mainly maps those values to application permissions. A custom service also needs its own data model, admin screens, an audit trail and a sync path to every application, and those costs recur as the product grows. The effort in a claims approach concentrates in deciding the role model, configuring project settings and scopes, and testing every token shape your applications accept. Ask a partner to separate those items in a written scope so you can see which parts are one-time design and which parts are ongoing maintenance.

Can our team configure role claims without outside help?

A team with working OIDC experience and admin access to a Zitadel instance can usually configure project roles, grants and the token options on its own, provided it has a clear role model written down first. The harder parts are usually decisions rather than clicks: which roles exist, who may assign them, which roles belong in ID tokens versus userinfo, and how roles behave across organizations. Outside help tends to pay off when those decisions touch several applications, when you need a repeatable setup across environments, or when the result must be reviewed by security or compliance staff. Check the current configuration options against the Zitadel documentation for your version before you commit to a design.

What does the work need from our identity and application owners?

The work depends on three groups making decisions early. Identity owners decide the organization and project structure, which users belong to which organization, and who may grant roles. Application owners decide which roles each application needs, which claim names their code reads, and whether they validate tokens locally or through introspection. Security or compliance reviewers should approve who can administer roles and how role changes are logged. Without those decisions, the first setup tends to be rebuilt once a second application or customer organization arrives. Ask for a written list of these decisions and owners as part of the scope.

How long does a first working role setup take in our environment?

The duration depends on the number of applications, the complexity of the role model, whether a Zitadel instance already exists, and how much testing your environment requires. A single application with a small role set on an existing instance is a much smaller task than several applications across multiple customer organizations on a new self-hosted deployment. Your own environment also sets the pace: access to a test instance, approval cycles and the availability of application owners for testing often matter more than the configuration itself. Ask any partner for a timeline tied to named milestones and to the applications in scope, and ask what it assumes about your environment.

How do role changes reach users who are already signed in?

Role changes do not rewrite tokens that have already been issued. A signed-in user keeps the claims in their current ID token or access token until that token expires or the application requests a new one through a refresh or re-login. Applications that read roles only at sign-in can therefore show stale permissions for the length of a session. Plan for this by setting token lifetimes deliberately, by having sensitive operations check roles through an API call or introspection, and by deciding how your applications force re-authentication after a role removal. Confirm the exact lifetime and refresh behavior in the Zitadel documentation for your version.

Why should administrator roles come from an API call instead of the token?

Administrator permissions should be checked against the current state of Zitadel through an API call because a token is a snapshot of what was true at issuance. An admin role removed five minutes ago could still appear in a valid token, and a token copied from a logged-in browser could be replayed until it expires. Using a live call for administrative actions narrows that window and keeps the authority decision in one place. Ordinary application roles can still travel in tokens for routine checks. Ask your partner to document which actions require a live check, how the call authenticates, and how failures are logged.

What should we ask a partner to include in a written scope?

Ask for a scope that lists the Zitadel version and deployment you will use, the applications and API clients that consume roles, the role model with each role's purpose, and the organizations and projects involved. It should state which token types and claim names each application receives, which userinfo and ID token settings apply, and how administrator checks are implemented. Request the test cases, including a role removal and a cross-organization user, the handover documentation, and what support follows go-live. Ask for the fixed price and assumptions in writing, and ask which items are one-time work and which are recurring.

Limits to confirm in your Zitadel version and environment

Role claims look simple in a demo, but their behavior depends on the Zitadel release you run, the libraries that read the tokens and the identity providers that feed users in. Confirm each item below on a test instance that matches your production setup before you write application code against role claims.

Scope and claim behavior in your version

Confirm which scopes and project settings cause role claims to appear in ID tokens and in userinfo responses, and the exact claim name and structure returned. Behavior has changed between releases, so do not copy examples from older articles. Read the documentation for your release and check the claims in a decoded token from your own test application. Record the exact scope string and project setting your code depends on, because a missing scope often produces a token that looks valid but has no roles in it.

Zitadel APIs docs

Support window for your release

Confirm how long the release you plan to run receives fixes and which upgrade path leads to the next supported version. Claim formats and project behavior can change across major versions, so a release that is supported today may need a planned upgrade before your application goes live. Check the Zitadel release notes and your own support agreement, and factor the upgrade test into your schedule. Ask whether your support terms cover a vendor patch, a community patch or neither.

Zitadel releases

Token library claim parsing

Confirm that the token validation library in each application reads the role claim format Zitadel returns. Some libraries map nested claims into flat lists, drop unknown claim types or expect a specific key name. Run a test login for every application stack you operate, including mobile and backend services, and check that the parsed role values match the decoded token. Pin the library version in your test plan, since a library upgrade can change how claims are mapped.

Maximum token size with many roles

Test how token size grows when a user holds many roles across projects and organizations. Large ID tokens can exceed header limits in proxies, load balancers and browsers, which fail with errors that look unrelated to authentication. Measure the largest realistic role set for your most privileged users, then test that the token passes through every hop in your ingress path. If the size is a problem, decide whether to reduce the claims in the token or fetch roles from the API for the few screens that need them.

Role changes and token lifetimes

Confirm how long a role change takes to reach users who already hold a valid token. A token issued before a role was removed keeps its old claims until it expires or is refreshed, so the gap equals your token lifetime plus any refresh behavior in the client. Set the access and ID token lifetimes deliberately, then test a revocation scenario end to end. For actions that must take effect immediately, plan a server-side check against the current grant rather than trusting the claim alone.

Roles passed by federated providers

Confirm whether any federated identity provider sends role or group attributes that Zitadel maps into project roles, and how that mapping is configured for each customer organization. Providers such as Entra ID or Okta can send group membership in different claim names and formats, and some configurations send no roles at all. Test one user from each federated provider and confirm that the expected roles appear in the token, and that a user without provider roles receives none rather than a default.

Identity provider docs

How DeployOpen scopes and delivers role-based access in Zitadel

DeployOpen plans, implements and documents project roles in Zitadel as a fixed-scope engagement inside your own infrastructure. The work covers how roles are granted, which scopes and project settings place them in ID tokens and userinfo, how roles behave across organizations, and how administrator access is kept on a separate API path.

How we scope

  • Written scope lists the projects, applications and role names that must appear in tokens for each client.
  • Scope records which organizations and users receive grants, and which must stay outside the role claims.
  • Scope states which administrator actions use the management API and who approves those permissions.

How we build

  • We configure project role keys, role grants and the project setting that adds role claims to tokens.
  • We set the requested scopes in each client so ID tokens and userinfo carry the agreed role claims.
  • We test role claims with real sign-in flows across each organization in the agreed scope before handover.

How we hand over

  • You receive a written record of role keys, grants, scope requests and the claim names your applications read.
  • Runbooks explain how to add a role, grant it to an organization and confirm it reaches the token.
  • Administrator access is documented separately, with the API calls and service accounts used to manage it.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, Zitadel upgrades and continuous testing of role claims are available as a retainer.
  • Ask any partner to confirm how role claims are re-tested after a Zitadel version upgrade in your environment.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.