Overview
The Role Management API provides endpoints for managing user roles, permissions, and access control in jshERP. Roles define what actions users can perform and what data they can access. Base Path:/role
Roles are essential for implementing role-based access control (RBAC) throughout the system.
CRUD Operations
Get Role Information
Role ID
Response status code (200 for success)
Role entity object
Get Role List
JSON string containing search filters:
name: Filter by role namedescription: Filter by description
Array of RoleEx objects with extended information
Total number of records
Create Role
Role name (must be unique)
Role type:
public: System-wide roletenant: Tenant-specific role
Role value/identifier
Role description
Price visibility configuration:
0: No price limit (can see all prices)1: Purchase price hidden2: Retail price hidden3: Sale price hidden
Role enabled status
Sort order for display
Update Role
Role ID
Role name
Role type
Role value/identifier
Role description
Price visibility configuration
Role enabled status
Sort order
Delete Role
Role ID to delete
Batch Delete Roles
Comma-separated role IDs (e.g., “1,2,3”)
Role Management
Check Role Name Exists
Role ID (0 for new role)
Role name to check
true if name exists, false otherwiseFind User Roles
User business type (e.g., “UserRole”)
User business key ID (typically user ID)
Array of role objects with checked status
Get All Roles
Array of all Role objects
Get Tenant Role List
Array of Role objects belonging to the current tenant
Batch Set Role Status
Status to set:
true: Enable rolesfalse: Disable roles
Comma-separated role IDs
Data Models
Role Entity
Unique role identifier
Role name (displayed to users)
Role type:
public: System-wide role available to all tenantstenant: Tenant-specific role
Price visibility restrictions:
0: No restrictions1: Purchase price hidden2: Retail price hidden3: Sale price hidden
Role value/identifier (used in code)
Detailed description of the role’s purpose
Role enabled status:
true: Role is active and can be assignedfalse: Role is disabled
Sort order for display purposes
Associated tenant ID (null for public roles)
Soft delete flag (used internally)
Role Types
Public Roles
- System-wide roles defined by administrators
- Available across all tenants
- Cannot be modified by tenant users
- Examples: Administrator, System Manager
Tenant Roles
- Created and managed by tenant administrators
- Specific to individual tenants
- Can be customized per tenant needs
- Examples: Sales Manager, Warehouse Staff
Price Limit Configuration
ThepriceLimit field controls what price information users with this role can view:
| Value | Description | Hidden Prices |
|---|---|---|
| 0 | No limit | None (full access) |
| 1 | Purchase price hidden | Purchase/cost prices |
| 2 | Retail price hidden | Retail prices |
| 3 | Sale price hidden | Sale prices |
Common Use Cases
Creating a New Role
- Check if the role name exists using
/role/checkIsNameExist - Create the role using
/role/addwith appropriate permissions - Configure price limits if needed
- Assign the role to users
Assigning Roles to Users
- Get the user’s current roles using
/role/findUserRole - Update the user’s role assignments through the user business API
- Verify the changes by checking user permissions
Managing Role Hierarchy
- Use the
sortfield to establish role display order - Public roles typically have lower sort values
- Tenant-specific roles follow the public roles
Best Practices
Tenant Isolation: Tenant roles are isolated per tenant. Each tenant can create roles with the same name without conflicts.
Permissions and Access Control
Roles work in conjunction with other permission systems:- Button Permissions: Control which UI buttons are visible
- Module Permissions: Control access to different modules
- Data Permissions: Control what data can be viewed/modified
- Price Limits: Control price information visibility
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.