Skip to content

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.

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).

Type (group_type.en)DescriptionSource entityEntity ID
Users GroupA regular group, created and managed manually by adding members.Users GroupUSERS_GROUP
Role GroupCreated automatically behind every role; membership derived from the role’s assignments.RoleROLE
Org Unit GroupCreated automatically behind every org unit; membership derived from the org chart.Org UnitORGUNIT
Query GroupA dynamic group: every user who satisfies the query joins, and any user who no longer does leaves, with no manual assignment.User Query GroupUSER_QUERY_GROUP
Virtual GroupA 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).

Membership is recorded as assignment rows, not as an array embedded on the group:

Entity nameEntity IDPurpose
group_assignmentsGROUP_ASSIGNMENTSVirtual: links a group (any type) to a user.
user_group_assignmentsUSER_GROUP_ASSIGNMENTSLinks a Users Group specifically to a user (value.users_group, value.user).
user_query_group_assignmentUSER_QUERY_GROUP_ASSIGNMENTMaterialized 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).

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.

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): when true, each returned user reference is enriched with a _resolved block containing the user’s indexed display metadata; when false or 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.

Each element is a user reference:

FieldTypePresent whenMeaning
dataEntitystringalwaysThe entity id of the reference (a user).
dataEntrystringalwaysThe member user’s id.
_resolvedobjectincludeResolved=trueResolved display metadata from the entry index.

getUsersInsideGroup builds a MongoDB aggregation over group_assignments that enforces, in order:

  1. Match rows where value.group.dataEntry is in the requested group id(s), state = Active and isInvalid != true. Several group ids may be passed at once; they are treated as a union.
  2. 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 the USER entity and restricts assignments to those users. This is how inactive users are excluded.
  3. De-duplicate by value.user.dataEntry, keeping the first row: a user who belongs to a group through more than one assignment appears once.
  4. Sort by value._metaOrder.value ascending, so member order is stable.
  5. Optional resolve: when includeResolved is 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.

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 optionEffect when the owner is a group
Default (single owner)Resolves the group and assigns its first member (groupUsers[0]) as the owner.
selectionCriteria = ManagerResolves the org-unit manager of the group via getOrgUnitManager; if none is found, the owner is cleared.
selectionCriteria = ManualThe auto-resolved owner is cleared so a person picks the owner manually.
isParallel = trueThe 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.

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.

  • 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.

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. ORGUNIT forms 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, address and motto. 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:

CapabilityDriven byEntry point
Scoping (“my org unit users”)the user’s Main assignment org unit + its parent + all descendantsGET /v1/users/my-orgunit
Direct-manager resolutionwalking the parent chain upward for the nearest manager assignmentGET /v1/users/direct-manager
Workflow step owner (relative)the same upward walk, driven by a step’s relative optionsworkflow engine (owner resolution)

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)LabelTypeNotes
nameNameLocalized textRequired, unique, shown as the entry title
descriptionDescriptionLocalized textOptional
iconIconIconOptional, used as the entry picture
parentParentRelation → ORGUNITThe hierarchy link. sourceOptions.denyCircularRelation: true, so a unit cannot become its own ancestor
org_unit_levelOrg unit levelRelation → ORGANIZATION_UNIT_LEVELS collectionThe unit’s level
isMainAssignmentLevel Assignment is mainBooleanDefault false. When true, the unit accepts only Main assignments (OrgUnitAcceptJustMainLevelException)
managerManagerRelation → USEROptional. 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_level points at the ORGANIZATION_UNIT_LEVELS string ADT collection (label Org Unit levels). Out of the box it holds a single level:

Level idLabel (en)levelindex
5cf7d2cc-…-461e636fFirst level00

Levels are descriptive labels; the actual hierarchy is defined by parent, not by the level value.

Initial setup creates one root org unit, “Executive Management” (org-root.json), with parent: "", the seeded first level, and a home icon.

Each Assignment (ASSIGNMENT entity, assignment.json) ties one user to one org unit with a role:

FieldLabelTypeMeaning
roleRoleRelation → ROLEThe role held
assign_levelAssign LevelSingle-selectMAIN or ADDITIONAL (AssignmentLevelTypes)
assign_typeAssign typeSingle-selectORIGINAL or DELEGATION (AssignTypes)
userUserRelation → USERThe assigned user
org_unitOrg UnitRelation → ORGUNITThe org unit
isManagerIs ManagerBooleanWhether 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_unit cleared.

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 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).

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.json duplicate was removed from the migration sources, so a fresh environment seeds ORGUNIT from orgunit.json, now the entity’s sole seed.
  • Migration 1.8.0-a31-add-manager-field-to-org-unit-entity backfills manager onto ORGUNIT on existing environments. It is idempotent (it appends the field only where manager is missing), and its down() is deliberately a no-op, because removing the field could destroy data already captured on org-unit entries.

getUserDirectManager(userId, relationGrade = 1) resolves a user’s manager by climbing the hierarchy:

  1. Find the user’s Main assignment and its org_unit.
  2. $graphLookup up the parent chain from that unit, ordered by depth (nearest first, including the user’s own unit at depth 0).
  3. Walk that list looking for an assignment on each unit with isManager: true and a different user than the subject.
  4. Return the N-th manager found, where N = relationGrade (“how many manager levels up”, starting at 1 for the immediate manager).
  5. 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).

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:

TokenConstantMeaning
$OWNER.DIRECT_MANAGERCURRENT_STEP_OWNER_DIRECT_MANAGER_RECIPIENT_SOURCE_VALUEThe step owner’s direct manager
$OWNER.ORG_UNIT_MANAGERCURRENT_STEP_OWNER_ORGUNIT_MANAGER_RECIPIENT_SOURCE_VALUEThe manager of the step owner’s org unit

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.

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.

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.

  • DataEntryTreeService computes ancestors with a MongoDB $graphLookup over value.<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 exposes calculateAncestors, findDescendants, updateNodeAncestors, updateNodeAndDescendantsAncestors, initializeAllAncestors and rebuildAncestors. Since 1.2 (with the 1.2.0-a02-calculate-ancestors backfill migration).
  • Sync handlers (sync-entry-ancestors-data-entry-created / -updated) fire on entry create/update, check treeStructure.supported, and recompute ancestors for each tree field. Moving a subtree recomputes the node and all its descendants.
  • Writes use raw $set on _meta.ancestors... (never updateById), consistent with the migration-safety rule for partial updates.
  • ORGUNIT: normalized name org_unit, entity type 11, implicit, restricted, editable (implicitOptions.allowEdit = true). Value model OrgUnitDataEntryValue.
  • ASSIGNMENT: normalized name assignment. Links user and org unit with role, level, type and isManager.
  • 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