Skip to main content

Create user profile

Creates a new user profile with the provided information. This endpoint is typically called after user registration in the authentication service.

Request body

name
string
required
The user’s full name. Must be between 1 and 120 characters.
email
string
required
The user’s email address. Must be a valid email format and at most 255 characters.
phone
string
required
The user’s phone number. Must match the pattern ^[0-9+()\- ]{7,20}$ (7-20 characters including digits, +, (), -, and spaces).

Response

id
integer
The unique identifier for the created user profile
userId
integer
The user ID from the authentication system
name
string
The user’s full name
email
string
The user’s email address
phone
string
The user’s phone number
createdAt
string
ISO 8601 timestamp when the profile was created
updatedAt
string
ISO 8601 timestamp when the profile was last updated
curl -X POST http://localhost:8082/users \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "name": "John Smith",
    "email": "[email protected]",
    "phone": "+1 (555) 123-4567"
  }'

List users

Retrieves a paginated list of all user profiles. This endpoint requires admin privileges.

Query parameters

page
integer
default:"0"
The page number to retrieve (0-indexed). Must be 0 or greater.
size
integer
default:"10"
The number of items per page. Must be between 1 and 100.
sortBy
string
default:"createdAt"
The field to sort by. Common values: createdAt, name, email, updatedAt.
sortDir
string
default:"desc"
The sort direction. Valid values: asc, desc.

Response

content
array
Array of user profile objects
page
integer
The current page number (0-indexed)
size
integer
The number of items per page
totalElements
integer
The total number of user profiles
totalPages
integer
The total number of pages available
last
boolean
Whether this is the last page
curl -X GET "http://localhost:8082/users?page=0&size=10&sortBy=createdAt&sortDir=desc" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Get user by ID

Retrieves a specific user profile by user ID. Users can only access their own profile unless they have admin privileges.

Path parameters

userId
integer
required
The unique user ID to retrieve

Response

id
integer
The unique identifier for the user profile
userId
integer
The user ID from the authentication system
name
string
The user’s full name
email
string
The user’s email address
phone
string
The user’s phone number
createdAt
string
ISO 8601 timestamp when the profile was created
updatedAt
string
ISO 8601 timestamp when the profile was last updated
curl -X GET http://localhost:8082/users/1001 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Update user profile

Updates an existing user profile. Users can only update their own profile unless they have admin privileges.

Path parameters

userId
integer
required
The unique user ID to update

Request body

name
string
required
The user’s full name. Must be between 1 and 120 characters.
email
string
required
The user’s email address. Must be a valid email format and at most 255 characters.
phone
string
required
The user’s phone number. Must match the pattern ^[0-9+()\- ]{7,20}$.

Response

id
integer
The unique identifier for the user profile
userId
integer
The user ID from the authentication system
name
string
The updated user’s full name
email
string
The updated user’s email address
phone
string
The updated user’s phone number
createdAt
string
ISO 8601 timestamp when the profile was created
updatedAt
string
ISO 8601 timestamp when the profile was last updated
curl -X PUT http://localhost:8082/users/1001 \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "name": "John A. Smith",
    "email": "[email protected]",
    "phone": "+1 (555) 123-4567"
  }'

Delete user profile

Deletes a user profile. Users can only delete their own profile unless they have admin privileges.

Path parameters

userId
integer
required
The unique user ID to delete

Response

message
string
A confirmation message indicating successful deletion
curl -X DELETE http://localhost:8082/users/1001 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Health check

Checks the health status of the User Service. This endpoint is typically used by monitoring systems and load balancers.

Response

Returns a 200 status code when the service is healthy.
curl -X GET http://localhost:8082/actuator/health

Build docs developers (and LLMs) love