Platform modules
Organizational hierarchy and scoped access
Model departments, assign dated memberships and grant access to a branch and its descendants.
Model the institution inside a tenant
Organizations owns unit types, organizational units, memberships, permission scope grants and change history. Its routes start with /api/v1/organizations. A unit represents a department or branch inside the current tenant; it does not create another tenant or another set of application accounts.
The hierarchy records a parent relationship. Unit codes are checked for duplicates. Moving a unit under itself or one of its descendants is rejected, so the tree remains acyclic. The writer serializes mutations that could affect hierarchy, scope or membership through a transaction and a tenant-specific PostgreSQL advisory lock.
Build a useful hierarchy
- Create a unit type through
POST /api/v1/organizations/types. - Create a top-level unit and its departments through
POST /api/v1/organizations/units. - Inspect the hierarchy with
GET /api/v1/organizations/units/tree. - Add memberships to the relevant units, setting their validity periods.
- Grant the required action scope to each supervisor, deciding whether it includes descendants.
Use a small development example: Head Office, Operations beneath it, and a Maintenance unit beneath Operations. This lets you verify inherited access without starting with an institution-wide hierarchy.
Separate membership, action and scope
| Record or permission | What it establishes |
|---|---|
| Role permission | The user can perform a named action |
| Membership | The user belongs to a unit during a valid period |
| Scope grant | The named action applies to this unit, optionally including descendants |
Permissions.Organizations.AccessAll |
Access across units in the current tenant |
HasScopeAsync checks both the user's action permission and a matching live scope. A grant is active after its start and before its optional end, unless revoked. IncludeDescendants follows the current hierarchy; it does not grant unrelated actions.
Grant administration requires ManageGrants, the tenant administrator checks and possession of the permission being granted. The recipient must already hold that permission. Self-granting through this operation is rejected. Only permissions admitted by Organizations or an IOrganizationScopePermissions provider can receive organizational scope.
Extend scope into a module
Consume IOrganizationAccess, IOrganizationParticipants or IOrganizationDuty through Contracts. Register an IOrganizationScopePermissions provider for your module's eligible actions. Tickets registers its View and Respond actions; Workflows registers its workflow permissions.
Use duty checks when eligibility also requires active unit membership. A broad scope alone does not prove someone is an active responder for a service unit. Keep the check on the server even if the frontend already limits its unit picker.
Verify and troubleshoot
Give a supervisor View on Operations with descendants enabled. Confirm they can read Operations and Maintenance but cannot read an unrelated branch. Revoke or expire the grant and repeat the same read. Also test the same user ID under another tenant: the request must remain within its tenant boundary.
For an empty tree, check the action permission and live grant dates before assuming records are missing. For failed grant creation, inspect the grantor's administrator status, the recipient's permission and the supported scope catalog. Unit history is available through GET /api/v1/organizations/units/{id}/history and records structural and access-related changes.