Skip to main content
PUT
Assign a manager to a department
Admin-only endpoint to assign a user as the manager of a department.

Request

Headers

Path Parameters

Request Body

Request Body Schema

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

  1. Verify Eligibility: Ensure user is suitable for management role
  2. Communicate Changes: Notify team about leadership changes
  3. Training: Provide management training if needed
  4. Access Review: Review manager permissions after assignment
  5. 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
  • Use /department/add-users to add users to department first
  • Use /user/update-department-role for other role assignments
  • Use /department/list to verify current assignments

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

departmentId
string
required

Unique identifier of the department

Body

application/json
userId
string
required

User ID of the manager to assign

Example:

"64ef3c29f9a1c27e1b2c3b5e"

Response

Successfully assigned manager

message
string
Example:

"Successfully assigned manager (John Doe) to Engineering department"

data
object