{"openapi":"3.1.0","info":{"title":"Cell Ledger lab API","version":"1.0.0","description":"Send clients, samples, custody events and tank readings from a lab's systems. Guide: https://cellledger.com/developers"},"servers":[{"url":"https://cellledger.com/api/v1"}],"components":{"securitySchemes":{"key":{"type":"http","scheme":"bearer","description":"A lab's API key (cvk_…), created in Settings → Connect your systems."}}},"security":[{"key":[]}],"paths":{"/samples":{"post":{"summary":"Create or update clients and samples","description":"Requires a key allowed to send clients and samples. Records are matched on clientRef and sampleCode, so sending a record again updates it. Up to 500 records per request.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["records"],"properties":{"records":{"type":"array","maxItems":500,"items":{"type":"object","required":["clientRef","fullName","sampleCode","cellType"],"properties":{"clientRef":{"type":"string","description":"Client number"},"fullName":{"type":"string","description":"Owner full name"},"email":{"type":"string","description":"Email"},"phone":{"type":"string","description":"Phone"},"country":{"type":"string","description":"Country of residence"},"preferredLanguage":{"type":"string","description":"Language"},"whatsappConsent":{"type":"string","description":"WhatsApp opt-in"},"whatsappMarketing":{"type":"string","description":"Offers & news opt-in"},"paidUntil":{"type":"string","description":"Paid until"},"outstandingAmount":{"type":"number","description":"Amount owed"},"sampleCode":{"type":"string","description":"Sample ID"},"cellType":{"type":"string","description":"Cell type"},"donorName":{"type":"string","description":"Donor name"},"collectedAt":{"type":"string","description":"Collection date"},"frozenAt":{"type":"string","description":"Freeze date"},"totalCells":{"type":"number","description":"Total cell count"},"viability":{"type":"number","description":"Viability %"},"cd34Count":{"type":"number","description":"CD34+ count"},"volumeMl":{"type":"number","description":"Volume (ml)"},"vialCount":{"type":"integer","description":"No. of vials/bags"},"tankCode":{"type":"string","description":"Tank"},"rack":{"type":"string","description":"Rack"},"box":{"type":"string","description":"Box"},"position":{"type":"string","description":"Position"},"icNumber":{"type":"string","description":"ID or passport number (only the last 4 digits are stored)"}}}}}}}}},"responses":{"200":{"description":"Result","content":{"application/json":{"schema":{"type":"object","properties":{"ownersCreated":{"type":"integer"},"samplesCreated":{"type":"integer"},"samplesUpdated":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"message":{"type":"string"}}}}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}}}},"/events":{"post":{"summary":"Add a custody event to a sample","description":"Requires a key allowed to send custody events. MOVED with tankCode/rack/box/position also updates the location; REMOVED and TRANSFERRED change the sample's status; RETURNED sets it back to stored.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["sampleCode","type","description"],"properties":{"sampleCode":{"type":"string"},"type":{"type":"string","enum":["AUDIT","MOVED","QC_TEST","REMOVED","RETURNED","TRANSFERRED","ALERT"]},"description":{"type":"string"},"performedBy":{"type":"string"},"occurredAt":{"type":"string","format":"date-time"},"tankCode":{"type":"string"},"rack":{"type":"string"},"box":{"type":"string"},"position":{"type":"string"}}}}}},"responses":{"200":{"description":"Event recorded","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"hash":{"type":"string"}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}}}},"/tank-readings":{"post":{"summary":"Send tank readings","description":"Requires a key allowed to send tank readings. Send one reading, or {\"readings\": [...]} with up to 1000. A reading for the same tank and time is skipped, so re-sending is safe.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"tankCode":{"type":"string"},"temperatureC":{"type":"number"},"ln2LevelPct":{"type":"number"},"lidOpen":{"type":"boolean"},"recordedAt":{"type":"string","format":"date-time"},"readings":{"type":"array","maxItems":1000,"items":{"type":"object","required":["tankCode","temperatureC"],"properties":{"tankCode":{"type":"string"},"temperatureC":{"type":"number"},"ln2LevelPct":{"type":"number"},"lidOpen":{"type":"boolean"},"recordedAt":{"type":"string","format":"date-time"}}}}}}}}},"responses":{"200":{"description":"Saved","content":{"application/json":{"schema":{"type":"object","properties":{"saved":{"type":"integer"},"duplicatesSkipped":{"type":"integer"}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}}}}}}