Overview
The Organization Management API provides endpoints for managing organizational structures, including departments, divisions, and hierarchical relationships. Organizations help structure users and define reporting relationships within jshERP. Base Path:/organization
Organizations support hierarchical structures with parent-child relationships, enabling complex organizational charts.
CRUD Operations
Get Organization Information
Organization ID
Response status code (200 for success)
Organization entity object
Create Organization
Organization code/number (must be unique)
Organization abbreviation or short name
Parent organization ID (omit or set to null for root-level organization)
Sort order for display purposes
Additional remarks or description
Update Organization
Organization ID
Organization code/number
Organization abbreviation
Parent organization ID
Sort order
Additional remarks
Delete Organization
Organization ID to delete
Batch Delete Organizations
Comma-separated organization IDs (e.g., “1,2,3”)
Organization Hierarchy
Get Organization Tree
Root organization ID (use null or 0 to get the entire tree)
Array of tree node objects with nested children
Get All Organization Tree by User
Only users with public role type can access the full organization tree. Other users will receive an empty array.
Array of tree node objects (empty if user doesn’t have public role)
Find Organization by ID
Organization ID
Response status code
Organization details with parent information
Validation
Check Organization Name Exists
Organization ID (0 for new organization)
Organization abbreviation to check
true if name exists, false otherwiseData Models
Organization Entity
Unique organization identifier
Organization code/number (must be unique within tenant)
Organization abbreviation or short name (displayed in UI)
Parent organization ID:
nullor0: Root-level organization- Other value: Child organization
Sort order for display purposes (lower numbers appear first)
Additional remarks or description
Timestamp when the organization was created
Timestamp of last update
Associated tenant ID (for multi-tenancy)
Soft delete flag (used internally)
Hierarchical Structure
Understanding Parent-Child Relationships
Organizations support unlimited depth of hierarchy:Root Organizations
- Root organizations have
parentIdset tonullor0 - Typically represent top-level divisions or departments
- Can have multiple root organizations per tenant
Child Organizations
- Child organizations reference their parent via
parentId - Can themselves be parents to other organizations
- Inherit tenant from parent organization
Common Use Cases
Creating an Organization Hierarchy
- Create root organization with
parentId: null - Create child organizations referencing the root’s ID
- Continue creating nested levels as needed
- Use
sortfield to control display order at each level
Moving an Organization
- Get the organization’s current information
- Update the organization with a new
parentId - Verify the change using
/organization/getOrganizationTree
Restructuring Organizations
- Get the complete tree structure
- Identify organizations to move or delete
- Update parent relationships
- Remove obsolete organizations
Best Practices
User Assignment: Users can be assigned to organizations through the user management API. This establishes their position in the organizational structure.
Integration with Other Features
User Management
- Users are assigned to organizations
- Organization structure determines user hierarchy
- Used for approval workflows and reporting lines
Permissions
- Organization membership can affect data access
- Users may only see data from their organization and below
- Role permissions combine with organization structure
Reporting
- Organization structure used for departmental reports
- Hierarchical rollup of statistics
- Department-level analytics
Tree Operations
The organization tree structure is commonly used in:- Organization Pickers: Select departments in forms
- User-Organization Trees: Combined view showing users within organizations
- Permission Assignment: Grant permissions by organization
- Reporting Hierarchies: Structure reports by department
Error Codes
| Code | Description |
|---|---|
| 200 | Success |
| 500 | Internal server error |
All endpoints return a standard response format with
code and data fields. Check the code field to determine success or failure.Performance Considerations
Caching: Organization structures typically change infrequently. Consider caching tree structures to improve performance.