Groups, org units & membership
Section titled “Groups, org units & membership”This page is for integrators and engineers who read or write group membership and the org chart programmatically, or who need to know exactly how OSOS resolves a group or a manager to a person. The administrator’s view of the same model is in Managing groups and Organization units. The permission side of groups is in Permissions API.
Groups
Section titled “Groups”What a group is
Section titled “What a group is”GROUP is not a physical collection of its own. It is a virtual view that unions several concrete identity source entities. When you pick a “group” in the interface, you pick a row that came from one of these entities. A group’s members are therefore defined directly (a Users Group populated by hand or by directory sync) or derived (an org unit’s staff, a role’s holders, or the result of a saved user query). Each kind is managed in the screen for its source entity.
Because GROUP is virtual, it is a core identity entity that exists in every environment, and groups are excluded from package export/import as first-class resources (see Groups and packaging).
Group types
Section titled “Group types”Type (group_type.en) | Description | Source entity | Entity ID |
|---|---|---|---|
| Users Group | A regular group, created and managed manually by adding members. | Users Group | USERS_GROUP |
| Role Group | Created automatically behind every role; membership derived from the role’s assignments. | Role | ROLE |
| Org Unit Group | Created automatically behind every org unit; membership derived from the org chart. | Org Unit | ORGUNIT |
| Query Group | A dynamic group: every user who satisfies the query joins, and any user who no longer does leaves, with no manual assignment. | User Query Group | USER_QUERY_GROUP |
| Virtual Group | A computed group managed by the system for internal purposes; never created or edited manually. | — | — |
Seeded field labels: USERS_GROUP has Group Name (name), Group Description (description), Group Icon (icon); USER_QUERY_GROUP has Group Name, Description, Icon and query (a data-query selector over users).
How membership is stored
Section titled “How membership is stored”Membership is recorded as assignment rows, not as an array embedded on the group:
| Entity name | Entity ID | Purpose |
|---|---|---|
group_assignments | GROUP_ASSIGNMENTS | Virtual: links a group (any type) to a user. |
user_group_assignments | USER_GROUP_ASSIGNMENTS | Links a Users Group specifically to a user (value.users_group, value.user). |
user_query_group_assignment | USER_QUERY_GROUP_ASSIGNMENT | Materialized query-group membership, written by background handlers. Since 1.8 |
A group_assignments row carries value.group.dataEntry (the group id), value.user.dataEntry (the member) and value._metaOrder.value (an ordering key used to sort members deterministically). Each row also has a top-level state and an isInvalid flag. Only rows with state = Active and isInvalid != true count as live membership.
Uniqueness. user_group_assignments, user_query_group_assignment and space_users each carry a compound unique index over the active (user, group) (or (user, space)) pair, so a second active assignment for the same pair is rejected. Since 1.8 — migration 1.8.0-a16 removed existing duplicates and 1.8.0-a17 re-asserted the indexes, which had been silently dropped in environments where the entity was edited.
The admin screens expose this as a Users tab on a Users Group record and a Groups tab on a user record (the seeded relations onto USER_GROUP_ASSIGNMENTS).
Directory synchronization
Section titled “Directory synchronization”For directory-backed groups, membership is populated by the directory importers: each OSOS Users Group marked external is matched to a directory group by value.externalGroupId, and each directory member to a OSOS user by account_information.externalUserId; a user_group_assignments row is created for every match. Groups that do not exist in OSOS, and members that do not map to a user, are skipped and logged. Full detail, including the fields a Users Group needs for this, is in Directory sync operations.
Listing the members of a group
Section titled “Listing the members of a group”The data service exposes one read endpoint for group membership. It resolves a group of any type to its distinct, active member users:
GET /v1/group/{groupId}/users?includeResolved={true|false}- Authentication: required (OSOS auth strategy).
- Authorization: guarded by the standard entity voter.
- Path parameter
groupId: the group’s id. - Query parameter
includeResolved(boolean): whentrue, each returned user reference is enriched with a_resolvedblock containing the user’s indexed display metadata; whenfalseor omitted, only the bare reference is returned.
The controller always filters the underlying users to state = 1 (Active), so inactive (archived or draft) user accounts are never returned. A user’s is_deactivated flag is a value field, not a state, so deactivated users are still returned as members.
Response shape
Section titled “Response shape”Each element is a user reference:
| Field | Type | Present when | Meaning |
|---|---|---|---|
dataEntity | string | always | The entity id of the reference (a user). |
dataEntry | string | always | The member user’s id. |
_resolved | object | includeResolved=true | Resolved display metadata from the entry index. |
Membership resolution rules
Section titled “Membership resolution rules”getUsersInsideGroup builds a MongoDB aggregation over group_assignments that enforces, in order:
- Match rows where
value.group.dataEntryis in the requested group id(s),state = ActiveandisInvalid != true. Several group ids may be passed at once; they are treated as a union. - Optional user pre-filter: if a users filter is supplied (the HTTP endpoint supplies
state = 1), the service first resolves the matching user ids from theUSERentity and restricts assignments to those users. This is how inactive users are excluded. - De-duplicate by
value.user.dataEntry, keeping the first row: a user who belongs to a group through more than one assignment appears once. - Sort by
value._metaOrder.valueascending, so member order is stable. - Optional resolve: when
includeResolvedis requested, member metadata is fetched from the data-entity index in a single batch and attached as_resolved.
There is also an internal activeOnly mode (not exposed on the HTTP endpoint): together with includeResolved, members whose index entry is not Active are dropped entirely rather than returned without resolved metadata. If no assignments match, the service returns an empty list.
The same resolution is used wherever a group is an audience or recipient (notifications, email/SMS triggers, comments), so membership configured once affects owner assignment, notification delivery and comment targeting consistently.
Groups as workflow-step owners
Section titled “Groups as workflow-step owners”Reference fields that accept an owner declare their accepted types as USER,GROUP, for example the workflow step’s Original Owner field. This is what lets a builder assign a group as a step owner.
When a step whose owner is a group is executed, the engine expands the group to a concrete user in OwnerTypeProcessor, depending on the step’s owner options:
| Owner option | Effect when the owner is a group |
|---|---|
| Default (single owner) | Resolves the group and assigns its first member (groupUsers[0]) as the owner. |
selectionCriteria = Manager | Resolves the org-unit manager of the group via getOrgUnitManager; if none is found, the owner is cleared. |
selectionCriteria = Manual | The auto-resolved owner is cleared so a person picks the owner manually. |
isParallel = true | The single owner is cleared; the step is handled as a parallel, multi-owner assignment. |
| Array of group owners (dynamic multiple) | Expands every group to its members via the dynamic-multiple-owner handler; if all resolved entries are users, the first is picked as the active owner (unless Manual or parallel). |
getOrgUnitManager first looks for an active assignment on the org unit itself where value.isManager = true and the referenced user is active. If none exists, it walks up the org-unit parent chain (nearest ancestor first) and returns the first manager it finds.
Because default owner assignment takes the first member, the _metaOrder ordering of a group’s members is not cosmetic: it decides who owns a group-owned step.
Groups and packaging
Section titled “Groups and packaging”GROUP, and the identity entities behind it (USER, ORGUNIT, WORKING_HOURS), exist independently in every environment, so they are core entities that are never exported as part of a package. When an imported package references a group that does not yet exist in the target environment, auto-create does not create a GROUP row directly. It creates an entry in the concrete source entity implied by the group’s group_type (Users Group, Role, Org Unit or Query Group), falling back to USERS_GROUP when the type is unknown.
When you move a workflow or view that assigns a group between environments, the group definition and its membership do not travel with the package. The equivalent group must exist in the target environment, or the reference must be re-pointed after import. See Packaging.
Operational notes
Section titled “Operational notes”- Active-only everywhere. Both member users and their assignment rows must be Active to count. Draft (
0) and Archived (2) states are excluded. - Duplicates are collapsed at read time, and since 1.8 prevented at write time by the unique indexes above.
Org units
Section titled “Org units”Concept overview
Section titled “Concept overview”An org unit is an ordinary data entry of the built-in ORGUNIT entity (normalized name org_unit). Org units reference each other through a self-referencing parent field, which turns the collection into a tree. Users are attached to org units through Assignment entries (ASSIGNMENT entity), each of which links a user, a role and an org unit and carries an assignment level (Main / Additional), an assignment type (Original / Delegation) and an is manager flag.
Two “organization” concepts.
ORGUNITforms the hierarchy. The singleton Organization entity (ORGANIZATION,OrganizationDataEntry/OrganizationDataEntryValue) only holds tenant branding and identity:name(localized, required),description,logo,contact_information(phone/email block),organization_header,organization_footer,addressandmotto. Initial setup seeds one “Default Organization” entry. A separate OrgConfig document in the users-service holds sign-in page branding (name, logo, favicon, custom CSS, optional sign-up URL). None of these carry a parent/hierarchy relationship.
The hierarchy powers three capabilities:
| Capability | Driven by | Entry point |
|---|---|---|
| Scoping (“my org unit users”) | the user’s Main assignment org unit + its parent + all descendants | GET /v1/users/my-orgunit |
| Direct-manager resolution | walking the parent chain upward for the nearest manager assignment | GET /v1/users/direct-manager |
| Workflow step owner (relative) | the same upward walk, driven by a step’s relative options | workflow engine (owner resolution) |
The Org Unit entity
Section titled “The Org Unit entity”ORGUNIT is seeded as an implicit (system) entity during initial setup. It is tree-structured: its definition carries treeStructure.supported = true with the tree field set to parent.
Fields (orgunit.json, mirrored by the OrgUnitDataEntryValue model):
| Field (normalizedName) | Label | Type | Notes |
|---|---|---|---|
name | Name | Localized text | Required, unique, shown as the entry title |
description | Description | Localized text | Optional |
icon | Icon | Icon | Optional, used as the entry picture |
parent | Parent | Relation → ORGUNIT | The hierarchy link. sourceOptions.denyCircularRelation: true, so a unit cannot become its own ancestor |
org_unit_level | Org unit level | Relation → ORGANIZATION_UNIT_LEVELS collection | The unit’s level |
isMainAssignment | Level Assignment is main | Boolean | Default false. When true, the unit accepts only Main assignments (OrgUnitAcceptJustMainLevelException) |
manager | Manager | Relation → USER | Optional. Denormalized, auto-synced from assignments |
The entity is restricted (restrictedEntityIds includes ORG_UNIT_ENTITY_ID): readable by system viewers and restricted-with-grants users, editable by admins only. implicitOptions.allowEdit = true, so builders can add fields.
Org unit levels
Section titled “Org unit levels”org_unit_level points at the ORGANIZATION_UNIT_LEVELS string ADT collection (label Org Unit levels). Out of the box it holds a single level:
| Level id | Label (en) | level | index |
|---|---|---|---|
5cf7d2cc-…-461e636f | First level | 0 | 0 |
Levels are descriptive labels; the actual hierarchy is defined by parent, not by the level value.
The seeded root
Section titled “The seeded root”Initial setup creates one root org unit, “Executive Management” (org-root.json), with parent: "", the seeded first level, and a home icon.
Assignments
Section titled “Assignments”Each Assignment (ASSIGNMENT entity, assignment.json) ties one user to one org unit with a role:
| Field | Label | Type | Meaning |
|---|---|---|---|
role | Role | Relation → ROLE | The role held |
assign_level | Assign Level | Single-select | MAIN or ADDITIONAL (AssignmentLevelTypes) |
assign_type | Assign type | Single-select | ORIGINAL or DELEGATION (AssignTypes) |
user | User | Relation → USER | The assigned user |
org_unit | Org Unit | Relation → ORGUNIT | The org unit |
isManager | Is Manager | Boolean | Whether this user manages the org unit |
The assignment validator enforces, on save:
- the unit’s
isMainAssignment(only Main allowed there); - a role with Unique assignment type can be assigned once per org unit; a role linked with one org unit can exist in only one org unit;
- a Main assignment needs a role of type job position (“role must be of type job position if the the assignment level is main”), and a user can have only one non-archived Main assignment (“each person can have only main assignment”);
- the user must be an organization account (“User must be an organization account”);
- a role not linked with org units has its
org_unitcleared.
Roles relate to the structure via RoleLinkWIthOrgUnitTypes: Not linked with org unit, Linked with one org unit, Linked with many org units.
A user’s org unit is their Main assignment. getUserOrgUnitId() returns the org_unit of the single active assignment where assign_level.id === MAIN. When an assignment is created, a handler copies a Main assignment’s role and org unit onto the user’s main_assignment_role and org_unit fields, and an Additional assignment’s role onto additional_assignment_role. direct_manager on the user is a calculated field derived by walking the parent chain.
The auto-synced manager field
Section titled “The auto-synced manager field”The org unit’s manager field is a denormalized mirror kept up to date by event handlers. When an assignment is created, updated or archived, a handler (update-orgunit-manager-on-assignment-entry-*) checks whether it is a Main assignment with isManager true and, if so, patches the org unit’s manager to that user. (Long-standing.)
Manager resolution for workflows and notifications does not read this convenience field; it queries assignments while walking the parent chain (next section).
Seeding the manager field Since 1.8
Section titled “Seeding the manager field Since 1.8”manager is guaranteed to be present on ORGUNIT in every environment since 1.8: a fresh environment seeds it with the entity definition, and a migration adds it to environments provisioned earlier. On an environment provisioned before that migration the field was absent, even though the assignment handlers had always written to it.
The cause: the initial-setup migration reads every JSON file in the entity/ folder and skips any entity id already inserted. Two files used to define ORGUNIT: org-unit.json (without manager) and orgunit.json (with manager and the full treeStructure). The directory listing yielded the dash-named file first, so the incomplete definition took the id and orgunit.json was skipped. Two changes put this right:
- The stale
org-unit.jsonduplicate was removed from the migration sources, so a fresh environment seedsORGUNITfromorgunit.json, now the entity’s sole seed. - Migration
1.8.0-a31-add-manager-field-to-org-unit-entitybackfillsmanagerontoORGUNITon existing environments. It is idempotent (it appends the field only wheremanageris missing), and itsdown()is deliberately a no-op, because removing the field could destroy data already captured on org-unit entries.
Manager resolution (walking up the tree)
Section titled “Manager resolution (walking up the tree)”getUserDirectManager(userId, relationGrade = 1) resolves a user’s manager by climbing the hierarchy:
- Find the user’s Main assignment and its
org_unit. $graphLookupup theparentchain from that unit, ordered by depth (nearest first, including the user’s own unit at depth 0).- Walk that list looking for an assignment on each unit with
isManager: trueand a different user than the subject. - Return the N-th manager found, where N =
relationGrade(“how many manager levels up”, starting at 1 for the immediate manager). - If no manager is found at the requested grade, return the org unit only (no
directManger).
This is exposed to the portal as GET /v1/users/direct-manager. A user’s direct manager also drives the manager-permissions model, the manager-scoped grants that let a manager act on records of the users they manage (see Permissions API: manager permissions).
Relative step owners in workflows
Section titled “Relative step owners in workflows”Workflow steps can define relative owner options (StepOwnerRelativeOptions): enabled, relationType and relationGrade (“the number of levels to go up in the hierarchy starting from 1”). During owner resolution, when a step’s source.relativeOptions.enabled is true (and it is not the final step), the engine replaces the resolved owner with getUserDirectManager(owner, relationGrade). If no manager is found at that grade, the step is left with no owner (logged as a warning) rather than falling back silently.
Two workflow recipient source tokens are tied to the hierarchy, used by notifications and email triggers:
| Token | Constant | Meaning |
|---|---|---|
$OWNER.DIRECT_MANAGER | CURRENT_STEP_OWNER_DIRECT_MANAGER_RECIPIENT_SOURCE_VALUE | The step owner’s direct manager |
$OWNER.ORG_UNIT_MANAGER | CURRENT_STEP_OWNER_ORGUNIT_MANAGER_RECIPIENT_SOURCE_VALUE | The manager of the step owner’s org unit |
Scoping (“related org unit users”)
Section titled “Scoping (“related org unit users”)”getUserRelatedOrgUnitsUsers(userId) returns the users considered “related” to a user through the structure. Starting from the user’s Main assignment org unit, an aggregation collects the active users assigned to the user’s own unit, its direct parent, and all descendant units (via $graphLookup down the parent chain). Only Active assignments and users are included; results are de-duplicated. This is GET /v1/users/my-orgunit, used for example by the user-picker fetcher to scope selectable people.
Administering the hierarchy over the API
Section titled “Administering the hierarchy over the API”There is no dedicated org-unit REST controller: org units and assignments go through the generic data-entry CRUD for the org_unit and assignment entities (see Writing data), plus the read helpers above. Build the tree with parent (leave the root’s parent empty), set a manager with a Main assignment that has isManager: true, give each user exactly one Main assignment, and extend ORGANIZATION_UNIT_LEVELS to describe depth.
Materialized ancestors
Section titled “Materialized ancestors”Because org units are a tree, OSOS materializes each node’s ancestor list to avoid repeated recursive lookups. Any entity whose definition has treeStructure.supported = true participates.
DataEntryTreeServicecomputes ancestors with a MongoDB$graphLookupovervalue.<treeField>.dataEntry → _id, sorted by depth, and stores the ordered ancestor ids at_meta.ancestors.value.<treeField>(for org units,_meta.ancestors.value.parent). It exposescalculateAncestors,findDescendants,updateNodeAncestors,updateNodeAndDescendantsAncestors,initializeAllAncestorsandrebuildAncestors.Since 1.2(with the1.2.0-a02-calculate-ancestorsbackfill migration).- Sync handlers (
sync-entry-ancestors-data-entry-created/-updated) fire on entry create/update, checktreeStructure.supported, and recompute ancestors for each tree field. Moving a subtree recomputes the node and all its descendants. - Writes use raw
$seton_meta.ancestors...(neverupdateById), consistent with the migration-safety rule for partial updates.
Data model summary
Section titled “Data model summary”ORGUNIT: normalized nameorg_unit, entity type11, implicit, restricted, editable (implicitOptions.allowEdit = true). Value modelOrgUnitDataEntryValue.ASSIGNMENT: normalized nameassignment. Links user and org unit with role, level, type andisManager.ORGANIZATION_UNIT_LEVELS: a string ADT collection of level labels.- Related constants in
libs/constants.ts:ORG_UNIT_ENTITY_ID='ORGUNIT',ORG_UNIT_ENTITY_NAME='org_unit',ASSIGNMENT_ENTITY_ID/NAME,AssignmentLevelTypes,AssignTypes,RoleLinkWIthOrgUnitTypes, and the two$OWNER.*recipient tokens.
Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27