Skip to main content
PUT
/
api
/
admin
/
users
/
{id}
Update User
curl --request PUT \
  --url https://api.example.com/api/admin/users/{id} \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "email": "<string>",
  "role": "<string>"
}
'

Overview

Update user information by ID. This endpoint is restricted to administrators and allows updating user profile data.

Authentication

Authorization
string
required
Bearer token for authentication. Must be a valid JWT token for a user with ADMIN role.

Authorization

This endpoint requires the ADMIN role.

Path Parameters

id
integer
required
The unique identifier of the user to update

Request Body

name
string
User’s full name
email
string
User’s email address. Must be unique in the system.
role
string
User role. Must be one of: ADMIN, PATIENT, DOCTOR

Response

Returns the updated user object with all fields.

Example Request

curl -X PUT https://api.example.com/api/admin/users/42 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Dr. Sarah Johnson",
    "email": "[email protected]",
    "role": "DOCTOR"
  }'

Example Response

{
  "id": 42,
  "name": "Dr. Sarah Johnson",
  "email": "[email protected]",
  "role": "DOCTOR",
  "isActive": true,
  "isSuspended": false,
  "createdAt": "2024-01-15T10:30:00.000Z",
  "updatedAt": "2024-03-03T14:20:00.000Z"
}

Error Responses

404 Not Found

{
  "error": "Usuario no encontrado"
}

400 Bad Request

{
  "error": "Email already exists"
}

403 Forbidden

{
  "error": "Access denied"
}

Build docs developers (and LLMs) love