Search Employees
Employees
Search Employees
Search for active employees by name or ID (Admin only)
GET
Search Employees
Overview
This endpoint provides a fast search functionality for finding active employees by name or ID. It’s designed for autocomplete interfaces and returns a limited set of results optimized for quick lookups.Admin Access Required
This endpoint requires administrator privileges. Only users with admin role can search for employees.
Request
Query Parameters
Search query string. Can be used to search by:
- Employee name (partial match)
- Employee ID (partial match)
Headers
Bearer token from Azure AD authentication with admin privileges
Response
Status of the request. Returns “success” for successful queries.
Array of matching employee records (maximum 10 results)
Response Example
Search Behavior
Active Employees Only
Only returns employees with active status (
id_estado = 1)Partial Matching
Searches using LIKE pattern with wildcards for flexible matching
Result Limit
Maximum 10 results returned to prevent performance issues
Alphabetical Order
Results sorted by name in ascending order
Search Examples
Search by Name
Search by ID
Empty Query
Performance Considerations
Indexed Search
Searches on
nombre and id_empleado fields for optimal performanceLimited Results
10-result limit prevents database overload in large datasets
Status Filter
Pre-filtering by active status reduces search scope
Optimized Query
Only fetches required fields (
id_empleado, nombre)Use Cases
Autocomplete
Power typeahead search in admin forms and interfaces
Employee Lookup
Quick employee ID/name lookup for administrative tasks
Request Assignment
Search for employees when assigning requests or approvers
Report Filtering
Filter reports by specific employees using search
Error Handling
403 Forbidden
User does not have administrator privileges to search employees
500 Internal Error
Database connection issues or unexpected server errors during search
Security Notes
- SQL Injection Protection: Uses Sequelize ORM with parameterized queries
- Role-Based Access: Enforced by
verificarRol(PERMISOS.SOLO_ADMINS)middleware - Limited Data Exposure: Only returns
id_empleadoandnombre_completofields - Active Status Filter: Prevents exposure of inactive/terminated employees