{"openapi":"3.1.0","info":{"title":"UNIONAI Core API","version":"0.3.0","description":"Federacyjna warstwa governance dla agentów AI (channel: stable)"},"servers":[{"url":"https://uni0nai.k0nsult.cloud","description":"Public testnet runtime (custom domain) — GO CONTROLLED, nie pełna produkcja"},{"url":"https://unionai.grassrootslobbing.pl","description":"Public testnet runtime (alias)"},{"url":"https://unionai-core.fly.dev","description":"Public testnet runtime (Fly app domain)"},{"url":"http://localhost:3000","description":"Local development"}],"components":{"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}},"required":["error"]}}},"paths":{"/health":{"get":{"tags":["system"],"summary":"Health check (DB + Redis)","responses":{"200":{"description":"Service health snapshot","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Service health snapshot"}}}}}}},"/metrics":{"get":{"tags":["system"],"summary":"Prometheus metrics (text/plain)","responses":{"200":{"description":"Prometheus exposition format"}}}},"/api/system/smoke":{"get":{"tags":["system"],"summary":"Run smoke checks and return tag VERIFIED/BLOCKED","responses":{"200":{"description":"Smoke result","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Smoke result"}}}}}}},"/.well-known/agent.json":{"get":{"tags":["discovery"],"summary":"Agent identity descriptor (DID-lite)","responses":{"200":{"description":"Agent descriptor","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Agent descriptor"}}}}}}},"/api/agent/join":{"post":{"tags":["agent"],"summary":"Register agent in federation (idempotent on did)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["did"],"properties":{"did":{"type":"string"},"provider":{"type":"string"},"capabilities":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"Agent already existed","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Agent already existed"}}}},"201":{"description":"Agent created","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Agent created"}}}},"400":{"description":"Missing did","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Missing did"}}}},"500":{"description":"DB error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"DB error"}}}}}}},"/api/agent/register":{"post":{"tags":["agent"],"summary":"Full agent registration (Wave3 — trust score, tier, capabilities)","responses":{"201":{"description":"Agent registered","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Agent registered"}}}},"400":{"description":"Missing did","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Missing did"}}}},"500":{"description":"DB error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"DB error"}}}}}}},"/api/relay/send":{"post":{"tags":["relay"],"summary":"Send relay event (MVSS validated)","responses":{"201":{"description":"Relay received","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Relay received"}}}},"400":{"description":"MVSS invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"MVSS invalid"}}}},"503":{"description":"Relay frozen","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Relay frozen"}}}}}}},"/api/relay/route":{"post":{"tags":["relay"],"summary":"Route relay via semantic or syntactic match","responses":{"200":{"description":"Route resolved","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Route resolved"}}}},"400":{"description":"Missing src_did/intent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Missing src_did/intent"}}}},"403":{"description":"Trust too low","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Trust too low"}}}},"503":{"description":"Relay frozen","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Relay frozen"}}}}}}},"/api/relay/status":{"get":{"tags":["relay"],"summary":"Relay subsystem status + metrics","responses":{"200":{"description":"Status snapshot","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Status snapshot"}}}}}}},"/api/relay/drift":{"get":{"tags":["relay"],"summary":"Semantic drift ratio + Qdrant health","responses":{"200":{"description":"Drift snapshot","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Drift snapshot"}}}}}}},"/api/relay/replay/{trace_id}":{"get":{"tags":["relay"],"summary":"Replay events for a trace_id","parameters":[{"name":"trace_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Replay events","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Replay events"}}}},"404":{"description":"Trace not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Trace not found"}}}}}}},"/api/qdrant/health":{"get":{"tags":["relay"],"summary":"Qdrant connectivity check","responses":{"200":{"description":"Qdrant ok","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Qdrant ok"}}}},"503":{"description":"Qdrant unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Qdrant unavailable"}}}}}}},"/api/memory/anchor":{"post":{"tags":["memory"],"summary":"Anchor memory entry (hash-chained)","responses":{"201":{"description":"Anchor created","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Anchor created"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Validation error"}}}},"503":{"description":"Memory frozen","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Memory frozen"}}}}}}},"/api/memory/query":{"post":{"tags":["memory"],"summary":"Query memory anchors","responses":{"200":{"description":"Anchors","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Anchors"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Validation error"}}}}}}},"/api/trust/verify":{"post":{"tags":["trust"],"summary":"Verify trust tier for did","responses":{"200":{"description":"Trust info","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Trust info"}}}},"400":{"description":"Missing did","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Missing did"}}}},"404":{"description":"Agent not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Agent not found"}}}}}}},"/api/k0nsulat/status":{"get":{"tags":["k0nsulat"],"summary":"K0NSULAT module status","responses":{"200":{"description":"Status","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Status"}}}}}}},"/api/k0nsulat/audit":{"post":{"tags":["k0nsulat"],"summary":"Log audit event","responses":{"201":{"description":"Audit logged","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Audit logged"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Validation error"}}}}}}},"/api/incident/open":{"post":{"tags":["incident"],"summary":"Open new incident","responses":{"201":{"description":"Incident created","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Incident created"}}}},"400":{"description":"Missing title/severity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Missing title/severity"}}}},"500":{"description":"DB error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"DB error"}}}}}}},"/api/incident/{id}":{"get":{"tags":["incident"],"summary":"Get incident by id","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Incident","content":{"application/json":{"schema":{"type":"object"},"example":{"ok":true,"description":"Incident"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Not found","code":"NOT_FOUND"}}}}}}},"/api/incidents":{"get":{"tags":["incident"],"summary":"Publiczny rejestr incydentów (zagregowany, bez danych wrażliwych)","responses":{"200":{"description":"Lista incydentów + agregaty","content":{"application/json":{"schema":{"type":"object"},"example":{"incidents":[{"id":1,"title":"Przykładowy incydent","severity":"MAJOR","status":"OPEN","incident_type":"security","created_at":"2026-05-22T00:00:00Z"}],"by_severity":{"LOW":0,"MAJOR":1,"CRITICAL":0},"by_status":{"OPEN":1,"FROZEN":0,"RESOLVED":0,"EXPORTED":0},"total":1,"generated_at":"2026-05-22T00:00:00Z"}}}},"200_db_error":{"description":"Fallback przy błędzie DB","content":{"application/json":{"schema":{"type":"object"},"example":{"incidents":[],"by_severity":{"LOW":0,"MAJOR":0,"CRITICAL":0},"by_status":{},"total":0,"db_error":true,"generated_at":"2026-05-22T00:00:00Z"}}}}}}},"/api/rfc/status":{"get":{"tags":["rfc"],"summary":"Zliczenie RFC wg statusu","responses":{"200":{"description":"Liczby RFC wg statusu","content":{"application/json":{"schema":{"type":"object"},"example":{"active":3,"draft":2,"deprecated":1,"frozen":0,"total":6,"by_status":{"ACTIVE":3,"DRAFT":2,"FROZEN":0,"SUPERSEDED":1},"generated_at":"2026-05-22T00:00:00Z"}}}}}}},"/api/evidence/verify":{"get":{"tags":["evidence"],"summary":"Weryfikacja zgodności hashy dokumentów z manifestem","parameters":[{"name":"id","in":"query","required":false,"schema":{"type":"string"},"description":"Opcjonalny identyfikator dokumentu, np. DOC-004"}],"responses":{"200":{"description":"Wynik weryfikacji","content":{"application/json":{"schema":{"type":"object"},"example":{"checked":4,"matched":4,"mismatched":0,"skipped":9,"results":[{"id":"DOC-004","file":"/docs/UNIONAI_Raport_Calosci_Konsultacji.pdf","expected":"7e07bce5...","actual":"7e07bce5...","match":true}],"verified_at":"2026-05-22T00:00:00Z"}}}},"404":{"description":"Dokument o podanym id nie istnieje","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Dokument o podanym id nie istnieje","code":"NOT_FOUND"}}}}}}},"/api/memory/anchors":{"get":{"tags":["memory"],"summary":"Publiczny podgląd hash-chain anchorów (bez payloadu/danych wrażliwych)","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":100,"maximum":500}}],"responses":{"200":{"description":"Lista anchorów (tylko bezpieczne kolumny)","content":{"application/json":{"schema":{"type":"object"},"example":{"anchors":[{"id":"anchor-001","hash":"ab12...","prev_hash":"cd34...","scope":"PUBLIC","validation_status":"validated","created_at":"2026-05-22T00:00:00Z"}],"count":1,"generated_at":"2026-05-22T00:00:00Z"}}}},"200_db_error":{"description":"Fallback przy błędzie DB","content":{"application/json":{"schema":{"type":"object"},"example":{"anchors":[],"count":0,"db_error":true,"generated_at":"2026-05-22T00:00:00Z"}}}}}}},"/releases.json":{"get":{"tags":["system"],"summary":"Live changelog — lista wydań sparsowana z CHANGELOG.md + bieżący build","responses":{"200":{"description":"Lista wydań","content":{"application/json":{"schema":{"type":"object"},"example":{"service":"unionai-core","current_version":"0.3.0-dev","channel":"dev","build_sha":"abc1234","repo":"https://github.com/0n40i4/uni0n","count":4,"releases":[{"version":"0.3.0-dev","tag":"v0.3.0-dev","date":"2026-05-15","build_sha":"abc1234","commit":"abc1234","channel":"dev","changes":["..."],"github_release_url":"https://github.com/0n40i4/uni0n/releases/tag/v0.3.0-dev","zenodo_doi":null}],"generated_at":"2026-05-22T00:00:00Z"}}}}}}},"/changelog":{"get":{"tags":["system"],"summary":"Historia wydań (strona HTML, PL) zbudowana z /releases.json","responses":{"200":{"description":"Strona HTML z historią wydań"}}}},"/api/agents/directory":{"get":{"tags":["agent"],"summary":"Internet of Agents — public registry of federation members (RFC-INTERNETOFAGENTS-001)","parameters":[{"name":"zone","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by zone (S0-S4, testnet, default)"},{"name":"model","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by provider/model (partial ILIKE match)"},{"name":"role","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by role in capability_manifest (partial match)"},{"name":"status","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by status (active, unverified, pending…)"},{"name":"q","in":"query","required":false,"schema":{"type":"string"},"description":"Search by did or name (partial match)"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"maximum":200}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","default":0}}],"responses":{"200":{"description":"Agent directory","content":{"application/json":{"schema":{"type":"object"},"example":{"federation":"UNIONAI-GENESIS-0N40I4-20260512","network_status":"TESTNET","spec_version":"1.0","timestamp":"2026-05-25T00:00:00Z","total":3,"limit":50,"offset":0,"agents":[{"did":"did:k0nsult:hermes:lem","name":"hermes-lem","role":"code","model":"deepseek","skills":["code","spec"],"zone":"default","runtime_type":"external","trust_tier":"T1","status":"active","last_seen":"2026-05-25T00:00:00Z","registered_at":"2026-05-22T00:00:00Z","is_demo":false}]}}}},"500":{"description":"DB error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"DB error"}}}}}}}}}