{"openapi":"3.1.0","info":{"title":"Coastal Signal beach API (pilot)","version":"1.0.0-pilot","description":"Beach water-quality forecasts from Coastal Signal with the official agency status beside them. California beaches carry the live forecast shown on coastalsignalinc.com; other states carry shadow forecasts from models still under test, or official status only. Not an official advisory. Every response has a meta block with the disclaimer, labels and data credits that must travel with the data.","contact":{"email":"riley@coastalsignalinc.com"}},"servers":[{"url":"https://api.coastalsignalinc.com","description":"Production"},{"url":"https://coastal-api.rileysullivan1103.workers.dev","description":"Former pilot address (kept working for 90 days from Nov 17 2026)"}],"security":[{"bearer":[]}],"paths":{"/v1/beaches":{"get":{"summary":"Search beaches by name, location or state","parameters":[{"name":"q","in":"query","schema":{"type":"string"},"description":"Name words, e.g. \"ocean beach\""},{"name":"state","in":"query","schema":{"type":"string","minLength":2,"maxLength":2}},{"name":"lat","in":"query","schema":{"type":"number"}},{"name":"lon","in":"query","schema":{"type":"number"}},{"name":"radius_km","in":"query","schema":{"type":"number","default":25,"maximum":500}},{"name":"coverage","in":"query","schema":{"$ref":"#/components/schemas/Coverage"}},{"name":"limit","in":"query","schema":{"type":"integer","default":20,"maximum":100}}],"responses":{"200":{"description":"Matching beaches","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchEnvelope"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/v1/beaches/{id}":{"get":{"summary":"Current status for one beach","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Beach id from /v1/beaches (URL-encode it; some ids contain \":\" or spaces)."}],"responses":{"200":{"description":"Beach status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BeachEnvelope"}}}},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/v1/beaches/{id}/why":{"get":{"summary":"Why the beach has its forecast colour today: why_today (one plain sentence with its facts and sources) plus the ranked ASK-1 reasons","description":"why_today is the main Developer plan feature: a sentence you can show your users each morning that explains the day, not the index.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Beach id from /v1/beaches (URL-encode it; some ids contain \":\" or spaces)."}],"responses":{"200":{"description":"Reasons"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/v1/beaches/{id}/history":{"get":{"summary":"Daily record for the last 30 days","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Beach id from /v1/beaches (URL-encode it; some ids contain \":\" or spaces)."},{"name":"days","in":"query","schema":{"type":"integer","default":30,"minimum":1,"maximum":30}}],"responses":{"200":{"description":"History rows"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/v1/coverage":{"get":{"summary":"Coverage counts by state and kind","parameters":[{"name":"state","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Coverage"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/v1/health":{"get":{"summary":"Snapshot freshness (no key needed)","security":[],"responses":{"200":{"description":"Fresh"},"503":{"description":"Stale or no snapshot"}}}},"/mcp":{"post":{"summary":"Remote MCP server (Streamable HTTP, JSON-RPC 2.0). Tools: find_beach, beach_status, why_flagged, coverage. Same bearer key.","responses":{"200":{"description":"JSON-RPC response"}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Pilot key, csk_pilot_..."}},"responses":{"Error":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"meta":{"type":"object"}}}}}}},"schemas":{"Coverage":{"type":"string","enum":["live","shadow","rain_rule","official_only"]},"Tier":{"type":["string","null"],"enum":["green","yellow","red",null],"description":"Our forecast colour: green lower risk, yellow elevated risk, red high risk of bacteria above the state standard. null = no forecast today (see status_text)."},"Official":{"type":"object","description":"Official agency status. Always present; withheld=true when the source licence does not allow redistribution.","properties":{"level":{"type":["string","null"],"enum":["closed","advisory","open","none","unknown",null]},"label":{"type":["string","null"]},"event_types":{"type":"array","items":{"type":"string"}},"source_id":{"type":["string","null"]},"source_name":{"type":["string","null"]},"source_url":{"type":["string","null"]},"as_of":{"type":["string","null"]},"last_sample_date":{"type":["string","null"]},"withheld":{"type":"boolean"},"note":{"type":["string","null"]}}},"Beach":{"type":"object","required":["id","name","state","coverage","shadow","ours","official"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"county":{"type":["string","null"]},"lat":{"type":["number","null"]},"lon":{"type":["number","null"]},"coverage":{"$ref":"#/components/schemas/Coverage"},"coverage_label":{"type":"string"},"shadow":{"type":"boolean","description":"true = model under test, not validated live"},"ours":{"type":"object","properties":{"tier":{"$ref":"#/components/schemas/Tier"},"status_text":{"type":["string","null"]},"model_id":{"type":["string","null"]},"model_label":{"type":["string","null"]},"read_status":{"type":["string","null"]},"forecast_date":{"type":["string","null"]},"horizon":{"type":"array"},"horizon_note":{"type":["string","null"]},"superseded_by_official":{"type":"boolean","description":"true when the agency has a closure or advisory in force: our call is set aside and status_text says to follow the posting. Show the official status, not our tier."}}},"official":{"$ref":"#/components/schemas/Official"},"why":{"type":"object","properties":{"reason_codes":{"type":"array","items":{"type":"string"}},"one_line":{"type":["string","null"]},"reasons":{"type":"array"},"note":{"type":["string","null"]}}},"why_today":{"$ref":"#/components/schemas/WhyToday"},"season":{"type":"object"},"updated_at":{"type":"string"}}},"WhyToday":{"type":["object","null"],"description":"Why today: one plain sentence on what is driving our call for this beach today, the facts behind it and their sources. Present when a sentence was written for the day; null otherwise. It explains our forecast only: the official status in the same response always comes first.","properties":{"sentence":{"type":"string","description":"Line a: at most 160 characters."},"detail":{"type":["string","null"],"description":"Line b: three to five sentences, or null."},"brief":{"type":["string","null"],"description":"Line c: a five-part brief (what is driving it, why it matters here, what to expect, typical clearing, what we do not know), or null."},"version":{"type":"string","enum":["v1","v2T"]},"facts":{"type":["object","array","null"]},"sources":{"type":"array","items":{"type":"string"}},"forecast_date":{"type":["string","null"]}}},"Meta":{"type":"object","required":["disclaimer","credits"],"properties":{"snapshot_id":{"type":"string"},"generated_at":{"type":"string"},"disclaimer":{"type":"string"},"live_note":{"type":"string"},"shadow_note":{"type":"string"},"credits":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string"},"credit":{"type":"string"},"url":{"type":["string","null"]}}}}}},"BeachEnvelope":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Beach"},"meta":{"$ref":"#/components/schemas/Meta"}}},"SearchEnvelope":{"type":"object","properties":{"data":{"type":"object","properties":{"count":{"type":"integer"},"beaches":{"type":"array","items":{"type":"object"}}}},"meta":{"$ref":"#/components/schemas/Meta"}}}}}}