{"openapi":"3.1.0","info":{"title":"Leaf API","summary":"Leaf's plant doctor, care planner and season plan for your garden.","description":"Authenticate with `Authorization: Bearer lf_...`. Make a key on your garden's Connect page (/connect). Keys have scopes (`read`, `readings`, `tools`) and limits per hour, per day and for calls that use Leaf's models. Every answer comes from code rules and cited sources; Leaf gives guidance, not certainty.","version":"1.0.0"},"paths":{"/api/v1/garden":{"get":{"tags":["Leaf API v1"],"summary":"The key's garden","description":"The garden this key acts for, with its active plants. Scope: `read`.","operationId":"garden_api_v1_garden_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GardenInfo"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."}}}},"/api/v1/today":{"get":{"tags":["Leaf API v1"],"summary":"The garden's day","description":"Urgent alerts, today's tasks (each with its reason and source), and each plant's water\nstatus. Planned on demand and safe to call often. Scope: `read`.","operationId":"today_api_v1_today_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Today Api V1 Today Get"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."}}}},"/api/v1/season":{"get":{"tags":["Leaf API v1"],"summary":"The season plan","description":"The current verified plan, week by week, with each item's reason, sources and cautions,\nwhat the checks removed, and the latest replans. `pending` shows a write in progress.\nScope: `read`.","operationId":"season_api_v1_season_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Season Api V1 Season Get"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."}}},"post":{"tags":["Leaf API v1"],"summary":"Write the season plan","description":"Start writing (or rewriting) the season plan in the background (about two minutes;\npoll `GET /season`). A garden may start three a day. Scope: `tools`; uses model credits.","operationId":"season_write_api_v1_season_post","responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Season Write Api V1 Season Post"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."}}}},"/api/v1/readings":{"post":{"tags":["Leaf API v1"],"summary":"Send a soil moisture reading","description":"The Home Assistant webhook. A fresh reading (12 hours) replaces the weather-based water\nestimate for its plant: below the dry mark Leaf asks you to water, at or above it Leaf says\nno water is needed, and today's water task is rewritten at once. Scope: `readings`.","operationId":"post_reading_api_v1_readings_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadingIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Post Reading Api V1 Readings Post"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["Leaf API v1"],"summary":"Recent soil moisture readings","description":"Readings sent in the last 14 days, newest first. Scope: `read`.","operationId":"list_readings_api_v1_readings_get","parameters":[{"name":"plant_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":40},{"type":"null"}],"title":"Plant Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Reading"},"title":"Response List Readings Api V1 Readings Get"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/diagnose":{"post":{"tags":["Leaf API v1"],"summary":"Diagnose a plant problem","description":"A photo and/or notes through Leaf's diagnosis (vision, Nemotron Ultra, Tavily sources,\nNemotron Lightning plan), with the garden's organic and pet choices applied in code. Returns\nthe verdict, hypotheses, plan, sources, a report link and the owner token for check-ins.\nScope: `tools`; uses model credits.","operationId":"diagnose_api_v1_diagnose_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_diagnose_api_v1_diagnose_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Diagnose Api V1 Diagnose Post"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/identify":{"post":{"tags":["Leaf API v1"],"summary":"Identify a plant from a photo","description":"Candidates with the evidence for each; confirm one in the app. Scope: `tools`; uses\nmodel credits.","operationId":"identify_api_v1_identify_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_identify_api_v1_identify_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Identify Api V1 Identify Post"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/weather-risk":{"get":{"tags":["Leaf API v1"],"summary":"Frost, heat and wind risk","description":"Risk from the forecast and, in the US, NWS alerts, with the next five days. Without a\npoint it uses the key's garden. Weather data by Open-Meteo.com (CC BY 4.0). Scope: `tools`.","operationId":"weather_risk_api_v1_weather_risk_get","parameters":[{"name":"lat","in":"query","required":false,"schema":{"anyOf":[{"type":"number","maximum":90,"minimum":-90},{"type":"null"}],"title":"Lat"}},{"name":"lon","in":"query","required":false,"schema":{"anyOf":[{"type":"number","maximum":180,"minimum":-180},{"type":"null"}],"title":"Lon"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Weather Risk Api V1 Weather Risk Get"}}}},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"The key does not have the scope this call needs."},"429":{"description":"The key is over a limit; see the Retry-After header."},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"Body_diagnose_api_v1_diagnose_post":{"properties":{"image":{"anyOf":[{"type":"string","contentMediaType":"application/octet-stream"},{"type":"null"}],"title":"Image","description":"A photo of the problem."},"notes":{"type":"string","maxLength":2000,"title":"Notes","description":"What you see.","default":""},"region":{"type":"string","maxLength":100,"title":"Region","description":"A town, for local weather.","default":""},"plant_id":{"anyOf":[{"type":"string","maxLength":40},{"type":"null"}],"title":"Plant Id","description":"Add the report to this plant: tasks and a replan."}},"type":"object","title":"Body_diagnose_api_v1_diagnose_post"},"Body_identify_api_v1_identify_post":{"properties":{"image":{"type":"string","contentMediaType":"application/octet-stream","title":"Image","description":"A photo of the plant."},"notes":{"type":"string","maxLength":500,"title":"Notes","default":""}},"type":"object","required":["image"],"title":"Body_identify_api_v1_identify_post"},"GardenInfo":{"properties":{"garden":{"$ref":"#/components/schemas/backend__data__repo__Garden"},"plants":{"items":{"$ref":"#/components/schemas/Plant"},"type":"array","title":"Plants"}},"type":"object","required":["garden","plants"],"title":"GardenInfo"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"Plant":{"properties":{"species":{"type":"string","maxLength":120,"title":"Species","default":""},"common_name":{"type":"string","maxLength":120,"title":"Common Name","default":""},"nickname":{"type":"string","maxLength":80,"title":"Nickname","default":""},"setting":{"type":"string","enum":["outdoor","indoor"],"title":"Setting","default":"outdoor"},"container":{"additionalProperties":true,"type":"object","title":"Container"},"planted_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Planted On"},"stage":{"type":"string","maxLength":40,"title":"Stage","default":""},"id":{"type":"string","title":"Id"},"garden_id":{"type":"string","title":"Garden Id"},"status":{"type":"string","enum":["active","archived"],"title":"Status","default":"active"},"created_at":{"type":"integer","title":"Created At"},"updated_at":{"type":"integer","title":"Updated At"}},"type":"object","required":["id","garden_id","created_at","updated_at"],"title":"Plant"},"Reading":{"properties":{"id":{"type":"integer","title":"Id"},"garden_id":{"type":"string","title":"Garden Id"},"plant_id":{"type":"string","title":"Plant Id"},"kind":{"type":"string","title":"Kind","default":"soil_moisture"},"value":{"type":"number","title":"Value"},"dry_below":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Dry Below"},"label":{"type":"string","enum":["sensor","test"],"title":"Label","default":"sensor"},"source":{"type":"string","title":"Source","default":""},"created_at":{"type":"integer","title":"Created At"}},"type":"object","required":["id","garden_id","plant_id","value","created_at"],"title":"Reading"},"ReadingIn":{"properties":{"plant_id":{"anyOf":[{"type":"string","maxLength":40},{"type":"null"}],"title":"Plant Id","description":"The plant's id."},"plant":{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}],"title":"Plant","description":"Or the plant's name or nickname (it must match one plant exactly)."},"value":{"type":"number","maximum":100.0,"minimum":0.0,"title":"Value","description":"Soil moisture, percent."},"unit":{"type":"string","const":"%","title":"Unit","default":"%"},"dry_below":{"anyOf":[{"type":"number","exclusiveMaximum":100.0,"exclusiveMinimum":0.0},{"type":"null"}],"title":"Dry Below","description":"Water below this percent. Leaf's default is 30; sensors differ."},"test":{"type":"boolean","title":"Test","description":"Send true for a test reading. Leaf labels it TEST wherever it uses it.","default":false},"source":{"type":"string","maxLength":80,"title":"Source","description":"Free text, e.g. the sensor's entity id.","default":""}},"type":"object","required":["value"],"title":"ReadingIn"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"backend__data__repo__Garden":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name","default":""},"lat":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Lat"},"lon":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Lon"},"cell":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cell"},"timezone":{"type":"string","title":"Timezone","default":"UTC"},"plan_hour_utc":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Plan Hour Utc"},"prefs":{"$ref":"#/components/schemas/backend__schemas__Garden"},"created_at":{"type":"integer","title":"Created At"},"last_seen":{"type":"integer","title":"Last Seen"}},"type":"object","required":["id","created_at","last_seen"],"title":"Garden"},"backend__schemas__Garden":{"properties":{"organic":{"type":"boolean","title":"Organic","default":false},"pets":{"type":"boolean","title":"Pets","default":false}},"type":"object","title":"Garden","description":"The gardener's preferences, applied to the care plan in code (backend/actives.py)."}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"lf_<key>"}}},"servers":[{"url":"https://leafathon.site"}],"security":[{"bearerAuth":[]}]}