Appointments API

Endpoints for managing tutoring sessions (appointments). Appointments are the core transactional records in NIVAA, representing scheduled sessions between tutors and students.

GET /api/appointments All authenticated roles

List appointments visible to the current user. Results are scoped by role: Admin sees all, Tutor sees their matches only, Parent sees their children only.

ParameterTypeDescription
datestringFilter by date (YYYY-MM-DD)
statusstringFilter by lowercase status (e.g., scheduled, approved)
match_idnumberFilter by match ID
pagenumberPage number (default: 1)
limitnumberResults per page (default: 20, max: 100)
Response
{
  "ok": true,
  "data": {
    "appointments": [
      {
        "id": 42,
        "match_id": 10,
        "date": "2026-03-27",
        "start_time": "09:00",
        "end_time": "10:00",
        "status": "scheduled",
        "checked_in_at": null,
        "checked_out_at": null,
        "tutor_notes": null,
        "billed_as_addon": 0,
        "child_name": "Emily Chen",
        "tutor_name": "Alex Tan",
        "created_at": "2026-03-20T10:00:00Z",
        "updated_at": "2026-03-20T10:00:00Z"
      }
    ],
    "total": 48,
    "page": 1,
    "limit": 20
  }
}
POST /api/appointments admin

Create a new appointment.

ParameterTypeDescription
match_idnumberMatch ID linking tutor to student
datestringSession date (YYYY-MM-DD)
start_timestringStart time (HH:MM)
end_timestringEnd time (HH:MM)
Response
{
  "ok": true,
  "data": { "id": 43, ... }
}
PATCH /api/appointments/:id/status Role-dependent

Update the status of an appointment. Machine status values are lowercase. Available transitions depend on the current status and the caller's role.

ParameterTypeDescription
statusstringNew status value
Response
{
  "ok": true,
  "data": { "status": "approved" }
}

Allowed Transitions

From StatusTo StatusWho
scheduledcancelled_by_tutorTutor, Admin
awaiting_approval_parentapprovedParent after tutor check-in/out; Admin via verify with reason
awaiting_approval_parentdisputedParent, Admin
disputedapprovedadmin via verify with reason
POST /api/appointments/:id/checkin Tutor, Admin

Check in to a session. Enforces the 30-minute time window.

Response
{
  "ok": true,
  "data": {
    "checked_in_at": "2026-03-27T08:35:00Z"
  }
}
POST /api/appointments/:id/checkout Tutor, Admin

Check out of a session. Sets status to awaiting_approval_parent and implicitly confirms the tutor side.

Response
{
  "ok": true,
  "data": {
    "checked_out_at": "2026-03-27T10:05:00Z",
    "status": "awaiting_approval_parent"
  }
}

Appointment Statuses

scheduled On the calendar, not yet started
checked_in Tutor has checked in, session in progress
awaiting_approval_parent Tutor checked out, waiting for parent acknowledgement
approved Parent acknowledged the checked-out session
disputed Parent flagged an issue
cancelled_by_tutor Tutor cancelled before session started