Skip to main content
GET
/
api
/
citas
/
buscar
Search Appointments
curl --request GET \
  --url https://api.example.com/api/citas/buscar
{
  "appointments": [
    {
      "id": 123,
      "cliente_id": 123,
      "medico_id": {},
      "fecha_solicitada": "<string>",
      "hora_solicitada": "<string>",
      "fecha_confirmada": {},
      "hora_confirmada": {},
      "sintomas": {},
      "estado": "<string>",
      "created_at": "<string>",
      "cliente": {
        "id": 123,
        "nombres": "<string>",
        "apellidos": {},
        "telefono": "<string>",
        "email": {}
      },
      "medico": {
        "id": 123,
        "persona_id": 123,
        "especialidad_id": 123,
        "persona": {
          "nombres": "<string>",
          "apellidos": "<string>"
        }
      }
    }
  ]
}

Authentication

This endpoint requires authentication and authorization. Required roles: admin or asistente Header:
Authorization: Bearer <token>

Query Parameters

q
string
required
Search query - searches in client’s first name and last name (case-insensitive)

Response

Returns an array of matching appointments ordered by creation date (descending), limited to 10 results.
appointments
array
Array of appointment objects matching the search query
id
number
Appointment ID
cliente_id
number
Public client ID
medico_id
number | null
Assigned doctor ID (null if not confirmed)
fecha_solicitada
string
Requested date (ISO 8601)
hora_solicitada
string
Requested time (ISO 8601)
fecha_confirmada
string | null
Confirmed date (ISO 8601)
hora_confirmada
string | null
Confirmed time (ISO 8601)
sintomas
string | null
Patient symptoms description
estado
string
Appointment status: pendiente, confirmada, atendida, or cancelada
created_at
string
Creation timestamp
cliente
object
Public client information
id
number
Client ID
nombres
string
First name(s)
apellidos
string | null
Last name(s)
telefono
string
Phone number
email
string | null
Email address
medico
object | null
Assigned doctor information (null if not confirmed)
id
number
Doctor ID
persona_id
number
Person ID
especialidad_id
number
Specialty ID
persona
object
Doctor’s personal information
nombres
string
First name(s)
apellidos
string
Last name(s)

Example Request

curl -X GET "https://api.example.com/api/citas/buscar?q=María" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

[
  {
    "id": 1,
    "cliente_id": 5,
    "medico_id": 2,
    "fecha_solicitada": "2026-03-15T00:00:00.000Z",
    "hora_solicitada": "1970-01-01T14:30:00.000Z",
    "fecha_confirmada": "2026-03-15T00:00:00.000Z",
    "hora_confirmada": "2026-03-05T18:20:00.000Z",
    "sintomas": "Dolor de cabeza constante",
    "estado": "confirmada",
    "created_at": "2026-03-05T10:00:00.000Z",
    "cliente": {
      "id": 5,
      "nombres": "María",
      "apellidos": "González",
      "telefono": "+50312345678",
      "email": "[email protected]"
    },
    "medico": {
      "id": 2,
      "persona_id": 10,
      "persona": {
        "nombres": "Carlos",
        "apellidos": "Ramírez"
      }
    }
  },
  {
    "id": 8,
    "cliente_id": 12,
    "medico_id": null,
    "fecha_solicitada": "2026-03-20T00:00:00.000Z",
    "hora_solicitada": "1970-01-01T09:00:00.000Z",
    "fecha_confirmada": null,
    "hora_confirmada": null,
    "sintomas": "Chequeo general",
    "estado": "pendiente",
    "created_at": "2026-03-04T15:30:00.000Z",
    "cliente": {
      "id": 12,
      "nombres": "Ana María",
      "apellidos": "López",
      "telefono": "+50398765432",
      "email": "[email protected]"
    },
    "medico": null
  }
]

Empty Query Response

If the query parameter is empty or missing, an empty array is returned:
curl -X GET "https://api.example.com/api/citas/buscar?q=" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
[]

Error Responses

401 Unauthorized
Missing or invalid authentication token
{
  "message": "Token no proporcionado"
}
403 Forbidden
User doesn’t have required role
{
  "message": "Acceso denegado: requiere rol admin o asistente"
}
500 Internal Server Error
Server error while searching appointments
{
  "message": "Error al buscar citas"
}

Notes

  • The search is case-insensitive
  • Searches both first names (nombres) and last names (apellidos)
  • Returns a maximum of 10 results
  • Results are ordered by creation date (most recent first)
  • Empty or whitespace-only queries return an empty array
  • Partial matches are supported (e.g., “Mar” will match “María” and “Marta”)

Build docs developers (and LLMs) love