{"openapi":"3.1.0","info":{"title":"Clinic AI Enterprise OS Automations","version":"0.1.0"},"paths":{"/clinical-task":{"post":{"summary":"Clinical Task","operationId":"clinical_task_clinical_task_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_clinical_task_clinical_task_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/generate-draft":{"get":{"summary":"Generate Draft","operationId":"generate_draft_generate_draft_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"task","in":"query","required":false,"schema":{"type":"string","default":"Draft welcome email for new IVF patient","title":"Task"}},{"name":"pod","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Pod"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reject":{"post":{"summary":"Reject Task","operationId":"reject_task_reject_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/approve":{"post":{"summary":"Approve Task","operationId":"approve_task_approve_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/build-calendar":{"post":{"summary":"Build Calendar","description":"Generates a print-ready HTML calendar from the medication table,\nstores it in Supabase, and returns a public URL the patient can open.\nn8n injects the URL into the patient email as a button.","operationId":"build_calendar_build_calendar_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalendarRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/upload-clinic-logo":{"post":{"summary":"Upload Clinic Logo","description":"Upload a clinic logo image to the GCS public assets bucket and return the\npublic URL.\n\nAuthorization is enforced HERE (server-side), not on the frontend: the\ncaller must be either a platform admin OR a member of the clinic identified\nby clinic_slug. The slug is validated to prevent object-path traversal, and\nthe upload is constrained to a small set of image types and a size cap\n(HIPAA §164.312(a)(1)).","operationId":"upload_clinic_logo_upload_clinic_logo_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_clinic_logo_upload_clinic_logo_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/calendar/{calendar_id}":{"get":{"summary":"Serve Calendar","description":"Serves the print-ready patient calendar (HIPAA F-04).\n\nAccess is gated by a signed, expiring token in the `?t=` query param\n(see backend/services/calendar_tokens.py) — the patient still opens the link\nwithout logging in, but the link now proves authenticity and has a TTL.\n\nRollout: when CALENDAR_LINK_ENFORCE is False (grace), tokenless/expired links\nare STILL served so previously-emailed links keep working, but every access\nis logged with its auth outcome. Flip CALENDAR_LINK_ENFORCE=True to hard-block\nonce old tokenless links have aged out.\n\nReads with the SERVICE-ROLE key (calendar_files has RLS enabled, migration\n009) so the public link survives RLS while anon-key enumeration stays blocked.","operationId":"serve_calendar_calendar__calendar_id__get","parameters":[{"name":"calendar_id","in":"path","required":true,"schema":{"type":"string","title":"Calendar Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"summary":"Update Calendar","description":"Saves nurse/doctor edits to the printable treatment calendar, made in the\nreview UI before the task is approved and sent.\n\nEnforces clinic ownership (F-06): as of migration 009 calendar_files carries\na clinic_id, so a caller can only edit a calendar belonging to their own\nclinic (platform admins excepted). This closes the previous cross-tenant IDOR.","operationId":"update_calendar_calendar__calendar_id__patch","security":[{"HTTPBearer":[]}],"parameters":[{"name":"calendar_id","in":"path","required":true,"schema":{"type":"string","title":"Calendar Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalendarUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/clinic-data/delete-patient":{"post":{"summary":"Delete Patient Data Endpoint","description":"Right-to-erasure (HIPAA F-11): permanently deletes one patient's protocol\nartifacts (execution_logs drafts + their calendar_files) within the caller's\nOWN clinic. Clinic-scoped via the authenticated user's clinic_id, so a clinic\ncan never erase another clinic's data. The deletion is audited (opaque — the\npatient identity being erased is never written to the audit log).","operationId":"delete_patient_data_endpoint_clinic_data_delete_patient_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatientDeletionRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/execution-logs":{"get":{"summary":"List Execution Logs","operationId":"list_execution_logs_execution_logs_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","default":0,"title":"Offset"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/execution-logs/{thread_id}":{"get":{"summary":"Get Execution Log","operationId":"get_execution_log_execution_logs__thread_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"thread_id","in":"path","required":true,"schema":{"type":"string","title":"Thread Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/execution-logs/{thread_id}/hold":{"patch":{"summary":"Hold Execution Log","operationId":"hold_execution_log_execution_logs__thread_id__hold_patch","security":[{"HTTPBearer":[]}],"parameters":[{"name":"thread_id","in":"path","required":true,"schema":{"type":"string","title":"Thread Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HoldRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/execution-logs/{thread_id}/unhold":{"patch":{"summary":"Unhold Execution Log","operationId":"unhold_execution_log_execution_logs__thread_id__unhold_patch","security":[{"HTTPBearer":[]}],"parameters":[{"name":"thread_id","in":"path","required":true,"schema":{"type":"string","title":"Thread Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/media-status/{thread_id}":{"get":{"summary":"Media Status","operationId":"media_status_media_status__thread_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"thread_id","in":"path","required":true,"schema":{"type":"string","title":"Thread Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/media-video/{thread_id}":{"get":{"summary":"Media Video","operationId":"media_video_media_video__thread_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"thread_id","in":"path","required":true,"schema":{"type":"string","title":"Thread Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"ApprovalRequest":{"properties":{"task":{"type":"string","title":"Task"},"draft_text":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Draft Text"},"thread_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Thread Id"}},"type":"object","required":["task"],"title":"ApprovalRequest"},"Body_clinical_task_clinical_task_post":{"properties":{"patient_file":{"type":"string","format":"binary","title":"Patient File"},"patient_email":{"type":"string","title":"Patient Email"},"task":{"type":"string","title":"Task","default":"Process patient file"}},"type":"object","required":["patient_file","patient_email"],"title":"Body_clinical_task_clinical_task_post"},"Body_upload_clinic_logo_upload_clinic_logo_post":{"properties":{"file":{"type":"string","format":"binary","title":"File"},"clinic_slug":{"type":"string","title":"Clinic Slug"}},"type":"object","required":["file","clinic_slug"],"title":"Body_upload_clinic_logo_upload_clinic_logo_post"},"CalendarRequest":{"properties":{"med_table_text":{"type":"string","title":"Med Table Text"},"patient_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Patient Name","default":"Patient"},"clinic_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Clinic Name","default":""},"clinic_logo_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Clinic Logo Url","default":""},"base_meds":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Base Meds"}},"type":"object","required":["med_table_text"],"title":"CalendarRequest"},"CalendarUpdateRequest":{"properties":{"html_content":{"type":"string","title":"Html Content"}},"type":"object","required":["html_content"],"title":"CalendarUpdateRequest"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"HoldRequest":{"properties":{"doctor_note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Doctor Note"}},"type":"object","title":"HoldRequest"},"PatientDeletionRequest":{"properties":{"patient_email":{"type":"string","title":"Patient Email"}},"type":"object","required":["patient_email"],"title":"PatientDeletionRequest"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}}}