Assign a manager to a department
User Management
Assign Department Manager
Admin-only endpoint to assign a user as the manager of a department.
PUT
Assign a manager to a department
Admin-only endpoint to assign a user as the manager of a department.
Request
Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token |
| Content-Type | string | Yes | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| departmentId | string | Yes | Department ID to assign manager to |
Request Body
Request Body Schema
| Field | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | User ID to assign as department manager |
Field Details
- userId: Valid MongoDB ObjectId of the user to promote to manager
Response
200 OK - Successfully assigned manager
400 Bad Request
401 Unauthorized
500 Internal Server Error
Example
Notes
- This is an admin-only endpoint - requires administrative privileges
- Department ID must be a valid MongoDB ObjectId
- User ID must be a valid MongoDB ObjectId
- The assigned user automatically gets “manager” role in the department
- Previous manager (if any) is demoted to regular member
- The user must already be a member of the department
- If user is not in department, they are added first as manager
Manager Privileges
Department managers typically have:- Full department access and control
- Ability to manage department members
- Access to department analytics and reports
- Approval authority for department requests
- Representation in organizational meetings
Use Cases
- Promotion: Promote a team member to management
- Replacement: Replace departing or transferred manager
- Reorganization: Assign new leadership during restructuring
- Interim Management: Assign temporary manager
Best Practices
- Verify Eligibility: Ensure user is suitable for management role
- Communicate Changes: Notify team about leadership changes
- Training: Provide management training if needed
- Access Review: Review manager permissions after assignment
- Documentation: Document the reason for management change
Error Handling
- User Not Found: User ID doesn’t exist in system
- Department Not Found: Department ID doesn’t exist
- Invalid Permissions: User lacks required permissions
- Already Manager: User is already the department manager
Impact on Users
New Manager
- Gains elevated permissions within department
- Can view and manage department resources
- Receives management notifications and reports
- May see additional dashboard features
Previous Manager
- Loses manager privileges but remains in department
- Retains regular department member access
- May need to hand over responsibilities
Department Members
- See new manager in organizational charts
- May receive notifications about leadership change
- Continue with normal department operations
Security Considerations
- Manager role grants significant permissions
- Regularly review manager assignments
- Consider audit trails for management changes
- Ensure proper authorization for this endpoint
Related Endpoints
- Use
/department/add-usersto add users to department first - Use
/user/update-department-rolefor other role assignments - Use
/department/listto verify current assignments
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Unique identifier of the department
Body
application/json
User ID of the manager to assign
Example:
"64ef3c29f9a1c27e1b2c3b5e"