Appointment APIs
This document covers all appointment-related endpoints for booking, managing, and tracking patient appointments.
Authentication
All appointment endpoints require authentication. Include the JWT token in the Authorization header:
Authorization: Bearer YOUR_AUTH_TOKENBase URL
/appointmentsEndpoints Overview
| Method | Endpoint | Description |
|---|---|---|
| GET | /appointments | List appointments with filtering |
| POST | /appointments | Create new appointment |
| GET | /appointments/:id | Get appointment details |
| PUT | /appointments/:id | Update appointment |
| DELETE | /appointments/:id | Cancel appointment |
| POST | /appointments/:id/check_in | Check in patient |
| POST | /appointments/:id/start_consultation | Start consultation |
| POST | /appointments/:id/complete | Complete appointment |
| GET | /appointments/slots | Get available time slots |
| GET | /appointments/today | Today's appointments |
| GET | /appointments/upcoming | Upcoming appointments |
List Appointments
GET /appointments
Retrieve appointments with optional filtering and pagination.
Query Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
page | Integer | Page number (default: 1) | 1 |
per_page | Integer | Items per page (default: 20) | 20 |
date | String | Filter by appointment date | 2025-01-15 |
doctor_id | Integer | Filter by doctor | 123 |
patient_id | Integer | Filter by patient | 456 |
status | String | Filter by status | scheduled |
start_date | String | Date range start | 2025-01-01 |
end_date | String | Date range end | 2025-01-31 |
Status Values
scheduled- Appointment bookedconfirmed- Patient confirmedchecked_in- Patient arrivedin_progress- Consultation startedcompleted- Consultation finishedcancelled- Appointment cancelledno_show- Patient didn't arrive
Example Request
curl -X GET "http://localhost:3000/appointments?date=2025-01-15&status=scheduled" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN"Example Response
{
"success": true,
"data": [
{
"id": 123,
"appointment_date": "2025-01-15",
"appointment_time": "10:00",
"duration": 30,
"status": "scheduled",
"reason": "Regular checkup",
"notes": "Patient reports mild headaches",
"patient": {
"id": 456,
"first_name": "John",
"last_name": "Doe",
"phone_number": "9999999999",
"age": 35
},
"doctor": {
"id": 789,
"first_name": "Dr. Sarah",
"last_name": "Smith",
"speciality": "General Physician",
"consultation_fee": 500
},
"clinic": {
"id": 101,
"name": "City Health Clinic"
},
"created_at": "2025-01-10T08:30:00Z",
"updated_at": "2025-01-12T14:20:00Z"
}
],
"meta": {
"page": 1,
"per_page": 20,
"total": 45,
"total_pages": 3
}
}Create Appointment
POST /appointments
Book a new appointment for a patient.
Request Body
{
"appointment": {
"clinic_patient_id": 456,
"clinic_doctor_id": 789,
"appointment_date": "2025-01-15",
"appointment_time": "10:00",
"duration": 30,
"reason": "Regular checkup",
"notes": "Patient reports mild headaches",
"appointment_type": "consultation",
"booking_source": "online"
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
clinic_patient_id | Integer | Yes | Patient ID |
clinic_doctor_id | Integer | Yes | Doctor ID |
appointment_date | String | Yes | Appointment date (YYYY-MM-DD) |
appointment_time | String | Yes | Appointment time (HH:MM) |
duration | Integer | No | Duration in minutes (default: 30) |
reason | String | No | Reason for visit |
notes | String | No | Additional notes |
appointment_type | String | No | Type of appointment |
booking_source | String | No | How appointment was booked |
Appointment Types
consultation- Regular consultationfollow_up- Follow-up visitemergency- Emergency appointmentteleconsultation- Video consultationprocedure- Medical procedure
Booking Sources
online- Web/mobile appphone- Phone bookingwalk_in- Walk-in patientreferral- Referred by another doctor
Example Request
curl -X POST http://localhost:3000/appointments \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"appointment": {
"clinic_patient_id": 456,
"clinic_doctor_id": 789,
"appointment_date": "2025-01-15",
"appointment_time": "10:00",
"reason": "Regular checkup"
}
}'Success Response (201 Created)
{
"success": true,
"data": {
"id": 123,
"appointment_date": "2025-01-15",
"appointment_time": "10:00",
"status": "scheduled",
"appointment_number": "APT001234",
"confirmation_code": "ABC123",
// ... complete appointment data
},
"message": "Appointment booked successfully"
}Error Response (422 Unprocessable Entity)
{
"success": false,
"error": "Appointment could not be created",
"errors": {
"appointment_time": ["is not available"],
"clinic_doctor_id": ["doctor is not available on this date"]
}
}Get Appointment Details
GET /appointments/:id
Get detailed information about a specific appointment.
Example Request
curl -X GET http://localhost:3000/appointments/123 \
-H "Authorization: Bearer YOUR_AUTH_TOKEN"Success Response
{
"success": true,
"data": {
"id": 123,
"appointment_date": "2025-01-15",
"appointment_time": "10:00",
"duration": 30,
"status": "scheduled",
"reason": "Regular checkup",
"notes": "Patient reports mild headaches",
"appointment_type": "consultation",
"appointment_number": "APT001234",
"confirmation_code": "ABC123",
"patient": {
"id": 456,
"first_name": "John",
"last_name": "Doe",
"phone_number": "9999999999",
"email": "john.doe@email.com",
"age": 35,
"gender": "M",
"blood_group": "O+",
"allergies": ["Penicillin"],
"medical_history": "Hypertension, Diabetes Type 2"
},
"doctor": {
"id": 789,
"first_name": "Dr. Sarah",
"last_name": "Smith",
"speciality": "General Physician",
"qualification": "MBBS, MD",
"consultation_fee": 500,
"experience_years": 8
},
"clinic": {
"id": 101,
"name": "City Health Clinic",
"address": "123 Main St, Mumbai",
"phone_number": "9888888888"
},
"vitals": {
"weight": 70,
"height": 175,
"bp_systolic": 120,
"bp_diastolic": 80,
"pulse": 72,
"temperature": 98.6
},
"prescriptions": [],
"invoices": [],
"created_at": "2025-01-10T08:30:00Z",
"updated_at": "2025-01-12T14:20:00Z"
}
}Update Appointment
PUT /appointments/:id
Update appointment details.
Request Body
{
"appointment": {
"appointment_date": "2025-01-16",
"appointment_time": "11:00",
"reason": "Follow-up checkup",
"notes": "Updated notes",
"status": "confirmed"
}
}Example Request
curl -X PUT http://localhost:3000/appointments/123 \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"appointment": {
"appointment_time": "11:00",
"status": "confirmed"
}
}'Cancel Appointment
DELETE /appointments/:id
Cancel an existing appointment.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
reason | String | Cancellation reason |
Example Request
curl -X DELETE "http://localhost:3000/appointments/123?reason=Patient%20rescheduled" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN"Success Response
{
"success": true,
"message": "Appointment cancelled successfully"
}Check In Patient
POST /appointments/:id/check_in
Mark patient as checked in when they arrive.
Request Body
{
"check_in_time": "2025-01-15T09:55:00Z",
"vitals": {
"weight": 70,
"height": 175,
"bp_systolic": 120,
"bp_diastolic": 80,
"pulse": 72,
"temperature": 98.6
}
}Example Request
curl -X POST http://localhost:3000/appointments/123/check_in \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"vitals": {
"weight": 70,
"bp_systolic": 120,
"bp_diastolic": 80
}
}'Start Consultation
POST /appointments/:id/start_consultation
Mark consultation as started.
Example Request
curl -X POST http://localhost:3000/appointments/123/start_consultation \
-H "Authorization: Bearer YOUR_AUTH_TOKEN"Success Response
{
"success": true,
"data": {
"id": 123,
"status": "in_progress",
"consultation_started_at": "2025-01-15T10:05:00Z"
},
"message": "Consultation started"
}Complete Appointment
POST /appointments/:id/complete
Mark appointment as completed with diagnosis and prescription.
Request Body
{
"diagnosis": "Common cold with mild fever",
"treatment_notes": "Prescribed antibiotics and rest",
"next_visit_date": "2025-01-22",
"prescriptions": [
{
"medicine_name": "Paracetamol",
"dosage": "500mg",
"frequency": "Twice daily",
"duration": "5 days",
"instructions": "Take after meals"
}
],
"investigations": [
{
"test_name": "Complete Blood Count",
"notes": "Routine check"
}
]
}Example Request
curl -X POST http://localhost:3000/appointments/123/complete \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"diagnosis": "Common cold",
"treatment_notes": "Rest and medication"
}'Get Available Slots
GET /appointments/slots
Get available appointment slots for a specific doctor and date.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
doctor_id | Integer | Yes | Doctor ID |
date | String | Yes | Date (YYYY-MM-DD) |
duration | Integer | No | Appointment duration in minutes |
Example Request
curl -X GET "http://localhost:3000/appointments/slots?doctor_id=789&date=2025-01-15" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN"Success Response
{
"success": true,
"data": {
"date": "2025-01-15",
"doctor": {
"id": 789,
"name": "Dr. Sarah Smith",
"speciality": "General Physician"
},
"available_slots": [
{
"time": "09:00",
"available": true
},
{
"time": "09:30",
"available": true
},
{
"time": "10:00",
"available": false,
"reason": "Already booked"
},
{
"time": "10:30",
"available": true
}
],
"total_slots": 16,
"available_count": 12,
"booked_count": 4
}
}Today's Appointments
GET /appointments/today
Get all appointments for today.
Example Request
curl -X GET http://localhost:3000/appointments/today \
-H "Authorization: Bearer YOUR_AUTH_TOKEN"Upcoming Appointments
GET /appointments/upcoming
Get upcoming appointments (next 7 days by default).
Query Parameters
| Parameter | Type | Description |
|---|---|---|
days | Integer | Number of days ahead (default: 7) |
Example Request
curl -X GET "http://localhost:3000/appointments/upcoming?days=14" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN"Appointment Status Transitions
Valid status transitions:
scheduled → confirmed → checked_in → in_progress → completed
↓ ↓ ↓ ↓
cancelled cancelled cancelled cancelled
↓ ↓ ↓
no_show no_show no_showError Codes
| Code | Description |
|---|---|
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid or missing token |
| 403 | Forbidden - No permission to access appointment |
| 404 | Not Found - Appointment doesn't exist |
| 422 | Unprocessable Entity - Validation errors |
| 409 | Conflict - Time slot not available |
Common Error Messages
{
"success": false,
"error": "Time slot not available",
"errors": {
"appointment_time": ["Doctor is not available at this time"]
}
}{
"success": false,
"error": "Patient not found",
"details": "No patient found with ID 456 in your clinic"
}{
"success": false,
"error": "Invalid status transition",
"details": "Cannot change status from 'completed' to 'scheduled'"
}Webhooks
The system can send webhooks for appointment events:
Events
appointment.createdappointment.updatedappointment.cancelledappointment.checked_inappointment.completed
Webhook Payload Example
{
"event": "appointment.created",
"data": {
"appointment_id": 123,
"patient_id": 456,
"doctor_id": 789,
"clinic_id": 101,
"appointment_date": "2025-01-15",
"appointment_time": "10:00"
},
"timestamp": "2025-01-10T08:30:00Z"
}Related Endpoints
- Patient APIs - Managing patient records
- Doctor APIs - Doctor schedules and availability
- Clinic APIs - Clinic settings and configuration