Skip to main content
PUT
/
api
/
management
/
users
/
{id}
Update user
curl --request PUT \
  --url https://api.example.com/api/management/users/{id} \
  --header 'Content-Type: application/json' \
  --data '
{
  "firstName": "<string>",
  "lastName": "<string>",
  "email": "<string>",
  "roles": [
    {}
  ]
}
'
{
  "success": true,
  "timestamp": "<string>",
  "data": {
    "data.email": "<string>",
    "data.firstName": "<string>",
    "data.lastName": "<string>",
    "data.roles": [
      {}
    ]
  }
}

Endpoint

PUT /api/management/users/{id}

Authentication

This endpoint requires authentication with a valid JWT token and the ADMIN role.
Authorization: Bearer <your_jwt_token>

Path Parameters

id
integer
required
The unique identifier of the user to update

Request Body

The request body must be a JSON object containing the user’s updated information.
firstName
string
required
User’s first nameValidation:
  • Required (cannot be blank)
  • Length: 2-50 characters
  • Pattern: Must contain only letters, spaces, periods, hyphens, and apostrophes
lastName
string
required
User’s last nameValidation:
  • Required (cannot be blank)
  • Length: 2-50 characters
  • Pattern: Must contain only letters, spaces, periods, hyphens, and apostrophes
email
string
required
User’s email address (must be unique)Validation:
  • Required (cannot be blank)
  • Must be a valid email format
roles
array
required
Array of role strings to assign to the userAvailable roles:
  • MEMBER: Standard user role
  • ADMIN: Administrator role with full system access
Validation:
  • At least one role must be assigned
Example: ["MEMBER"] or ["ADMIN", "MEMBER"]

Response

Returns the updated user information.
success
boolean
required
Indicates if the request was successful
timestamp
string
required
ISO 8601 timestamp of the response
data
object
required
Updated user details
data.email
string
required
User’s updated email address
data.firstName
string
required
User’s updated first name
data.lastName
string
required
User’s updated last name
data.roles
array
required
Array of role strings assigned to the user

Example Request

curl -X PUT "http://localhost:8080/api/management/users/1" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "John",
    "lastName": "Smith",
    "email": "[email protected]",
    "roles": ["MEMBER", "ADMIN"]
  }'

Example Response

{
  "success": true,
  "timestamp": "2026-03-03T10:30:00Z",
  "data": {
    "email": "[email protected]",
    "firstName": "John",
    "lastName": "Smith",
    "roles": ["MEMBER", "ADMIN"]
  }
}

Error Responses

400 Bad Request

Returned when the request body contains invalid data or fails validation.
{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Validation failed",
    "details": [
      {
        "field": "firstName",
        "message": "Name must be between 2 and 50 characters"
      },
      {
        "field": "email",
        "message": "Invalid email format"
      },
      {
        "field": "roles",
        "message": "At least one role must be assigned"
      }
    ]
  }
}

401 Unauthorized

Returned when authentication credentials are missing or invalid.
{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Authentication required"
  }
}

403 Forbidden

Returned when the authenticated user does not have the ADMIN role.
{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": {
    "code": "FORBIDDEN",
    "message": "Access denied. ADMIN role required."
  }
}

404 Not Found

Returned when no user exists with the specified ID.
{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": {
    "code": "USER_NOT_FOUND",
    "message": "User not found with id: 999"
  }
}

409 Conflict

Returned when the email address is already in use by another user.
{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": {
    "code": "EMAIL_ALREADY_EXISTS",
    "message": "Email address is already in use"
  }
}

Build docs developers (and LLMs) love