{"openapi":"3.0.3","info":{"title":"Yezza Clinic API (external access)","version":"1.0.0","description":"Programmatic access to your clinic's services, appointments, queue, patients and clinical records.\n\n**Authentication is a single header:** `X-Api-Key: yzk_live_xxxxxxxx.<secret>` (from developer.yezza.com).\n\nYou never pass a clinic id/slug or a Yezza user token — the gateway scopes every call to your key's own clinic and calls Yezza on its behalf, once a clinic admin turns on **Enable API access** in the portal.\n\nDatetimes are ISO 8601 (`2026-05-10T14:00:00+08:00`); money is in cents (`5000` = RM 50.00). Rate limits + a monthly quota apply per clinic; `429` includes `Retry-After`."},"servers":[{"url":"https://developer.yezza.com"}],"security":[{"ApiKeyAuth":[]}],"tags":[{"name":"Services","description":"What your clinic offers and patients can book."},{"name":"Appointments","description":"Slot search, booking, reschedule, cancel, emails."},{"name":"Registrations","description":"Check-in queue and visit completion."},{"name":"Patients","description":"Records, medical record, visit history, custom data, documents."},{"name":"Vital signs","description":"Readings recorded against a consultation."},{"name":"Custom fields","description":"Define per-clinic custom patient fields."},{"name":"Relationships","description":"Family/guardian links between patients."},{"name":"Medications","description":"A patient's ongoing medications."}],"paths":{"/v1/services":{"get":{"summary":"List services","description":"Requires the `services:read` scope.","responses":{"200":{"description":"Paginated services (name, cost in cents, duration, providers)"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Services"],"parameters":[{"name":"categorized","in":"query","description":"false = only uncategorised","schema":{"type":"string"}},{"name":"search","in":"query","description":"","schema":{"type":"string"}},{"name":"ordering","in":"query","description":"","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer"}},{"name":"offset","in":"query","schema":{"type":"integer"}}]}},"/v1/services/{id}":{"get":{"summary":"Retrieve a service","description":"Requires the `services:read` scope.","responses":{"200":{"description":"Full service incl. providers, preliminary_questions, durations, instructions"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Services"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}},"/v1/appointments":{"get":{"summary":"List appointments","description":"Requires the `appointments:read` scope.","responses":{"200":{"description":"A page of appointments"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Appointments"],"parameters":[{"name":"span","in":"query","description":"day | week | month | year (centred on today)","schema":{"type":"string"}},{"name":"from","in":"query","description":"","schema":{"type":"string"}},{"name":"until","in":"query","description":"","schema":{"type":"string"}},{"name":"date","in":"query","description":"","schema":{"type":"string"}},{"name":"date__gte","in":"query","description":"","schema":{"type":"string"}},{"name":"date__lte","in":"query","description":"","schema":{"type":"string"}},{"name":"time","in":"query","description":"","schema":{"type":"string"}},{"name":"time__gte","in":"query","description":"","schema":{"type":"string"}},{"name":"time__lte","in":"query","description":"","schema":{"type":"string"}},{"name":"statuses","in":"query","description":"Comma-separated lead statuses, e.g. new,processed","schema":{"type":"string"}},{"name":"search","in":"query","description":"","schema":{"type":"string"}},{"name":"ordering","in":"query","description":"","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer"}},{"name":"offset","in":"query","schema":{"type":"integer"}}]},"post":{"summary":"Create an appointment (book)","description":"Requires the `appointments:write` scope.","responses":{"201":{"description":"The booked appointment"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"400":{"description":"Validation / slot clash (human-readable)","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Appointments"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["date","time","provider","service"],"properties":{"date":{"type":"string","format":"date","description":"YYYY-MM-DD"},"time":{"type":"string","example":"10:30:00","description":"HH:MM:SS (seconds required — '10:30' is rejected). `until` is computed from the service duration."},"provider":{"type":"integer","description":"Provider id (from service.providers)"},"service":{"type":"integer","description":"Service id (singular; not product id)"},"patient":{"type":"integer","description":"Existing patient id (use this OR lead)"},"lead":{"type":"object","description":"New person (auto-creates a patient). name + phone + ic required.","properties":{"name":{"type":"string"},"phone":{"type":"string"},"ic":{"type":"string"},"email":{"type":"string"},"status":{"type":"string"},"remarks":{"type":"string"}}},"preliminary_questions":{"type":"array","items":{"type":"object","properties":{"question_id":{"type":"integer"},"answer":{"type":"string"}}}},"ignore_rules":{"type":"array","items":{"type":"string"}}}}}}}}},"/v1/appointments/{id}":{"get":{"summary":"Retrieve an appointment","description":"Requires the `appointments:read` scope.","responses":{"200":{"description":"The appointment"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Appointments"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},{"name":"pid","in":"query","description":"Set true to look up by lead pid instead of id","schema":{"type":"boolean"}}]},"patch":{"summary":"Update / reschedule / cancel","description":"To reschedule, send a new `start`. To cancel, send `status: cancelled` (+ optional `cancelled_reason`).\n\nRequires the `appointments:write` scope.","responses":{"200":{"description":"Updated"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Appointments"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Send only changed fields.","properties":{"start":{"type":"string","description":"New slot datetime — this is how you RESCHEDULE. date/time not accepted on update."},"provider":{"type":"integer"},"service":{"type":"integer"},"lead":{"type":"object","description":"Edit lead details (name, phone, email, ic, address, remarks)."},"status":{"type":"string","enum":["new","pending","request","processed","received","reject","absent","cancelled","deleted"]},"remarks":{"type":"string"},"cancelled_reason":{"type":"string","description":"Persists only with status=cancelled"},"ignore_rules":{"type":"array","items":{"type":"string"}}}}}}}}},"/v1/appointments/{id}/reschedule":{"patch":{"summary":"Reschedule (move slot)","description":"Requires the `appointments:write` scope.","responses":{"200":{"description":"Moved to the new slot"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"400":{"description":"Slot clash / prep-time / schedule violation","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Appointments"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["start"],"properties":{"start":{"type":"string","description":"New slot datetime, e.g. '2026-05-11 15:00'. Writes a reschedule audit entry."},"provider":{"type":"integer","description":"Defaults to the current provider if omitted."},"services":{"type":"array","items":{"type":"integer"},"description":"Service ids (array/plural on this endpoint)."},"ignore_rules":{"type":"array","items":{"type":"string"}}}}}}}}},"/v1/appointments/recur_slots":{"post":{"summary":"Find available slots","description":"Times when the selected services can be performed back-to-back for a provider.\n\nRequires the `appointments:read` scope.","responses":{"200":{"description":"{ options: [{time, dates}] } or { times: [...] } for a single date"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Appointments"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["provider","services"],"properties":{"provider":{"type":"integer"},"services":{"type":"array","items":{"type":"integer"}},"date":{"type":"string","format":"date","description":"Single date → response collapses to { times: [...] }"},"dates":{"type":"array","items":{"type":"string","format":"date"}},"frequency":{"type":"string","enum":["daily","weekly","monthly"]},"count":{"type":"integer"}}}}}}}},"/v1/appointments/combo_slots":{"post":{"summary":"Find combo slots (multi-provider)","description":"Chained sessions across different providers on the same day.\n\nRequires the `appointments:read` scope.","responses":{"200":{"description":"{ total_min, options:[{time, services:[{id,name,time,flag}]}] }"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Appointments"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["date","sessions"],"properties":{"date":{"type":"string","format":"date"},"sessions":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"integer"},"services":{"type":"array","items":{"type":"integer"}}}}}}}}}}}},"/v1/appointments/{id}/send_email":{"post":{"summary":"Send a confirmation email","description":"Requires the `appointments:write` scope.","responses":{"200":{"description":"{ \"status\": \"sent\" }"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Appointments"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["type"],"properties":{"email":{"type":"string","format":"email","description":"Updates the lead's email if supplied."},"type":{"type":"string","enum":["appointment_confirmation","appointment_request","appointment_approved","appointment_rejected"]}}}}}}}},"/v1/registrations":{"get":{"summary":"List the queue","description":"Requires the `registrations:read` scope.","responses":{"200":{"description":"Queue with names, numbers, statuses, rooms"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Registrations"],"parameters":[{"name":"search","in":"query","description":"","schema":{"type":"string"}},{"name":"ordering","in":"query","description":"","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer"}},{"name":"offset","in":"query","schema":{"type":"integer"}}]},"post":{"summary":"Check a patient in","description":"Requires the `registrations:write` scope.","responses":{"201":{"description":"The registration"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Registrations"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"patient":{"type":"integer"},"provider":{"type":"integer"},"appointment":{"type":"integer"},"code":{"type":"integer"},"tagging":{"type":"string"}}}}}}}},"/v1/registrations/{lead_pid}":{"get":{"summary":"Retrieve a registration","description":"Requires the `registrations:read` scope.","responses":{"200":{"description":"The registration"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Registrations"],"parameters":[{"name":"lead_pid","in":"path","required":true,"schema":{"type":"string"},"description":"The lead's opaque public id (pid), not the numeric id."}]},"patch":{"summary":"Update a registration (call / move / complete)","description":"Advance the visit lifecycle: waiting → on_hold → serving → checkout → completed.\n\nRequires the `registrations:write` scope.","responses":{"200":{"description":"Updated"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Registrations"],"parameters":[{"name":"lead_pid","in":"path","required":true,"schema":{"type":"string"},"description":"The lead's opaque public id (pid), not the numeric id."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["waiting","on_hold","serving","checkout","completed"]},"seat":{"type":"integer"},"checkout_note":{"type":"string"}}}}}}},"delete":{"summary":"Remove a registration (soft-delete)","description":"Requires the `registrations:write` scope.","responses":{"204":{"description":"Removed"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Registrations"],"parameters":[{"name":"lead_pid","in":"path","required":true,"schema":{"type":"string"},"description":"The lead's opaque public id (pid), not the numeric id."}]}},"/v1/registrations/stats":{"get":{"summary":"Queue stats","description":"Requires the `registrations:read` scope.","responses":{"200":{"description":"{ stats: { all, waiting, on_hold, serving, checkout, completed } }"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Registrations"]}},"/v1/registrations/available_seats":{"get":{"summary":"Available seats/rooms","description":"Requires the `registrations:read` scope.","responses":{"200":{"description":"Rooms/seats not currently occupied"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Registrations"]}},"/v1/patients":{"get":{"summary":"List patients","description":"Requires the `patients:read` scope.","responses":{"200":{"description":"A page of patients"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"gender","in":"query","description":"male | female","schema":{"type":"string"}},{"name":"marital_status","in":"query","description":"married | single","schema":{"type":"string"}},{"name":"phone","in":"query","description":"","schema":{"type":"string"}},{"name":"ic","in":"query","description":"","schema":{"type":"string"}},{"name":"uid","in":"query","description":"","schema":{"type":"string"}},{"name":"total_visit","in":"query","description":"","schema":{"type":"integer"}},{"name":"total_visit__gte","in":"query","description":"","schema":{"type":"integer"}},{"name":"total_visit__lte","in":"query","description":"","schema":{"type":"integer"}},{"name":"panels","in":"query","description":"CSV panel ids","schema":{"type":"string"}},{"name":"services","in":"query","description":"CSV service ids","schema":{"type":"string"}},{"name":"medications","in":"query","description":"CSV medication ids","schema":{"type":"string"}},{"name":"diagnoses","in":"query","description":"CSV diagnosis keywords","schema":{"type":"string"}},{"name":"search","in":"query","description":"","schema":{"type":"string"}},{"name":"ordering","in":"query","description":"","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer"}},{"name":"offset","in":"query","schema":{"type":"integer"}}]},"post":{"summary":"Create a patient","description":"Requires the `patients:write` scope.","responses":{"201":{"description":"The patient"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"400":{"description":"UID required / already exists","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","phone"],"properties":{"name":{"type":"string"},"phone":{"type":"string","description":"Digits only, e.g. 60123456789"},"ic":{"type":"string","description":"The configured customer UID (usually IC)"},"email":{"type":"string","format":"email"},"gender":{"type":"string","enum":["male","female"]},"dob":{"type":"string","format":"date"},"age":{"type":"integer"},"nickname":{"type":"string"},"nationality":{"type":"string","default":"Malaysia"},"race":{"type":"string"},"religion":{"type":"string"},"occupation":{"type":"string"},"marital_status":{"type":"string","enum":["married","single"]},"staff_id":{"type":"string"},"address":{"type":"object","properties":{"address_1":{"type":"string"},"address_2":{"type":"string"},"postcode":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"country":{"type":"string","default":"Malaysia"}},"required":["address_1","postcode","city","state"]},"emergency_contact":{"type":"object","properties":{"name":{"type":"string"},"relationship":{"type":"string"},"phone":{"type":"string"}}},"panels":{"type":"array","items":{"type":"object","properties":{"panel":{"type":"integer"},"staff_id":{"type":"string"},"note":{"type":"string"}}}},"tagging":{"type":"array","items":{"type":"integer"}}}}}}}}},"/v1/patients/{id}":{"get":{"summary":"Retrieve a patient","description":"Requires the `patients:read` scope.","responses":{"200":{"description":"Full patient"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]},"patch":{"summary":"Update a patient","description":"Requires the `patients:write` scope.","responses":{"200":{"description":"Updated"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","phone"],"properties":{"name":{"type":"string"},"phone":{"type":"string","description":"Digits only, e.g. 60123456789"},"ic":{"type":"string","description":"The configured customer UID (usually IC)"},"email":{"type":"string","format":"email"},"gender":{"type":"string","enum":["male","female"]},"dob":{"type":"string","format":"date"},"age":{"type":"integer"},"nickname":{"type":"string"},"nationality":{"type":"string","default":"Malaysia"},"race":{"type":"string"},"religion":{"type":"string"},"occupation":{"type":"string"},"marital_status":{"type":"string","enum":["married","single"]},"staff_id":{"type":"string"},"address":{"type":"object","properties":{"address_1":{"type":"string"},"address_2":{"type":"string"},"postcode":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"country":{"type":"string","default":"Malaysia"}},"required":["address_1","postcode","city","state"]},"emergency_contact":{"type":"object","properties":{"name":{"type":"string"},"relationship":{"type":"string"},"phone":{"type":"string"}}},"panels":{"type":"array","items":{"type":"object","properties":{"panel":{"type":"integer"},"staff_id":{"type":"string"},"note":{"type":"string"}}}},"tagging":{"type":"array","items":{"type":"integer"}}}}}}}},"put":{"summary":"Replace a patient","description":"Requires the `patients:write` scope.","responses":{"200":{"description":"Replaced"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","phone"],"properties":{"name":{"type":"string"},"phone":{"type":"string","description":"Digits only, e.g. 60123456789"},"ic":{"type":"string","description":"The configured customer UID (usually IC)"},"email":{"type":"string","format":"email"},"gender":{"type":"string","enum":["male","female"]},"dob":{"type":"string","format":"date"},"age":{"type":"integer"},"nickname":{"type":"string"},"nationality":{"type":"string","default":"Malaysia"},"race":{"type":"string"},"religion":{"type":"string"},"occupation":{"type":"string"},"marital_status":{"type":"string","enum":["married","single"]},"staff_id":{"type":"string"},"address":{"type":"object","properties":{"address_1":{"type":"string"},"address_2":{"type":"string"},"postcode":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"country":{"type":"string","default":"Malaysia"}},"required":["address_1","postcode","city","state"]},"emergency_contact":{"type":"object","properties":{"name":{"type":"string"},"relationship":{"type":"string"},"phone":{"type":"string"}}},"panels":{"type":"array","items":{"type":"object","properties":{"panel":{"type":"integer"},"staff_id":{"type":"string"},"note":{"type":"string"}}}},"tagging":{"type":"array","items":{"type":"integer"}}}}}}}},"delete":{"summary":"Soft-delete a patient","description":"Requires the `patients:write` scope.","responses":{"204":{"description":"Deleted (deleted_at set)"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}},"/v1/patients/{id}/merge":{"post":{"summary":"Merge duplicate patients","description":"This patient becomes canonical; `merge_from` is folded in and soft-deleted.\n\nRequires the `patients:write` scope.","responses":{"200":{"description":"The canonical patient"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["merge_from"],"properties":{"merge_from":{"type":"integer","description":"The patient id to fold into this one (then soft-deleted)."},"name":{"type":"string"},"phone":{"type":"string"},"ic":{"type":"string"},"email":{"type":"string"},"dob":{"type":"string","format":"date"},"gender":{"type":"string","enum":["male","female"]}}}}}}}},"/v1/patients/{id}/record":{"get":{"summary":"Get medical record","description":"Requires the `patients:read` scope.","responses":{"200":{"description":"Allergies, conditions, panel"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]},"patch":{"summary":"Update medical record (merge)","description":"Requires the `patients:write` scope.","responses":{"200":{"description":"Updated"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"allergies":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"reaction":{"type":"string"}}}},"underlying_conditions":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"since":{"type":"string"}}}},"panel":{"type":"integer","nullable":true,"description":"Panel id, or null to clear. PATCH merges, PUT replaces."}}}}}}},"put":{"summary":"Replace medical record","description":"Requires the `patients:write` scope.","responses":{"200":{"description":"Replaced"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"allergies":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"reaction":{"type":"string"}}}},"underlying_conditions":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"since":{"type":"string"}}}},"panel":{"type":"integer","nullable":true,"description":"Panel id, or null to clear. PATCH merges, PUT replaces."}}}}}}}},"/v1/patients/{id}/histories":{"get":{"summary":"List visit history","description":"Consolidated timeline: appointment, provider, vital signs, consultation, treatments, invoice, payments.\n\nRequires the `patients:read` scope.","responses":{"200":{"description":"A page of visits"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"begin","in":"query","description":"","schema":{"type":"string"}},{"name":"until","in":"query","description":"","schema":{"type":"string"}},{"name":"past_months","in":"query","description":"","schema":{"type":"integer"}},{"name":"providers","in":"query","description":"CSV","schema":{"type":"string"}},{"name":"services","in":"query","description":"CSV","schema":{"type":"string"}},{"name":"medications","in":"query","description":"CSV","schema":{"type":"string"}},{"name":"diagnoses","in":"query","description":"CSV","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},{"name":"search","in":"query","description":"","schema":{"type":"string"}},{"name":"ordering","in":"query","description":"","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer"}},{"name":"offset","in":"query","schema":{"type":"integer"}}]}},"/v1/patients/{id}/histories/{lead_pid}":{"get":{"summary":"Retrieve one visit","description":"Requires the `patients:read` scope.","responses":{"200":{"description":"A single visit"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},{"name":"lead_pid","in":"path","required":true,"schema":{"type":"string"},"description":"The lead's opaque public id (pid), not the numeric id."}]}},"/v1/patients/{id}/vital_signs":{"get":{"summary":"List a patient's vital signs","description":"Requires the `patients:read` scope.","responses":{"200":{"description":"All readings for the patient"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}},"/v1/patients/{id}/custom_data":{"get":{"summary":"List custom data","description":"Requires the `patients:read` scope.","responses":{"200":{"description":"Custom field values"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]},"post":{"summary":"Upsert custom data","description":"Submit only the fields to set/update; others untouched.\n\nRequires the `patients:write` scope.","responses":{"200":{"description":"Updated custom data"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["custom_data"],"properties":{"custom_data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer","description":"Custom field id"},"datatype":{"type":"string","enum":["string","number","date","time","text","selection","phone","email","address"]},"value":{}}}}}}}}}}},"/v1/patients/{id}/documents":{"get":{"summary":"List generated documents","description":"Requires the `patients:read` scope.","responses":{"200":{"description":"e.g. medical certificates"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}},"/v1/patients/{id}/attachments":{"get":{"summary":"List consultation attachments","description":"Requires the `patients:read` scope.","responses":{"200":{"description":"Files uploaded during consultations"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Patients"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}},"/v1/consultations/{pid}/vital_signs":{"post":{"summary":"Record a vital sign","description":"Vital signs attach to a consultation (POSTing under /patients is 405).\n\nRequires the `consultations:write` scope.","responses":{"201":{"description":"The saved reading"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Vital signs"],"parameters":[{"name":"pid","in":"path","required":true,"schema":{"type":"string"},"description":"Consultation opaque public id."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"All fields optional — record what you measured.","properties":{"recorded_at":{"type":"string","format":"date-time"},"height":{"type":"number","description":"cm"},"weight":{"type":"number","description":"kg"},"bp_systolic":{"type":"integer","description":"mmHg"},"bp_diastolic":{"type":"integer","description":"mmHg"},"pulse":{"type":"integer","description":"bpm"},"temperature":{"type":"number","description":"°C"},"blood_glucose":{"type":"number","description":"mmol/L"},"spo2":{"type":"integer","description":"%"},"respiratory_rate":{"type":"integer","description":"breaths/min"}}}}}}}},"/v1/consultations/{pid}/vital_signs/{id}":{"patch":{"summary":"Edit a vital sign","description":"Requires the `consultations:write` scope.","responses":{"200":{"description":"Updated"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Vital signs"],"parameters":[{"name":"pid","in":"path","required":true,"schema":{"type":"string"},"description":"Consultation opaque public id."},{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"All fields optional — record what you measured.","properties":{"recorded_at":{"type":"string","format":"date-time"},"height":{"type":"number","description":"cm"},"weight":{"type":"number","description":"kg"},"bp_systolic":{"type":"integer","description":"mmHg"},"bp_diastolic":{"type":"integer","description":"mmHg"},"pulse":{"type":"integer","description":"bpm"},"temperature":{"type":"number","description":"°C"},"blood_glucose":{"type":"number","description":"mmol/L"},"spo2":{"type":"integer","description":"%"},"respiratory_rate":{"type":"integer","description":"breaths/min"}}}}}}},"delete":{"summary":"Delete a vital sign","description":"Requires the `consultations:write` scope.","responses":{"204":{"description":"Removed"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Vital signs"],"parameters":[{"name":"pid","in":"path","required":true,"schema":{"type":"string"},"description":"Consultation opaque public id."},{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}},"/v1/patient_custom_fields":{"get":{"summary":"List custom fields","description":"Requires the `patient_custom_fields:read` scope.","responses":{"200":{"description":"Defined fields"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Custom fields"]},"post":{"summary":"Create a custom field","description":"Requires the `patient_custom_fields:write` scope.","responses":{"201":{"description":"Created"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Custom fields"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["field_name","datatype"],"properties":{"field_name":{"type":"string"},"datatype":{"type":"string","enum":["string","number","date","time","text","selection","phone","email","address"]},"status":{"type":"string"},"order":{"type":"integer"},"extra_options":{"type":"object","description":"For 'selection': { choices: [...] }"}}}}}}}},"/v1/patient_custom_fields/{id}":{"patch":{"summary":"Edit a custom field","description":"Requires the `patient_custom_fields:write` scope.","responses":{"200":{"description":"Updated"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Custom fields"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["field_name","datatype"],"properties":{"field_name":{"type":"string"},"datatype":{"type":"string","enum":["string","number","date","time","text","selection","phone","email","address"]},"status":{"type":"string"},"order":{"type":"integer"},"extra_options":{"type":"object","description":"For 'selection': { choices: [...] }"}}}}}}},"delete":{"summary":"Delete a custom field","description":"Requires the `patient_custom_fields:write` scope.","responses":{"204":{"description":"Soft-deleted"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Custom fields"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}},"/v1/patient_relationships":{"get":{"summary":"List relationships","description":"Requires the `patient_relationships:read` scope.","responses":{"200":{"description":"Relationships for a patient"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Relationships"],"parameters":[{"name":"primary_person","in":"query","description":"Patient id","schema":{"type":"integer"}}]},"post":{"summary":"Create a relationship","description":"Requires the `patient_relationships:write` scope.","responses":{"201":{"description":"Created"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Relationships"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["primary_person","related_person","relationship"],"properties":{"primary_person":{"type":"integer"},"related_person":{"type":"integer"},"relationship":{"type":"integer","description":"Option id from GET /v1/relationship_options"}}}}}}}},"/v1/patient_relationships/{id}":{"delete":{"summary":"Remove a relationship","description":"Requires the `patient_relationships:write` scope.","responses":{"204":{"description":"Removed"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Relationships"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}},"/v1/relationship_options":{"get":{"summary":"List relationship options","description":"Requires the `relationship_options:read` scope.","responses":{"200":{"description":"Clinic-defined relationship types"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Relationships"]}},"/v1/active_medications":{"get":{"summary":"List active medications","description":"Requires the `active_medications:read` scope.","responses":{"200":{"description":"Medications a patient is currently taking"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Medications"],"parameters":[{"name":"patient","in":"query","description":"Patient id","schema":{"type":"integer"}}]},"post":{"summary":"Add an active medication","description":"Requires the `active_medications:write` scope.","responses":{"201":{"description":"Added"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Medications"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["patient","medication"],"properties":{"patient":{"type":"integer"},"medication":{"type":"integer"}}}}}}}},"/v1/active_medications/{id}":{"delete":{"summary":"Stop tracking a medication","description":"Requires the `active_medications:write` scope.","responses":{"204":{"description":"Removed"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"402":{"description":"Monthly quota exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"403":{"description":"Insufficient scope, inactive subscription, or the clinic hasn't authorized API access","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded — see Retry-After header","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}},"502":{"description":"Upstream unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"detail":{"type":"string"}}}}}}},"security":[{"ApiKeyAuth":[]}],"tags":["Medications"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}]}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-Api-Key","description":"Your clinic's gateway API key: yzk_live_xxxxxxxx.<secret>"}}}}