{"openapi":"3.1.0","info":{"title":"Life Oracle API","version":"0.1.0","description":"Seven readings and one verdict per place, plus ingest endpoints for sound recorders and soil probes. Auth: `Authorization: Bearer <key>`. Keys: admin (env), STEWARD/VERIFIER/CONSUMER keys (lo_key_…), device tokens (lo_dev_…).","license":{"name":"Apache-2.0"}},"servers":[{"url":"https://life.oncra.org/api/v1"}],"paths":{"/places":{"get":{"summary":"List public places","parameters":[{"name":"format","in":"query","schema":{"type":"string","enum":["json","geojson"]}}],"responses":{"200":{"description":"List or FeatureCollection"}}},"post":{"summary":"Register a place (STEWARD or admin)","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","geometry"],"properties":{"name":{"type":"string"},"geometry":{"description":"GeoJSON Polygon or MultiPolygon (WGS84)"},"landUse":{"type":"string"},"country":{"type":"string"},"description":{"type":"string"},"public":{"type":"boolean"},"locationHidden":{"type":"boolean","description":"Hide the exact boundary from the public. They see a circle of blurRadiusM around a centre moved a random distance from the true one; the owner, the steward key and admins see the boundary."},"blurRadiusM":{"type":"integer","minimum":200,"maximum":20000,"default":1000}}}}}},"responses":{"201":{"description":"Place + one-time steward key; satellite backfill queued"}}}},"/places/{id}":{"get":{"summary":"Place detail: readings, verdict, satellite series, devices, visits","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"id or slug"}],"responses":{"200":{"description":"ok"}}},"patch":{"summary":"Update place metadata","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}},"delete":{"summary":"Delete (admin)","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}}},"/places/{id}/satellite":{"get":{"summary":"NDVI observations","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"format","in":"query","schema":{"type":"string","enum":["json","csv"]}}],"responses":{"200":{"description":"ok"}}}},"/places/{id}/carbon":{"get":{"summary":"Yearly net ecosystem carbon balance (low/central/high) and issuable at the lower bound","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"ok"}}}},"/places/{id}/node":{"get":{"summary":"The Life Node dashboard as data: heartbeats and silences, soil and box series, species counts and the dawn-chorus grid. Public for every place; it says nothing about where the node stands.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"range","in":"query","schema":{"type":"string","enum":["24h","7d","30d","all"],"default":"7d"}}],"responses":{"200":{"description":"ok"},"404":{"description":"no such place, or no devices on it"}}}},"/places/{id}/node/status":{"get":{"summary":"How the node is doing now, as the status panel on its dashboard shows it: `state` (live, listening, awake, on, asleep, saving, quiet, silent, never), whether the numbers come from a live post or the last heartbeat (`source`), the window it says it is in with its times, what comes next (`next`: a post, its sleep at a window's end, or its wake), power, heat, the 4G signal (operator and strength only), sound today, the soil, storage, and short series for the lines (`spark`: the last fifteen minutes when live, else the last posts). A node on WiFi or a cable posts live every 20 seconds (/ingest/live); one on 4G only every three hours. Public for every place; it says nothing about where the node stands.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"ok"},"404":{"description":"no such place, or no devices on it"}}}},"/places/{id}/readings":{"get":{"summary":"All readings by period","responses":{"200":{"description":"ok"}}},"post":{"summary":"Recompute readings now (steward/verifier/admin)","security":[{"bearer":[]}],"responses":{"200":{"description":"readings + verdict"}}}},"/places/{id}/devices":{"get":{"summary":"Devices on a place","responses":{"200":{"description":"ok"}}},"post":{"summary":"Register a device; returns a one-time device token","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["kind","model"],"properties":{"kind":{"type":"string","enum":["SOUND","SOIL","CAMERA","OTHER"]},"model":{"type":"string"},"devEui":{"type":"string","description":"16 hex chars, LoRaWAN devices"},"lat":{"type":"number"},"lon":{"type":"number"},"heightM":{"type":"number"},"depthCm":{"type":"integer"},"installedAt":{"type":"string","format":"date-time"},"mapping":{"type":"object","description":"decoded_payload field names: {vwc, tempC, ec, co2Ppm}"}}}}}},"responses":{"201":{"description":"device + token"}}}},"/places/{id}/alerts":{"get":{"summary":"Open alerts on the place's devices: SILENT (no heartbeat for 36 h), MOVED (heartbeat from a cell outside the home set: the cells heard in the first 14 days, plus later cells in the same tracking areas) and TAMPER (a guard loop opened outside a maintenance window) and LOW_BATTERY (battery under 12.8 V, or a node its battery guard stopped; resolved at 13.2 V) and MIC (one of a node's two microphones moved 6 dB against the other in two bird bands, or gave no sound levels; resolved when every bird band is back within 3 dB). ?all=1 includes resolved. Steward or admin.","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}}},"/places/{id}/alerts/{alertId}":{"post":{"summary":"Acknowledge an alert. Acknowledging MOVED re-homes the device to its current cell and starts a new 14-day learning window.","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}}},"/places/{id}/devices/{deviceId}/maintenance":{"get":{"summary":"The device's maintenance window","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}},"put":{"summary":"Declare a maintenance window: {hours} from now, or {from?, until}. The node silences its tamper guard inside it. Steward or admin.","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"hours":{"type":"number"},"from":{"type":"string","format":"date-time"},"until":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"ok"}}},"delete":{"summary":"Clear the window","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}}},"/places/{id}/devices/{deviceId}/visit":{"get":{"summary":"A node's visit settings: the phone hotspot it joins on a visit (name, password; hotspot / 12345678 until the owner sets them) and its own WiFi for a laptop (life- and the last six characters of the device id, with a password drawn for it), whether the node has them yet, its clips and its last visit as its last heartbeat said, and the alarm window. A managing key, or the place's owner signed in.","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}},"put":{"summary":"Set the visit settings: {ssid?, psk?, apPsk?}; a value sets it, null puts the default back (for apPsk: a new password). The node hears it with its next heartbeat answer.","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ssid":{"type":["string","null"],"description":"1 to 32 bytes"},"psk":{"type":["string","null"],"description":"8 to 63 printable ASCII characters"},"apPsk":{"type":["string","null"]}}}}}},"responses":{"200":{"description":"the settings as GET shows them"}}}},"/places/{id}/devices/{deviceId}/night":{"get":{"summary":"A node's meadow-bird window: listening after its dusk window in spring, when black-tailed godwit, lapwing and snipe call most; off until the owner turns it on, and never counted by the readings. The settings, whether the node has them yet, the next window as the oracle works it out from the place's centroid (`tonight` {start, end}, or `seasonFrom` when out of season, `fits` false when the times leave no room before the next dawn), and how the last one went (`last`, the heartbeat's nightLast). A managing key, or the place's owner signed in.","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}},"put":{"summary":"Set the meadow-bird window: {on?, startMin?, lenMin?, from?, to?, battery?, minV?}; a value sets it. The node hears it with its next heartbeat answer.","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"on":{"type":"boolean","description":"off by default"},"startMin":{"type":"integer","minimum":0,"maximum":360,"description":"minutes after sunset; the window never starts before the end of the day's last listening window (default 60)"},"lenMin":{"type":"integer","minimum":15,"maximum":180,"description":"default 60; it ends at least 15 minutes before the next day's first listening window"},"from":{"type":"string","pattern":"^\\d{2}-\\d{2}$","description":"MM-DD, first day of the season, included (default 03-25)"},"to":{"type":"string","pattern":"^\\d{2}-\\d{2}$","description":"MM-DD, last day, included; a season may run over the new year (default 06-30)"},"battery":{"type":"boolean","description":"only when the Witty Pi reads at least minV at the window's start (default true)"},"minV":{"type":"number","minimum":12,"maximum":14,"description":"volts to one decimal (default 13.1)"}}}}}},"responses":{"200":{"description":"the settings as GET shows them"}}}},"/places/{id}/devices/{deviceId}/config":{"get":{"summary":"A node's settings over the air (node/life-config.py): the method's listening windows as rules (`method`, the same at every node), today's windows at the place (`today`), the settings the owner set (`env`) within the bounds in `settings`, the rev the oracle sends (`rev`), and as the node's last heartbeat said: the rev it runs (`nodeRev`, null on a node without life-config), whether it has them (`nodeHas`) or is trying them (`trial`: back to its last good settings after three wakes without an answer from the oracle), what it refused (`refused` {rev, why}) or left out (`ignored`), and the settings it runs (`running` {at, settings}). Steward, admin or the place's owner signed in.","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}},"put":{"summary":"Set the node's settings: {env: {KEY: value}} sets each (a number within its bounds or one of its words; null gives it back to the node), {again: true} sends the same settings again under a new rev after the node refused them. Only the keys in `settings` (GET) can be set; never the SIM, the network, the tokens, the oracle's address or the software. The node gets them with its next heartbeat answer and checks every value again itself.","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"env":{"type":"object","additionalProperties":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"again":{"type":"boolean"}}}}}},"responses":{"200":{"description":"ok, with the new state"},"400":{"description":"a value out of bounds, or a setting that cannot be set over the air"}}}},"/places/{id}/clips.zip":{"get":{"summary":"The clips of a place whose sound the oracle still has, as one zip with a clips.csv of their facts and verdicts. For whoever may see the place exactly.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"month","in":"query","schema":{"type":"string","example":"2026-05"},"description":"one month (UTC)"},{"name":"device","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"application/zip"}}}},"/clips":{"post":{"summary":"One detection's clip, as multipart: the sound (`file`) and its row of the node's clips.csv, with `sha256` as the sender has it. From the node itself (device token), from a laptop that took the clip from the node at a visit (`Authorization: Grant lg1...`, the node's grant for exactly those clips), or with a steward or admin key and `device`. Every answer that keeps the clip carries the SHA-256 the oracle holds; the sender deletes its copy only when that is its own. `replace=1` puts a new sound in the first one's place and keeps the verdicts.","security":[{"bearer":[]}],"responses":{"200":{"description":"kept before, with the first sound's sha256"},"201":{"description":"kept, with its sha256"}}}},"/clips/batches":{"post":{"summary":"A laptop registers the batch it took from a node at a visit before it sends the clips: `Authorization: Grant lg1...` and {items: [{ref, sha256}], laptop?}. The oracle checks the list against the grant and answers with the refs it already has with the same SHA-256, which need not be sent again. Harmless twice.","responses":{"200":{"description":"{batch, have: [ref]}"}}}},"/places/{id}/access":{"get":{"summary":"People given access to this place (admin or steward key)","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}},"post":{"summary":"Give someone access: they sign in at /me and see the exact boundary (admin or steward key)","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string"},"role":{"type":"string","enum":["owner","viewer"]}}}}}},"responses":{"201":{"description":"ok"}}},"delete":{"summary":"Remove access (?email=)","security":[{"bearer":[]}],"responses":{"200":{"description":"ok"}}}},"/places/{id}/visits":{"get":{"summary":"Visits","responses":{"200":{"description":"ok"}}},"post":{"summary":"File a visit (VERIFIER/admin)","security":[{"bearer":[]}],"responses":{"201":{"description":"ok"}}}},"/heard":{"get":{"summary":"The species the nodes heard last, newest first, one per species whatever name it came under (a species is its scientific name), each with its cut-out picture and credits, its common names by language (en, nl, de, fr, es, zh) from Wikidata and the node that heard it, plus whether each node is listening, asleep, quiet or silent. Public like the node dashboard: what was heard and when, never where. CORS open.","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":20,"default":6}},{"name":"place","in":"query","description":"one place, slug or id","schema":{"type":"string"}},{"name":"min","in":"query","description":"lowest detection confidence; 0.7 is the threshold the diversity reading counts from","schema":{"type":"number","minimum":0,"maximum":1,"default":0.7}},{"name":"images","in":"query","description":"only: leave out species whose picture is not made yet","schema":{"type":"string","enum":["only"]}}],"responses":{"200":{"description":"{now, min, items[], nodes[]}"},"404":{"description":"no such place"}}}},"/nodes":{"get":{"summary":"Every place with a device that has reported, as a signal for the map: when it was last heard, what it last heard, and a point that is blurred for places that hide their location or are private","responses":{"200":{"description":"ok"}}}},"/ingest/sound":{"post":{"summary":"Deliver detections and/or acoustic indices (device token)","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"detections":{"type":"array","items":{"type":"object","required":["ts","species","confidence"],"properties":{"ts":{"type":"string","format":"date-time"},"species":{"type":"string"},"scientific":{"type":"string"},"confidence":{"type":"number"},"detector":{"type":"string","example":"birdnet-2.4"},"durationS":{"type":"number"},"test":{"type":"boolean","description":"made while a microphone or the node was being tested: stored, counted nowhere"}}}},"indices":{"type":"array","items":{"type":"object","required":["ts"],"properties":{"ts":{"type":"string","format":"date-time"},"windowS":{"type":"integer"},"aci":{"type":"number"},"adi":{"type":"number"},"aei":{"type":"number"},"bio":{"type":"number"},"ndsi":{"type":"number"},"biophony":{"type":"number"},"anthrophony":{"type":"number"},"spl":{"type":"number"}}}},"heartbeat":{"type":"object","description":"same object as /ingest/heartbeat"}}}}}},"responses":{"201":{"description":"counts; with a heartbeat its answer as /ingest/heartbeat gives it (`heartbeat`), or `heartbeatError` when the oracle could not read the heartbeat: the detections count all the same"}}}},"/ingest/heartbeat":{"post":{"summary":"Node liveness (device token): time, event, the modem's serving cell and device metrics. The first cell heard becomes the home cell, and every cell heard in the 14 days after it joins the home set; after that a cell in a tracking area the node has not been in opens a MOVED alert, and a heartbeat from home resolves it. A node with two microphones adds their check (once a week) as `metrics.mics`: {day, n, bands (Hz), diff (median AudioMoth minus I2S level per band, dB), a, i (each microphone's median level), fa, fi (each one's median floor), missing?}, compared with the node's own last weeks (MIC alert). A node that pushes sound can send the same object as `heartbeat` on /ingest/sound instead and save a TLS handshake.","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["heartbeat"],"properties":{"heartbeat":{"type":"object","properties":{"ts":{"type":"string","format":"date-time"},"event":{"type":"string","enum":["boot","hourly","shutdown","manual","alarm"]},"tamper":{"type":"object","description":"with event alarm","properties":{"loop":{"type":"string","enum":["lid","panel","tilt","unknown"]},"state":{"type":"string"}}},"cell":{"type":"object","properties":{"plmn":{"type":"string","example":"20408"},"cellId":{"type":"string"},"tac":{"type":"string"},"pci":{"type":"integer"},"band":{"type":"string"},"rsrp":{"type":"number"},"rssi":{"type":"number"},"sinr":{"type":"number"},"mode":{"type":"string"}}},"metrics":{"type":"object","description":"flat: uptimeS, cpuTempC, diskFreeMb, unsent, load1, throttled; from the Witty Pi 4 vinV (its input, the battery on a 12 V node), piW, boxTempC, wake, lowV, recoveryV, lvOff; window and offWindow (stop, visit or kept) from the node's schedule; from life-clips clipsKeep, clipsWaiting, clipsMb, clipsFull, clipsCollectedAt, clipsSentAt and clipsHanded (the laptop batches not yet in full on the oracle, \"batch:clips,...\"); from life-visit visitRev (the revision of the visit settings the node has, -1 for none) and visitLast {at, reason, how (online, hotspot, wifi, hotspot+wifi, none), sent, handed, minutes, laptop}; from life-window nightRev (the revision of the meadow-bird settings the node has, -1 for none), from life-config cfgRev (the rev of the settings over the air the node runs, empty for none yet), cfgTrial, cfgRefused and cfgWhy (a rev it refused and why), cfgIgnored (keys it does not know) and, after each change, settings {KEY: value} (what it runs), and nightLast {date (the local day the window belongs to), start, end, ran (listened, battery: skipped for the battery, unknown: listened without a battery reading, kept: stayed on for a maintenance window), v, minV, at}; from the charge controller over VE.Direct battV, battA, pvV, pvW, charge, mpptErr, loadOn, yieldTodayWh, yieldYdayWh, pvMaxTodayW; net {via: wifi, lan or 4g}, how the post left the node. A battery under 12.8 V, or a shutdown with wake low-voltage (the battery guard), opens LOW_BATTERY","additionalProperties":true}}}}}}}},"responses":{"201":{"description":"ok; recovered/moved/tamper flags and the maintenance window {from, until, active} or null, which the node caches; `visit` {rev, device, ssid, psk, apPsk} when the node reports a visitRev other than the current one; `night` {rev, on, startMin, lenMin, from, to, battery, minV} when the node reports a nightRev other than the current one; `config` {rev, windows (the method's rules), env} when the node reports a cfgRev other than the current one and has not refused it; `clipsReceived`, the laptop batches of clipsHanded the oracle has every clip of, which the node then deletes"}}}},"/ingest/live":{"post":{"summary":"How a node on WiFi or a cable is doing now, every 20 seconds (device token; node/life-live.py; a node on 4G never sends it, to spare the SIM): {live: {net: {via: wifi|lan|4g, dBm?}, cell?, metrics}} with the same cell and metrics as /ingest/heartbeat. The oracle keeps only the latest post and the samples of the last fifteen minutes on the device, overwritten each time, for the status panel (GET /places/{id}/node/status); the heartbeats stay the record. The cell id, tracking area and PCI are not kept.","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["live"],"properties":{"live":{"type":"object","properties":{"net":{"type":"object","properties":{"via":{"type":"string","enum":["wifi","lan","4g"]},"dBm":{"type":"number","description":"WiFi signal"}}},"cell":{"type":"object","description":"as in /ingest/heartbeat"},"metrics":{"type":"object","additionalProperties":true}}}}}}}},"responses":{"201":{"description":"{ok, every}: how many seconds until the next post"}}}},"/ingest/soil":{"post":{"summary":"Deliver soil readings (device token)","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["readings"],"properties":{"readings":{"type":"array","items":{"type":"object","required":["ts"],"properties":{"ts":{"type":"string","format":"date-time"},"depthCm":{"type":"integer"},"vwc":{"type":"number","description":"percent"},"tempC":{"type":"number"},"ec":{"type":"number","description":"µS/cm"},"co2Ppm":{"type":"number"},"fluxUmol":{"type":"number"}}}}}}}}},"responses":{"201":{"description":"count"}}}},"/ingest/ttn":{"post":{"summary":"The Things Stack webhook (uplink messages). Auth with a device token, or a STEWARD/ADMIN key + registered DevEUI.","security":[{"bearer":[]}],"responses":{"201":{"description":"stored"},"422":{"description":"no soil fields recognised; set device.mapping"}}}},"/keys":{"post":{"summary":"Create an API key (admin)","security":[{"bearer":[]}],"responses":{"201":{"description":"one-time key"}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}}}