Skip to main content
GET
/
users
/
{id}
Get User
curl --request GET \
  --url https://api.example.com/users/{id}
{
  "200": {},
  "404": {},
  "id": 123,
  "name": "<string>",
  "email": "<string>",
  "role": {},
  "createdAt": {},
  "_links": {
    "self": {
      "href": "<string>"
    }
  }
}

Description

Retrieve a single user by their unique identifier. Returns a user object with HATEOAS links.
The password field is never included in response objects for security purposes.

Request

id
Long
required
The unique identifier of the user to retrieve

Response

Returns an EntityModel wrapping a UserView object with HATEOAS links.
id
Long
required
Unique identifier for the user
name
string
required
Full name of the user
email
string
required
Email address of the user
role
enum
required
User role in the system. Possible values: CUSTOMER, ADMIN
createdAt
LocalDateTime
required
Timestamp when the user was created (ISO 8601 format)
HATEOAS links for the user resource
self
object
Link to this specific user
href
string
URL to the user resource

Status Codes

200
OK
Successfully retrieved the user
404
Not Found
User with the specified ID does not exist (throws UserNotFoundException)

Security

Password fields are encrypted using PasswordEncoder and are never returned in API responses.

Example Request

cURL
curl -X GET http://localhost:8080/users/1 \
  -H "Content-Type: application/json"

Example Response

Success (200 OK)

{
  "id": 1,
  "name": "John Doe",
  "email": "[email protected]",
  "role": "CUSTOMER",
  "createdAt": "2026-03-01T10:30:00",
  "_links": {
    "self": {
      "href": "http://localhost:8080/users/1"
    }
  }
}

Error (404 Not Found)

{
  "error": "User not found",
  "message": "Could not find user with id: 999"
}

Build docs developers (and LLMs) love