Skip to main content
PATCH
/
work_schedules
/
:id
curl -X PATCH "https://api.clinicavitalis.com/work_schedules/1" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startTime": "08:00",
    "endTime": "16:00"
  }'
{
  "schedule": {
    "id": 1,
    "professionalID": 5,
    "dayOfWeek": 1,
    "startTime": "08:00",
    "endTime": "16:00"
  }
}

Authentication

Requires a valid JWT token in the request header. Admin privileges required - Only administrators can update work schedules.

Path Parameters

id
integer
required
The unique identifier of the work schedule to update

Request Body

All fields are optional. Only include the fields you want to update.
dayOfWeek
integer
Day of the week for this schedule
  • 0 = Sunday (Domingo)
  • 1 = Monday (Lunes)
  • 2 = Tuesday (Martes)
  • 3 = Wednesday (Miércoles)
  • 4 = Thursday (Jueves)
  • 5 = Friday (Viernes)
  • 6 = Saturday (Sábado)
Constraint: Each professional can have only one schedule block per day.
startTime
string
Start time of the work schedule in HH:MM formatFormat: HH:MM (24-hour format)Examples:
  • "09:00" - 9:00 AM
  • "14:30" - 2:30 PM
  • "08:00" - 8:00 AM
Validation:
  • Hours: 00-23
  • Minutes: 00-59
  • Must match pattern: /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/
endTime
string
End time of the work schedule in HH:MM formatFormat: HH:MM (24-hour format)Examples:
  • "17:30" - 5:30 PM
  • "13:00" - 1:00 PM
  • "20:00" - 8:00 PM
Validation:
  • Hours: 00-23
  • Minutes: 00-59
  • Must match pattern: /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/
  • Must be later than startTime (if both are provided or startTime exists)

Response

schedule
object
The updated work schedule object
curl -X PATCH "https://api.clinicavitalis.com/work_schedules/1" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startTime": "08:00",
    "endTime": "16:00"
  }'
{
  "schedule": {
    "id": 1,
    "professionalID": 5,
    "dayOfWeek": 1,
    "startTime": "08:00",
    "endTime": "16:00"
  }
}

Update Constraints

Professional ID Cannot Be Changed

The professionalID field cannot be updated. If you need to assign a schedule to a different professional, you must delete the existing schedule and create a new one.

Unique Day Constraint

When updating the dayOfWeek, the system ensures that the professional doesn’t already have another schedule for that day. The unique constraint is enforced on (professionalID, dayOfWeek). Example:
  • Professional has schedule ID 1 for Monday (dayOfWeek: 1)
  • Professional has schedule ID 2 for Wednesday (dayOfWeek: 3)
  • ✅ Can update schedule ID 1 to Tuesday (dayOfWeek: 2)
  • ❌ Cannot update schedule ID 1 to Wednesday (dayOfWeek: 3) - conflict with schedule ID 2

Time Format Validation

Both startTime and endTime must match the HH:MM format:
  • Valid: "09:00", "14:30", "08:15", "23:59"
  • Invalid: "9:00" (missing leading zero), "09:00:00" (includes seconds), "25:00" (invalid hour)

Time Range Validation

The endTime must be strictly greater than startTime:
  • startTime: "09:00", endTime: "17:30"
  • startTime: "09:00", endTime: "09:00"
  • startTime: "17:00", endTime: "09:00"
When updating only one time field, the validation checks against the current value of the other field.

Impact on Appointments

Existing Appointments

Changing work schedules may affect existing appointments:
  • If you reduce the work hours (e.g., change endTime from "18:00" to "16:00"), existing appointments scheduled between 16:00-18:00 will become invalid
  • If you change the dayOfWeek, all appointments scheduled on the original day may become invalid
Recommendation: Before updating work schedules, check for existing appointments that may be affected.

Future Appointments

The updated schedule will be used to validate all new appointments created after the change.

Notes

  • Only administrators can update work schedules
  • Partial updates are supported - include only the fields you want to change
  • The schedule ID in the URL must match an existing schedule
  • Time format must be exactly HH:MM (24-hour format with leading zeros)

Build docs developers (and LLMs) love