Skip to main content

Endpoint

PUT /api/medicos/:id

Authentication

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

Description

Updates the information of an existing doctor. You can modify the specialty, email, professional license number, and active status. Note that the associated person cannot be changed.

Path Parameters

id
integer
required
Unique identifier of the doctor to update

Request Body

All fields are optional. Only include the fields you want to update.
especialidad_id
integer
ID of the medical specialty to assign to the doctor
email
string
Professional email address for the doctor
colegiatura
string
Professional license or medical registration number
activo
boolean
Whether the doctor is active in the system

Response

Returns the updated doctor object.

Response Fields

id
integer
Unique identifier for the doctor
persona_id
integer
ID of the associated person (unchanged)
especialidad_id
integer
Updated specialty ID
email
string
Updated email address
colegiatura
string
Updated professional license number
activo
boolean
Updated active status

Example Request

curl -X PUT "https://api.example.com/api/medicos/3" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "especialidad_id": 5,
    "email": "[email protected]",
    "activo": true
  }'

Example Response

{
  "id": 3,
  "persona_id": 5,
  "especialidad_id": 5,
  "email": "[email protected]",
  "colegiatura": "MED-12345",
  "activo": true
}

Error Responses

401 Unauthorized
Missing or invalid authentication token
{
  "message": "Token no proporcionado"
}
403 Forbidden
User does not have admin role
{
  "message": "Acceso denegado"
}
404 Not Found
Doctor with the specified ID does not exist
{
  "message": "Médico no encontrado"
}
500 Internal Server Error
Server error while updating doctor
{
  "message": "Error al actualizar médico"
}

Notes

  • The persona_id cannot be changed after a doctor is created
  • To deactivate a doctor without deleting their record, set activo to false
  • All fields in the request body are optional - only send the fields you want to update

Build docs developers (and LLMs) love