The Appointments API enables scheduling, updating, and managing dental appointments across different branches and doctors.
Authentication
All endpoints require authentication with appropriate permissions:
VIEW_APPOINTMENTS - View appointments
CREATE_APPOINTMENTS - Create new appointments
EDIT_APPOINTMENTS - Update appointment details
DELETE_APPOINTMENTS - Cancel/delete appointments
Endpoints
List Appointments
curl -X GET "https://your-domain.com/api/appointments?date=2024-03-20&doctor_id=2&branch_id=1&status=scheduled" \
-H "Cookie: session=your-session-token"
Retrieve appointments filtered by date, doctor, branch, and status.
Filter by date (YYYY-MM-DD). Defaults to current date
Filter by doctor ID. Use “all” for all doctors (default: “all”)
Filter by branch ID. Use “all” for all branches (default: “all”)
Filter by status. Use “all” for all statuses (default: “all”)Valid statuses:
scheduled - Appointment is scheduled
confirmed - Patient confirmed attendance
completed - Appointment was completed
cancelled - Appointment was cancelled
no_show - Patient did not show up
Indicates if the request was successful
Array of appointment objects
Unique appointment identifier
ID of the assigned doctor
Date of appointment (YYYY-MM-DD)
Time of appointment (HH:MM:SS)
Current status of the appointment
{
"success": true,
"appointments": [
{
"id": 10,
"patient_id": 1,
"patient_name": "John Doe",
"doctor_id": 2,
"doctor_name": "Dr. Smith",
"branch_id": 1,
"branch_name": "Main Office",
"appointment_date": "2024-03-20",
"appointment_time": "10:00:00",
"duration_minutes": 30,
"status": "scheduled",
"notes": "Regular checkup",
"created_at": "2024-03-01T09:00:00Z"
},
{
"id": 11,
"patient_id": 5,
"patient_name": "Jane Smith",
"doctor_id": 2,
"doctor_name": "Dr. Smith",
"branch_id": 1,
"branch_name": "Main Office",
"appointment_date": "2024-03-20",
"appointment_time": "11:00:00",
"duration_minutes": 60,
"status": "confirmed",
"notes": "Root canal procedure",
"created_at": "2024-03-02T14:30:00Z"
}
]
}
Create Appointment
To create an appointment, use the patient-specific endpoint:
curl -X POST "https://your-domain.com/api/patients/1/appointments" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{
"doctor_id": 2,
"branch_id": 1,
"appointment_date": "2024-03-20",
"appointment_time": "10:00",
"duration_minutes": 30,
"notes": "Regular checkup"
}'
See the Patients API for full details.
Update Appointment Status
curl -X PATCH "https://your-domain.com/api/appointments/10" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{
"status": "confirmed"
}'
Update the status of an appointment.
New status for the appointmentValid values:
scheduled - Appointment is scheduled
confirmed - Patient confirmed attendance
completed - Appointment was completed
cancelled - Appointment was cancelled
no_show - Patient did not show up
{
"success": true,
"message": "Estado actualizado"
}
Update Appointment Details
curl -X PUT "https://your-domain.com/api/appointments/10" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{
"doctor_id": 2,
"branch_id": 1,
"appointment_date": "2024-03-21",
"appointment_time": "14:00",
"notes": "Rescheduled by patient request"
}'
Update appointment details including date, time, doctor, and branch.
New date in YYYY-MM-DD format
Additional notes or reason for change
{
"success": true,
"message": "Cita actualizada correctamente"
}
Common Use Cases
Daily Schedule View
Get all appointments for today:
curl -X GET "https://your-domain.com/api/appointments" \
-H "Cookie: session=your-session-token"
Doctor’s Schedule
Get appointments for a specific doctor:
curl -X GET "https://your-domain.com/api/appointments?doctor_id=2&date=2024-03-20" \
-H "Cookie: session=your-session-token"
Branch Schedule
Get all appointments at a specific branch:
curl -X GET "https://your-domain.com/api/appointments?branch_id=1&date=2024-03-20" \
-H "Cookie: session=your-session-token"
Confirm Patient Attendance
curl -X PATCH "https://your-domain.com/api/appointments/10" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{"status": "confirmed"}'
Mark as Completed
curl -X PATCH "https://your-domain.com/api/appointments/10" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{"status": "completed"}'
Error Responses
{
"message": "No autorizado"
}
Source Reference
API implementation can be found in:
src/routes/api/appointments/+server.js - List appointments
src/routes/api/appointments/[id]/+server.js - Update appointment status and details
src/routes/api/patients/[id]/appointments/+server.js - Patient-specific appointment operations