Skip to main content
PUT
/
update-department-role
Update a user's department role
curl --request PUT \
  --url http://localhost:2000/update-department-role \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "payload": {
    "userId": "64ef3c29f9a1c27e1b2c3a4d",
    "departmentRole": "manager"
  }
}
'
{
  "message": "<string>",
  "data": {}
}
Admin-only endpoint to update a user’s department role by user ID.

Request

Headers

NameTypeRequiredDescription
AuthorizationstringYesBearer token
Content-TypestringYesapplication/json

Request Body

{
  "payload": {
    "userId": "64ef3c29f9a1c27e1b2c3a4d",
    "departmentRole": "manager"
  }
}

Request Body Schema

FieldTypeRequiredDescription
payloadobjectYesUpdate payload
payload.userIdstringYesUser ID to update
payload.departmentRolestringYesNew department role

Response

200 OK - Successfully updated department role

{
  "message": "Department role updated successfully",
  "data": {}
}

400 Bad Request

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request body"
  }
}

401 Unauthorized

{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Missing or invalid token or insufficient permissions"
  }
}

404 Not Found

{
  "error": {
    "code": "USER_NOT_FOUND",
    "message": "User not found"
  }
}

500 Internal Server Error

{
  "error": {
    "code": "SERVER_ERROR",
    "message": "Internal server error"
  }
}

Example

curl -X PUT 'http://localhost:2000/update-department-role' \
  -H 'Authorization: Bearer your-jwt-token' \
  -H 'Content-Type: application/json' \
  -d '{
    "payload": {
      "userId": "64ef3c29f9a1c27e1b2c3a4d",
      "departmentRole": "manager"
    }
  }'

Notes

  • This is an admin-only endpoint - requires administrative privileges
  • The user ID must be a valid MongoDB ObjectId
  • Department roles can include: “manager”, “supervisor”, “agent”, “admin”, etc.
  • The role may affect the user’s permissions within their department
  • Only administrators can update other users’ department roles
  • Role names should match predefined roles in your system

Authorizations

Authorization
string
header
required

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

Body

application/json
payload
object

Response

Successfully updated department role

message
string
data
object