http://localhost:3000/api
All API endpoints require authentication using a Bearer token from Clerk. Include the token in the Authorization header:
Authorization: Bearer <your_token>
Get available appointment slots for a specific doctor.
Endpoint: GET /appointments/available-slots/:doctorId
Parameters:
doctorId(path parameter): The ID of the doctordate(query parameter): The date for which to get available slots (format: YYYY-MM-DD)
Example Request:
GET /api/appointments/available-slots/123?date=2024-03-20Response:
[
{
"start": "2024-03-20T09:00:00.000Z",
"end": "2024-03-20T09:30:00.000Z"
},
{
"start": "2024-03-20T10:00:00.000Z",
"end": "2024-03-20T10:30:00.000Z"
}
]Create a new appointment.
Endpoint: POST /appointments
Request Body:
{
"doctorId": "string",
"patientName": "string",
"patientPhone": "string",
"startTime": "2024-03-20T09:00:00.000Z",
"endTime": "2024-03-20T09:30:00.000Z",
"notes": "string" // optional
}Response:
{
"_id": "string",
"doctorId": "string",
"patientName": "string",
"patientPhone": "string",
"startTime": "2024-03-20T09:00:00.000Z",
"endTime": "2024-03-20T09:30:00.000Z",
"status": "scheduled",
"notes": "string",
"createdAt": "2024-03-20T09:00:00.000Z",
"updatedAt": "2024-03-20T09:00:00.000Z"
}Get all appointments for a specific doctor with optional filtering.
Endpoint: GET /appointments/doctor/:doctorId
Parameters:
doctorId(path parameter): The ID of the doctorstatus(query parameter, optional): Filter by appointment status ('scheduled', 'cancelled', 'completed')date(query parameter, optional): Filter by date (format: YYYY-MM-DD)
Example Request:
GET /api/appointments/doctor/123?status=scheduled&date=2024-03-20Response:
[
{
"_id": "string",
"doctorId": "string",
"patientName": "string",
"patientPhone": "string",
"startTime": "2024-03-20T09:00:00.000Z",
"endTime": "2024-03-20T09:30:00.000Z",
"status": "scheduled",
"notes": "string",
"createdAt": "2024-03-20T09:00:00.000Z",
"updatedAt": "2024-03-20T09:00:00.000Z"
}
]Update the status of an appointment.
Endpoint: PATCH /appointments/:appointmentId
Parameters:
appointmentId(path parameter): The ID of the appointment
Request Body:
{
"status": "completed" // or "cancelled"
}Response:
{
"_id": "string",
"doctorId": "string",
"patientName": "string",
"patientPhone": "string",
"startTime": "2024-03-20T09:00:00.000Z",
"endTime": "2024-03-20T09:30:00.000Z",
"status": "completed",
"notes": "string",
"createdAt": "2024-03-20T09:00:00.000Z",
"updatedAt": "2024-03-20T09:00:00.000Z"
}Cancel an existing appointment.
Endpoint: DELETE /appointments/:appointmentId
Parameters:
appointmentId(path parameter): The ID of the appointment
Response:
{
"message": "Appointment cancelled successfully"
}400 Bad Request:
{
"error": "Time slot is not available"
}401 Unauthorized:
{
"error": "Unauthorized"
}404 Not Found:
{
"error": "Doctor not found"
}or
{
"error": "Appointment not found"
}500 Internal Server Error:
{
"error": "Failed to create appointment"
}- Available slots are generated in 30-minute intervals
- Slots are only available during doctor's working hours (default: 9 AM to 5 PM)
- Past time slots are not available for booking
- Each slot can only be booked once
- All times are in UTC timezone
- Authentication is handled through Clerk
- The system integrates with Google Calendar for appointment management