Organizational API
The Organizational API provides endpoints for managing organizational units and their hierarchical structure within the UBU Digital Finance Solution.
Endpoints
Create Organizational Unit
Creates a new organizational unit. Requires the create_organizational_unit permission.
Request Body
{
"unit_name": "string",
"unit_description": "string",
"parent_unit_id": "uuid" // Optional, null for top-level units
}
Responses
201 Created - Organizational unit created successfully
{
"unit_id": "uuid",
"unit_name": "string",
"unit_description": "string",
"parent_unit_id": "uuid",
"is_active": true
}
400 Bad Request - Validation error
404 Not Found - Parent unit not found
403 Forbidden - Insufficient permissions
Get All Organizational Units
Retrieves a list of all organizational units. Requires the view_organizational_units permission.
Responses
200 OK - Organizational units retrieved successfully
[
{
"unit_id": "uuid",
"unit_name": "string",
"unit_description": "string",
"parent_unit_id": "uuid",
"is_active": true
}
]
403 Forbidden - Insufficient permissions
Get Organizational Unit
Retrieves a specific organizational unit. Requires the view_organizational_units permission.
Path Parameters
unit_id(UUID): ID of the organizational unit
Responses
200 OK - Organizational unit retrieved successfully
{
"unit_id": "uuid",
"unit_name": "string",
"unit_description": "string",
"parent_unit_id": "uuid",
"is_active": true,
"parent": {
"unit_id": "uuid",
"unit_name": "string"
},
"children": [
{
"unit_id": "uuid",
"unit_name": "string"
}
]
}
404 Not Found - Organizational unit not found
403 Forbidden - Insufficient permissions
Update Organizational Unit
Updates an organizational unit. Requires the update_organizational_unit permission.
Path Parameters
unit_id(UUID): ID of the organizational unit to update
Request Body
{
"unit_name": "string",
"unit_description": "string",
"parent_unit_id": "uuid", // Optional, null for top-level units
"is_active": true
}
Responses
200 OK - Organizational unit updated successfully
{
"unit_id": "uuid",
"unit_name": "string",
"unit_description": "string",
"parent_unit_id": "uuid",
"is_active": true
}
404 Not Found - Organizational unit not found
404 Not Found - Parent unit not found
400 Bad Request - Validation error
400 Bad Request - Circular reference
403 Forbidden - Insufficient permissions
Delete Organizational Unit
Deletes an organizational unit. Requires the delete_organizational_unit permission.
Path Parameters
unit_id(UUID): ID of the organizational unit to delete
Responses
200 OK - Organizational unit deleted successfully
404 Not Found - Organizational unit not found
400 Bad Request - Unit has children
400 Bad Request - Unit has users
403 Forbidden - Insufficient permissions
Get Users in Organizational Unit
Retrieves the users assigned to an organizational unit. Requires the view_organizational_units permission.
Path Parameters
unit_id(UUID): ID of the organizational unit
Responses
200 OK - Users retrieved successfully
[
{
"user_id": "uuid",
"user_code": "string",
"user_fullname": "string",
"user_email": "string",
"assignment_is_active": true
}
]
404 Not Found - Organizational unit not found
403 Forbidden - Insufficient permissions
Get User's Organizational Units
Retrieves the organizational units assigned to a user. Requires the view_organizational_units permission.
Path Parameters
user_id(UUID): ID of the user
Responses
200 OK - Organizational units retrieved successfully
[
{
"unit_id": "uuid",
"unit_name": "string",
"unit_description": "string",
"parent_unit_id": "uuid",
"is_active": true,
"assignment_is_active": true
}
]
404 Not Found - User not found
403 Forbidden - Insufficient permissions
Organizational Structure
Organizational units in the UBU Digital Finance Solution are structured hierarchically:
Hierarchical Structure
- Each unit can have a parent unit
- Units without a parent are considered top-level units
- The hierarchy can have multiple levels
- Units cannot be their own ancestor (no circular references)
Unit Properties
- Unit Name: A human-readable name for the unit
- Unit Description: Additional context about what the unit represents
- Parent Unit: The parent unit in the hierarchy (optional)
- Active Status: Whether the unit is active
Unit Status
Units can be active or inactive:
- Active units can be assigned to users
- Inactive units cannot be assigned to users
- Existing assignments to inactive units are not automatically removed
Default Organizational Units
The system can be configured with default organizational units:
| Unit Name | Description | Parent |
|---|---|---|
| Headquarters | Main organizational headquarters | None |
| Finance Department | Department handling financial operations | Headquarters |
| IT Department | Department handling technology | Headquarters |
| Operations Department | Department handling day-to-day operations | Headquarters |
| East Region | Regional office for eastern operations | Headquarters |
| West Region | Regional office for western operations | Headquarters |
| Branch Office 1 | Local branch office | East Region |
| Branch Office 2 | Local branch office | West Region |
Unit Assignment
Organizational units are assigned to users through the User API when creating or updating a user. The assignment includes:
- User ID: The ID of the user
- Unit ID: The ID of the organizational unit
- Active Status: Whether the unit assignment is active
A user can be assigned to multiple organizational units, but typically one primary unit is used for most operations.
Organizational Unit-Based Access Control
The system can implement organizational unit-based access control:
- Users are assigned to organizational units
- Access to certain resources can be restricted based on organizational unit membership
- This provides an additional layer of access control beyond role-based permissions
- Useful for implementing branch-level or department-level restrictions