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

Authentication

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

Request Body

professionalID
integer
required
ID of the professional for whom the schedule is being createdMust reference an existing professional in the system.
dayOfWeek
integer
required
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
required
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
required
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

Response

schedule
object
The created work schedule object
curl -X POST "https://api.clinicavitalis.com/work_schedules" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "professionalID": 5,
    "dayOfWeek": 1,
    "startTime": "09:00",
    "endTime": "17:30"
  }'
{
  "schedule": {
    "id": 15,
    "professionalID": 5,
    "dayOfWeek": 1,
    "startTime": "09:00",
    "endTime": "17:30"
  }
}

Professional Schedule Constraints

Unique Day Constraint

Each professional can have only one schedule block per day of the week. This constraint is enforced at the database level through a unique index on (professionalID, dayOfWeek). Example Scenarios: Valid: Dr. García works Monday 09:00-17:30 Invalid: Dr. García works Monday 09:00-13:00 AND Monday 15:00-19:00 If you need to define split schedules (morning and afternoon), you must use a single continuous block or handle breaks in the appointment logic.

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"

Notes

  • Work schedules are used to validate appointment availability
  • Appointments can only be created during the professional’s defined work hours
  • The system checks that appointment times fall within the startTime and endTime range
  • Changes to work schedules may affect existing appointments

Build docs developers (and LLMs) love