Skip to main content

GET /api/users/search

Search for users by email and/or status with pagination support. This endpoint requires read privileges or admin role.

Authentication

This endpoint requires JWT authentication with one of the following:
  • READ_PRIVILEGES authority
  • ADMIN role

Query Parameters

email
string
Filter by email address or user ID (partial match). Optional.
status
string
Filter by user status. Valid values: ACTIVO, INACTIVO. Optional.
page
integer
default:"0"
Page number (0-based index). Default is 0.
size
integer
default:"10"
Number of items per page. Default is 10.

Response

content
array
Array of user objects matching the search criteria
pageNumber
integer
Current page number (0-based)
pageSize
integer
Number of items per page
totalElements
long
Total number of users matching the search criteria
totalPages
integer
Total number of pages available
isLast
boolean
Whether this is the last page of results

Error Codes

  • 200 - Search results returned successfully
  • 400 - Bad Request: Invalid parameters (e.g., invalid status value)
  • 401 - Unauthorized: Missing or invalid JWT token
  • 403 - Forbidden: Insufficient permissions

Example Request

curl -X GET "https://api.example.com/api/users/search?email=john&status=ACTIVO&page=0&size=10" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

{
  "content": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "names": "John Michael Doe",
      "email": "john.doe@example.com",
      "isEnabled": true,
      "accountNonExpired": true,
      "accountNonLocked": true,
      "credentialsNonExpired": true,
      "roles": [
        {
          "id": "660e8400-e29b-41d4-a716-446655440000",
          "name": "USER",
          "description": "Standard user role",
          "permissions": [],
          "status": "ACTIVO"
        }
      ],
      "status": "ACTIVO"
    },
    {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "names": "Johnny Smith",
      "email": "johnny.smith@example.com",
      "isEnabled": true,
      "accountNonExpired": true,
      "accountNonLocked": true,
      "credentialsNonExpired": true,
      "roles": [],
      "status": "ACTIVO"
    }
  ],
  "pageNumber": 0,
  "pageSize": 10,
  "totalElements": 2,
  "totalPages": 1,
  "isLast": true
}

Pagination Example

To retrieve the second page of results with 20 items per page:
curl -X GET "https://api.example.com/api/users/search?page=1&size=20" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Error Response

{
  "timestamp": "2026-03-04T10:30:00Z",
  "requestId": "abc123-def456",
  "message": "Invalid parameter",
  "detail": "Status must be either ACTIVO or INACTIVO"
}

Build docs developers (and LLMs) love