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 byorganization.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.
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 bygroup.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 byorganization.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.
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.
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.
Static roles
Since your application already knows about these roles, model each as its own named relation directly onorganization, for example:
Map it by matching the role’s ID, hardcoded to the specific role you created in your own tenant:
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 asorganization_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, withinput.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.