Skip to main content

Endpoint

GET /api/medicos

Authentication

This endpoint requires authentication with an admin role. Include a valid JWT token in the Authorization header.
Authorization: Bearer <token>

Description

Retrieves all doctors in the system, including both active and inactive ones. This is the admin view that shows complete information about all doctors with their associated person and specialty details.

Response

Returns an array of doctor objects with nested person and specialty information.

Response Fields

id
integer
Unique identifier for the doctor
persona_id
integer
Foreign key reference to the associated person
especialidad_id
integer
Foreign key reference to the doctor’s specialty
email
string
Doctor’s professional email address
colegiatura
string
Professional license or medical registration number
activo
boolean
Indicates if the doctor is currently active in the system
persona
object
Associated person information
especialidad
object
Associated specialty information

Example Request

curl -X GET "https://api.example.com/api/medicos" \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

[
  {
    "id": 1,
    "persona_id": 5,
    "especialidad_id": 2,
    "email": "[email protected]",
    "colegiatura": "MED-12345",
    "activo": true,
    "persona": {
      "nombres": "John",
      "apellidos": "Smith",
      "telefono": "+1234567890"
    },
    "especialidad": {
      "nombre": "Cardiology"
    }
  },
  {
    "id": 2,
    "persona_id": 8,
    "especialidad_id": 1,
    "email": "[email protected]",
    "colegiatura": "MED-67890",
    "activo": false,
    "persona": {
      "nombres": "Sarah",
      "apellidos": "Jones",
      "telefono": "+1234567891"
    },
    "especialidad": {
      "nombre": "Pediatrics"
    }
  }
]

Error Responses

401 Unauthorized
Missing or invalid authentication token
{
  "message": "Token no proporcionado"
}
403 Forbidden
User does not have admin role
{
  "message": "Acceso denegado"
}
500 Internal Server Error
Server error while retrieving doctors
{
  "message": "Error al listar médicos"
}

Notes

  • Unlike the public doctors endpoint (/api/medicos/public), this admin endpoint returns both active and inactive doctors
  • Results are ordered by ID in ascending order
  • The response includes full person and specialty details through relations

Build docs developers (and LLMs) love