Skip to main content
GET
/
api
/
admin
/
users
/
{id}
Get User by ID
curl --request GET \
  --url https://api.example.com/api/admin/users/{id} \
  --header 'Authorization: <authorization>'
{
  "id": 123,
  "name": "<string>",
  "email": "<string>",
  "role": "<string>",
  "isActive": true,
  "isSuspended": true,
  "suspensionReason": "<string>",
  "createdAt": "<string>",
  "updatedAt": "<string>"
}

Overview

Retrieve detailed information about a specific user by their ID. This endpoint is restricted to administrators only.

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. Users with PATIENT or DOCTOR roles will receive a 403 Forbidden response.

Path Parameters

id
integer
required
The unique identifier of the user to retrieve

Response

id
integer
Unique user identifier
name
string
User’s full name
email
string
User’s email address (unique)
role
string
User role: ADMIN, PATIENT, or DOCTOR
isActive
boolean
Whether the user account is active
isSuspended
boolean
Whether the user account is suspended
suspensionReason
string
Reason for suspension if the account is suspended
createdAt
string
ISO 8601 timestamp of account creation
updatedAt
string
ISO 8601 timestamp of last update

Example Request

curl -X GET https://api.example.com/api/admin/users/42 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Example Response

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

Error Responses

404 Not Found

{
  "error": "Usuario no encontrado"
}

403 Forbidden

{
  "error": "Access denied"
}

401 Unauthorized

{
  "error": "Unauthorized"
}

Build docs developers (and LLMs) love