Skip to main content
This page is a reference for role assignment, since roles can attach to three different entities, and any of the other use-cases can also involve roles. A role can attach to a user within an organization, a group at the tenant level, or a group within an organization. Each attachment point fires its own event pair, but tenant-wide and organization-scoped grants must never share the same object. Organization-scoped grants use their own organization_role type. Pick the subsection below that matches how you’re assigning the role, then read Static vs. dynamic roles.

What can hold a role

A user, within an organization membership

Triggered by organization.member.role.assigned / organization.member.role.deleted. This is the most common case, and the one B2B via Organizations walks through end to end. organization.member.deleted’s payload only ever carries organization.id and user.user_id, never which roles that user held. A role assignment is therefore wired through an intermediate organization_membership object, so removing a user from an organization can revoke its roles without knowing their IDs. The target is an organization-scoped role object, organization_role:{organization_id}_{role_id}, separate from the tenant-wide role type. Checking the tenant-wide role:{role_id} for an organization-specific permission would pool grants from other organizations. The organization_role type also requires organization membership: assignee is assigned and member from organization, so a user who has been assigned the role but does not belong to the organization is not an assignee. The assign rules write the organization tuple that links the role object to its organization.
Assigning a role writes user --member--> organization_membership:{organization_id}_{user_id}, organization_membership:{organization_id}_{user_id}#member --assigned--> organization_role:{organization_id}_{role_id}, and organization:{organization_id} --organization--> organization_role:{organization_id}_{role_id}. The last tuple only records which organization the role object belongs to. Removing a role from a user leaves that tuple in place, because other members may still hold the role. “Remove user from organization” removes the user’s organization membership tuple, and “Revoke roles held through the membership” cleans up only this organization’s role assignments and the membership’s own member tuples. The filters are computable from organization_id and user_id, which organization.member.deleted carries. Without the first filter, orphaned role assignments would remain. The first filter uses the bare type organization_role: as its object. It does not need to name the organization, because its user side (organization_membership:{organization_id}_{user_id}#member) is unique to this organization and user. Do not use a partial object ID such as organization_role:{organization_id}_; filters match whole values. If the same user holds the role in a second organization, its organization_membership and organization_role objects are separate, so removing one does not affect the other. Each grant applies only while the user is also a member of that organization. Scope the permission check too: a resource in org_acme can use organization_role:org_acme_rol_billing#assignee as a userset, but must not check the tenant-wide role:rol_billing#assignee for that organization-specific grant. Your application must connect the correct scoped role userset to the organization’s resource; writing the assigned tuple alone does not grant access to a resource.

A group, at the tenant level

Triggered by group.role.assigned / group.role.deleted. Covers assigning a role directly to a SCIM group with no organization involved, as in Workforce via SCIM Groups.
role#assignee accepting group#member (alongside user) is what lets a role reach every current and future member of a group with one tuple, instead of one tuple per member. group.role.deleted only carries the role’s id, never its name. If a rule needs to branch on which role fired, branch on role.id.

A group, within an organization

Triggered by organization.group.role.assigned / organization.group.role.deleted, distinct from the bare, tenant-level events above. The payload carries organization.id, group.id, and role.id together. Write these grants to the organization-scoped role object, organization_role:{organization_id}_{role_id}, not the tenant-wide role:{role_id}. The tenant-wide object is shared by every organization, so a grant made in one organization would apply in all of them.
Scoping the role object is not enough on its own, because group#member is tenant-wide: a group member who does not belong to the organization would still hold the assignment. The organization_role type closes this. Its assignee relation is assigned and member from organization, so a group member is an assignee only while they are also a member of the organization. Use organization_role:{organization_id}_{role_id}#assignee wherever your application checks the role, and never #assigned: Your application writes organization_role:{organization_id}_{role_id}#assignee as a billing_manager on the matching organization. A user who holds the role in organization A, directly or through a group, gets billing_manager on A only if they are also a member of A, and gets nothing on organization B.
Deleting a role in Auth0 emits no event, and it does not emit unassignment events for the role’s existing assignments (see Roles have no CRUD events), so no mapping rule can remove the deleted role’s grants, at either scope. Do not delete roles in your Auth0 tenant while you use Relationship Sync. fga mapping sync cannot remove the grants of a deleted role either. If a role was deleted, follow Cleaning up tuples that no rule covers.

Static vs. dynamic roles

Roles fall into two categories, and each needs different modeling. This applies to any of the three attachment points above.
  • Static roles: your application defines these itself, once, as a fixed set of named permissions hardcoded into your model as relations (for example, an “Approver” role your app checks for explicitly). Your mapping can branch on these by identity.
  • Dynamic roles: each customer or organization defines their own roles, with arbitrary names, IDs, and permissions your application can’t know ahead of time. Since they’re managed by the customer rather than fixed in your model, these have to be modeled generically and managed as tuples.
Some applications need only one category; others need both.
Branch on the role’s ID (input.data.object.role.id), not its name. A role’s name can be changed by whoever manages roles in your Auth0 tenant (see Create Roles), but its ID is stable for the role’s lifetime. Matching by name is fragile: a rename silently breaks the branch, with no error to catch it.

Static roles

Since your application already knows about these roles, model each as its own named relation directly on organization, for example: Map it by matching the role’s ID, hardcoded to the specific role you created in your own tenant:
Replace rol_YOUR_APPROVER_ROLE_ID with the real role ID from your tenant. Because this writes a direct relation on organization, no separate cleanup rule is needed: Cleaning up roles on membership removal’s filter-by-user+organization technique already reaches it when the membership is removed.

Dynamic roles

Since these roles’ names, IDs, and count aren’t known ahead of time, model their assignees generically as organization_role:{organization_id}_{role_id}#assignee, one role object per organization, for both users and groups. Link each scoped role only to that organization’s resources. The type requires organization membership for every assignee, including group members (see A group, within an organization).

Combining both

If your application has both kinds, add two separate rule pairs per event, each guarded by whether the role ID matches your known, hardcoded set. The first pair is the static branch shown above. The second pair reuses the same rules as A user, within an organization membership, with input.data.object.role.id != "rol_YOUR_APPROVER_ROLE_ID" (and any other static role IDs) added to their when guards, so the two branches don’t overlap. Rules are independent, and all matching ones fire for a given event, so ordering between the two pairs doesn’t matter as long as their when conditions are mutually exclusive.