Update a user's department
Profile Management
Update User Department
Admin-only endpoint to set a user’s department by department ID.
PUT
Update a user's department
Admin-only endpoint to set a user’s department by department ID.
Request
Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token |
| Content-Type | string | Yes | application/json |
Request Body
Request Body Schema
| Field | Type | Required | Description |
|---|---|---|---|
| payload | object | Yes | Update payload |
| payload.userId | string | Yes | User ID to update |
| payload.departmentId | string | Yes | New department ID |
Response
200 OK - Successfully updated department
400 Bad Request
401 Unauthorized
404 Not Found
500 Internal Server Error
Example
Notes
- This is an admin-only endpoint - requires administrative privileges
- Both user ID and department ID must be valid MongoDB ObjectIds
- The department ID must correspond to an existing department
- Users can be moved between departments using this endpoint
- Only administrators can update other users’ departments
- This may affect the user’s permissions if departments have role-based access