{"openapi":"3.1.0","info":{"title":"Seyarkai BioPulse API","version":"0.1.0","description":"Continuous non-invasive tissue intelligence. Ingest multi-frequency bioimpedance sweeps; receive Cole-Cole parameters, fluid-compartment estimates, phase angle, and edema risk scoring. RESEARCH-GRADE — not a medical device.","contact":{"name":"Seyarkai","url":"https://seyarkai.com"},"license":{"name":"MIT"}},"servers":[{"url":"https://biopulse.seyarkai.com","description":"Production"},{"url":"http://localhost:8787","description":"Local wrangler dev"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","description":"API key as Bearer token (or x-api-key header)."},"AdminAuth":{"type":"http","scheme":"bearer","description":"ADMIN_TOKEN for /v1/admin/*."}},"schemas":{"SweepPoint":{"type":"object","required":["freqHz","resistance","reactance"],"properties":{"freqHz":{"type":"number","example":50000},"resistance":{"type":"number","description":"R, ohms","example":470.1},"reactance":{"type":"number","description":"Xc, ohms (negative = capacitive)","example":-58.9}}},"ReadingInput":{"type":"object","required":["deviceId","sweep"],"properties":{"deviceId":{"type":"string"},"sessionId":{"type":"string"},"t":{"description":"Epoch ms or ISO date; defaults to now","oneOf":[{"type":"number"},{"type":"string"}]},"sweep":{"type":"array","items":{"$ref":"#/components/schemas/SweepPoint"},"minItems":3},"covariates":{"type":"object","properties":{"skinTempC":{"type":"number"},"heartRate":{"type":"number"}}}}},"Assessment":{"type":"object","properties":{"r0":{"type":"number"},"rinf":{"type":"number"},"tau":{"type":"number"},"alpha":{"type":"number"},"fc":{"type":"number"},"fitRmse":{"type":"number"},"phaseAngle50k":{"type":"number"},"ecwL":{"type":"number"},"icwL":{"type":"number"},"tbwL":{"type":"number"},"ecwIcwRatio":{"type":"number"},"riskScore":{"type":"number"},"riskLevel":{"type":"string","enum":["low","moderate","high"]}}},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}}}}}},"paths":{"/health":{"get":{"summary":"Health check","security":[],"responses":{"200":{"description":"OK"}}}},"/v1/admin/orgs":{"post":{"summary":"Create an org and issue its first API key","security":[{"AdminAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"}}}}}},"responses":{"201":{"description":"Org + apiKey (shown once)"}}}},"/v1/devices":{"post":{"summary":"Register a device","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["externalId"],"properties":{"externalId":{"type":"string"},"sensorType":{"type":"string"},"site":{"type":"string"},"heightCm":{"type":"number"},"weightKg":{"type":"number"},"sex":{"type":"string"}}}}}},"responses":{"201":{"description":"Device"}}},"get":{"summary":"List devices","responses":{"200":{"description":"Devices"}}}},"/v1/devices/{id}":{"get":{"summary":"Get a device","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Device"},"404":{"description":"Not found"}}}},"/v1/sessions":{"post":{"summary":"Open a session","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["deviceId"],"properties":{"deviceId":{"type":"string"},"subjectRef":{"type":"string"},"meta":{"type":"object"}}}}}},"responses":{"201":{"description":"Session"}}}},"/v1/sessions/{id}/close":{"post":{"summary":"Close a session","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Closed"}}}},"/v1/readings":{"post":{"summary":"Ingest a sweep (fits + assesses + alerts synchronously)","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadingInput"}}}},"responses":{"201":{"description":"readingId + assessment + alerts","content":{"application/json":{"schema":{"type":"object","properties":{"readingId":{"type":"string"},"assessment":{"$ref":"#/components/schemas/Assessment"},"alerts":{"type":"array"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"summary":"List readings","parameters":[{"name":"deviceId","in":"query","schema":{"type":"string"}},{"name":"sessionId","in":"query","schema":{"type":"string"}},{"name":"from","in":"query","schema":{"type":"number"}},{"name":"to","in":"query","schema":{"type":"number"}}],"responses":{"200":{"description":"Readings"}}}},"/v1/readings/batch":{"post":{"summary":"Ingest up to 200 sweeps","responses":{"201":{"description":"Ingested"}}}},"/v1/assessments/{readingId}":{"get":{"summary":"Get the assessment for a reading","parameters":[{"name":"readingId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Assessment"},"404":{"description":"Not found"}}}},"/v1/trends":{"get":{"summary":"Metric trend for a device","parameters":[{"name":"deviceId","in":"query","required":true,"schema":{"type":"string"}},{"name":"metric","in":"query","schema":{"type":"string","enum":["phaseAngle","ecwIcwRatio","risk"]}},{"name":"from","in":"query","schema":{"type":"number"}},{"name":"to","in":"query","schema":{"type":"number"}}],"responses":{"200":{"description":"Trend points + slopePerDay"}}}},"/v1/alerts":{"get":{"summary":"List alerts","parameters":[{"name":"deviceId","in":"query","schema":{"type":"string"}},{"name":"status","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Alerts"}}}},"/v1/alerts/config":{"post":{"summary":"Create an alert threshold","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["metric","comparator","threshold"],"properties":{"deviceId":{"type":"string"},"metric":{"type":"string","enum":["risk","phaseAngle","ecwIcwRatio"]},"comparator":{"type":"string","enum":["gt","lt"]},"threshold":{"type":"number"},"severity":{"type":"string"}}}}}},"responses":{"201":{"description":"Config"}}}},"/v1/webhooks":{"post":{"summary":"Register a webhook (alert.created)","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string"}},"secret":{"type":"string"}}}}}},"responses":{"201":{"description":"Webhook + signing secret"}}},"get":{"summary":"List webhooks","responses":{"200":{"description":"Webhooks"}}}},"/v1/webhooks/{id}":{"delete":{"summary":"Delete a webhook","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"}}}}}}