📡 API Reference

REST API for clinic and patient operations. All endpoints require session cookie via /login. Content-Type: application/json.

Authentication

Sessions are HTTP-only cookies set by SSO at auth.melyx.id. After login, cookies are scoped to .carelyx.app.

GET/login — redirect to SSO
GET/logout — full SSO logout
GET/auth/callback?token=<jwt> — SSO landing

Clinic

GET/api/clinic/me — current user's clinic
POST/api/clinic — create clinic
{"name":"My Clinic","timezone":"Europe/Dublin"}
GET/api/clinic/:id/stats — patient/appointment counts
GET/api/clinic/:id/members — staff list
POST/api/clinic/:id/members — invite
DELETE/api/clinic/:id/member/:memberId
GET/api/clinic/:id/outcomes — aggregate outcomes (Phase 3)
GET/api/clinic/:id/symptom-alerts — high-severity alerts (Phase 3)

Patients

GET/api/patients — list patients
GET/api/patient/:id — patient detail
DELETE/api/patient/:id
GET/api/patients/export.csv — CSV export
POST/api/import/execute — bulk import patients

Appointments

GET/api/appointments?date=YYYY-MM-DD
POST/api/appointments
{"patient_id":1,"type":"chemo","scheduled_at":"2026-05-01T10:00:00"}
DELETE/api/appointment/:id

Treatments & Notes

GET/api/treatments/:patientId
GET/api/notes/:patientId
GET/api/timeline/:patientId — chronological events (Phase 2)

Patient self-tracking (/p)

GET/api/p/me
GET/api/p/logs
GET/api/p/prescriptions
GET/api/p/today-doses
GET/api/p/cycles

News / Blog

GET/api/articles/:slug
GET/api/articles/:slug/ai
POST/api/news/receive — HMAC-signed webhook (internal)

Health

GET/api/health
{"ok":true,"ts":1745700000000}