{"openapi":"3.0.3","info":{"title":"OpenMemory","version":"0.1.0","description":"Memory for agents: facts with full-text recall, a journal, typed records, an approval ledger, KV, events, and nightly dreaming. Create a space with POST /v1/spaces, then send its key as a bearer token."},"servers":[{"url":"https://api.openmemory.sh"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Your space key (om_...). Create one with POST /v1/spaces."},"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-API-Key"}},"schemas":{"NewSpace":{"type":"object","properties":{"space_id":{"type":"string"},"api_key":{"type":"string","description":"Shown once. Store it; it cannot be recovered."},"next":{"type":"string"}},"required":["space_id","api_key","next"]},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{"nullable":true}}},"required":["code","message"]}},"required":["error"]},"Space":{"type":"object","properties":{"space_id":{"type":"string"},"timezone":{"type":"string"},"dream_mode":{"$ref":"#/components/schemas/DreamMode"},"created_at":{"type":"string"},"last_seen_at":{"type":"string"},"last_dream_at":{"type":"string","nullable":true},"delete_after":{"type":"string","description":"The space is deleted if unused until then."},"usage":{"type":"object","additionalProperties":{"type":"number"}},"limits":{"type":"object","additionalProperties":{"type":"number"}}},"required":["space_id","timezone","dream_mode","created_at","last_seen_at","last_dream_at","delete_after","usage","limits"]},"DreamMode":{"type":"string","enum":["client","server","off"]},"SpacePatch":{"type":"object","properties":{"timezone":{"type":"string","maxLength":64},"dream_mode":{"$ref":"#/components/schemas/DreamMode"}}},"Context":{"type":"object","properties":{"now":{"type":"string"},"timezone":{"type":"string"},"today":{"type":"string"},"profile":{"type":"object","properties":{"text":{"type":"string","description":"Pinned and core facts, one per line, within budget_chars."},"facts_included":{"type":"number"},"facts_total":{"type":"number"},"truncated":{"type":"boolean"},"dream_summary":{"type":"string","nullable":true,"description":"The owner profile written by the last dream, if any."}},"required":["text","facts_included","facts_total","truncated","dream_summary"]},"due":{"type":"array","items":{"$ref":"#/components/schemas/Record"},"description":"Open records due within due_within_days."},"open_records":{"type":"array","items":{"$ref":"#/components/schemas/Record"},"description":"Open records in the requested collections."},"actions":{"type":"array","items":{"$ref":"#/components/schemas/Action"},"description":"Pending, approved, and executing actions."},"journal":{"type":"array","items":{"$ref":"#/components/schemas/JournalEntry"}},"weekly":{"allOf":[{"$ref":"#/components/schemas/JournalEntry"},{"nullable":true}]},"kv":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"nullable":true}}},"last_dream":{"type":"object","nullable":true,"properties":{"id":{"type":"string"},"status":{"type":"string"},"finished_at":{"type":"string","nullable":true},"report":{"nullable":true}},"required":["id","status","finished_at"]}},"required":["now","timezone","today","profile","due","open_records","actions","journal","weekly","kv","last_dream"]},"Record":{"type":"object","properties":{"id":{"type":"string"},"collection":{"type":"string"},"key":{"type":"string","nullable":true},"status":{"type":"string"},"due_at":{"type":"string","nullable":true},"data":{"type":"object","additionalProperties":{"nullable":true}},"origin":{"$ref":"#/components/schemas/Origin"},"version":{"type":"integer"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","collection","key","status","due_at","data","origin","version","created_at","updated_at"]},"Origin":{"type":"string","enum":["user","agent","dream"]},"Action":{"type":"object","properties":{"id":{"type":"string"},"class":{"type":"string"},"summary":{"type":"string"},"payload":{"type":"object","additionalProperties":{"nullable":true}},"payload_hash":{"type":"string"},"preconditions":{"type":"array","items":{"nullable":true}},"meta":{"type":"object","additionalProperties":{"nullable":true}},"idempotency_key":{"type":"string"},"status":{"$ref":"#/components/schemas/ActionStatus"},"receipt":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"expires_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","class","summary","payload","payload_hash","preconditions","meta","idempotency_key","status","receipt","expires_at","created_at","updated_at"]},"ActionStatus":{"type":"string","enum":["pending","approved","executing","done","failed","denied","expired","superseded","blocked"]},"JournalEntry":{"type":"object","properties":{"kind":{"type":"string","enum":["day","week"]},"date":{"type":"string"},"summary":{"type":"string"},"decisions":{"type":"array","items":{"type":"string"}},"open_loops":{"type":"array","items":{"type":"string"}},"source_refs":{"type":"array","items":{"type":"string"}},"origin":{"$ref":"#/components/schemas/Origin"},"updated_at":{"type":"string"}},"required":["kind","date","summary","decisions","open_loops","source_refs","origin","updated_at"]},"BatchInput":{"type":"object","properties":{"ops":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"op":{"type":"string","enum":["memory.remember"]},"input":{"$ref":"#/components/schemas/MemoryInput"}},"required":["op","input"]},{"type":"object","properties":{"op":{"type":"string","enum":["memory.update"]},"id":{"type":"string"},"patch":{"$ref":"#/components/schemas/MemoryPatch"}},"required":["op","id","patch"]},{"type":"object","properties":{"op":{"type":"string","enum":["memory.delete"]},"id":{"type":"string"}},"required":["op","id"]},{"type":"object","properties":{"op":{"type":"string","enum":["journal.put"]},"date":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"input":{"$ref":"#/components/schemas/JournalInput"}},"required":["op","date","input"]},{"type":"object","properties":{"op":{"type":"string","enum":["record.put"]},"collection":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i"},"input":{"$ref":"#/components/schemas/RecordInput"}},"required":["op","collection","input"]},{"type":"object","properties":{"op":{"type":"string","enum":["record.update"]},"collection":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i"},"id":{"type":"string"},"patch":{"$ref":"#/components/schemas/RecordPatch"}},"required":["op","collection","id","patch"]},{"type":"object","properties":{"op":{"type":"string","enum":["record.delete"]},"collection":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i"},"id":{"type":"string"}},"required":["op","collection","id"]},{"type":"object","properties":{"op":{"type":"string","enum":["action.propose"]},"input":{"$ref":"#/components/schemas/ActionInput"}},"required":["op","input"]},{"type":"object","properties":{"op":{"type":"string","enum":["action.transition"]},"id":{"type":"string"},"input":{"$ref":"#/components/schemas/ActionTransition"}},"required":["op","id","input"]},{"type":"object","properties":{"op":{"type":"string","enum":["kv.set"]},"ns":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i"},"key":{"type":"string","minLength":1,"maxLength":200},"input":{"$ref":"#/components/schemas/KvInput"}},"required":["op","ns","key","input"]},{"type":"object","properties":{"op":{"type":"string","enum":["kv.delete"]},"ns":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i"},"key":{"type":"string","minLength":1,"maxLength":200}},"required":["op","ns","key"]},{"type":"object","properties":{"op":{"type":"string","enum":["event.append"]},"input":{"$ref":"#/components/schemas/EventInput"}},"required":["op","input"]}]},"minItems":1,"maxItems":200}},"required":["ops"],"description":"Applied in one transaction: all ops succeed or none do."},"MemoryInput":{"type":"object","properties":{"subject":{"type":"string","maxLength":200,"default":"","description":"Who or what the fact is about, e.g. 'Sam'."},"text":{"type":"string","minLength":1,"maxLength":4000,"description":"The fact itself, in one or two sentences."},"tier":{"$ref":"#/components/schemas/Tier"},"tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":50},"maxItems":20,"default":[]},"source_ref":{"type":"string","maxLength":500,"default":"","description":"Where the fact came from (message id, URL). No message bodies."},"pinned":{"type":"boolean","default":false,"description":"Pinned facts are never changed by dreaming."},"origin":{"type":"string","enum":["user","agent"],"default":"agent","description":"'user' when the person stated it; dreaming never rewrites those."},"expires_at":{"type":"string","nullable":true,"format":"date-time"}},"required":["text"]},"Tier":{"type":"string","enum":["core","long","scratch"],"default":"long","description":"core = always in context; long = recalled on demand; scratch = short-lived."},"MemoryPatch":{"type":"object","properties":{"subject":{"type":"string","maxLength":200},"text":{"type":"string","minLength":1,"maxLength":4000},"tier":{"$ref":"#/components/schemas/Tier"},"tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":50},"maxItems":20},"source_ref":{"type":"string","maxLength":500},"pinned":{"type":"boolean"},"expires_at":{"type":"string","nullable":true,"format":"date-time"}}},"JournalInput":{"type":"object","properties":{"summary":{"type":"string","maxLength":4000,"default":""},"decisions":{"type":"array","items":{"type":"string","maxLength":500},"maxItems":50,"default":[]},"open_loops":{"type":"array","items":{"type":"string","maxLength":500},"maxItems":50,"default":[]},"source_refs":{"type":"array","items":{"type":"string","maxLength":500},"maxItems":50,"default":[]},"kind":{"type":"string","enum":["day","week"],"default":"day"},"merge":{"type":"boolean","default":false,"description":"Append to an existing entry instead of replacing it."}}},"RecordInput":{"type":"object","properties":{"key":{"type":"string","minLength":1,"maxLength":200,"description":"Optional unique key within the collection; writing it again updates the record."},"status":{"type":"string","maxLength":50,"default":""},"due_at":{"type":"string","nullable":true,"format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true},"default":{}},"origin":{"type":"string","enum":["user","agent"],"default":"agent"}}},"RecordPatch":{"type":"object","properties":{"status":{"type":"string","maxLength":50},"due_at":{"type":"string","nullable":true,"format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true},"description":"Shallow-merged into the existing data. Set a field to null to clear it."},"expected_version":{"type":"integer","minimum":1,"description":"Fail with 409 unless the record is at this version."}}},"ActionInput":{"type":"object","properties":{"class":{"type":"string","minLength":1,"maxLength":64,"description":"Kind of action, e.g. email_reply, calendar_hold."},"summary":{"type":"string","minLength":1,"maxLength":1000,"description":"One line the owner reads when approving."},"payload":{"type":"object","additionalProperties":{"nullable":true},"description":"Exactly what will be executed."},"preconditions":{"type":"array","items":{"nullable":true},"maxItems":20,"default":[]},"meta":{"type":"object","additionalProperties":{"nullable":true},"default":{}},"idempotency_key":{"type":"string","minLength":1,"maxLength":200,"description":"Same key + same payload returns the existing action."},"expires_at":{"type":"string","nullable":true,"format":"date-time"}},"required":["class","summary","payload","idempotency_key"]},"ActionTransition":{"type":"object","properties":{"from":{"allOf":[{"$ref":"#/components/schemas/ActionStatus"},{"description":"The status you expect the action to be in now."}]},"to":{"$ref":"#/components/schemas/ActionStatus"},"receipt":{"type":"object","additionalProperties":{"nullable":true},"description":"What the execution did. Usually sent with to=done or to=failed."}},"required":["from","to"]},"KvInput":{"type":"object","properties":{"value":{"nullable":true,"description":"Any JSON value."},"expected_version":{"type":"integer","minimum":0,"description":"0 = only create; n = only update if at version n. Omit to upsert."},"expires_at":{"type":"string","nullable":true,"format":"date-time"}}},"EventInput":{"type":"object","properties":{"kind":{"type":"string","minLength":1,"maxLength":64},"key":{"type":"string","maxLength":200,"default":""},"status":{"type":"string","maxLength":64,"default":""},"detail":{"type":"object","additionalProperties":{"nullable":true},"default":{},"description":"Small structured detail. Do not put message bodies or secrets here."}},"required":["kind"]},"Memory":{"type":"object","properties":{"id":{"type":"string"},"subject":{"type":"string"},"text":{"type":"string"},"tier":{"$ref":"#/components/schemas/Tier"},"tags":{"type":"array","items":{"type":"string"}},"source_ref":{"type":"string"},"pinned":{"type":"boolean"},"origin":{"$ref":"#/components/schemas/Origin"},"expires_at":{"type":"string","nullable":true},"recall_count":{"type":"integer"},"last_recalled_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","subject","text","tier","tags","source_ref","pinned","origin","expires_at","recall_count","last_recalled_at","created_at","updated_at"]},"ForgetResult":{"type":"object","properties":{"dry_run":{"type":"boolean"},"memories":{"type":"array","items":{"type":"string"}},"records":{"type":"array","items":{"type":"string"}},"journal":{"type":"array","items":{"type":"string"}}},"required":["dry_run","memories","records","journal"]},"ForgetInput":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string"},"maxItems":200,"description":"Memory ids to delete."},"query":{"type":"string","minLength":2,"maxLength":200,"description":"Delete memories matching ALL of these words; records and journal text containing this exact phrase."},"scopes":{"type":"array","items":{"type":"string","enum":["memories","records","journal"]},"default":["memories"]},"journal_mode":{"type":"string","enum":["redact","delete"],"default":"redact"},"dry_run":{"type":"boolean","default":false}}},"KvItem":{"type":"object","properties":{"ns":{"type":"string"},"key":{"type":"string"},"value":{"nullable":true},"version":{"type":"integer"},"expires_at":{"type":"string","nullable":true},"updated_at":{"type":"string"}},"required":["ns","key","version","expires_at","updated_at"]},"Event":{"type":"object","properties":{"id":{"type":"integer"},"at":{"type":"string"},"kind":{"type":"string"},"key":{"type":"string"},"status":{"type":"string"},"detail":{"type":"object","additionalProperties":{"nullable":true}}},"required":["id","at","kind","key","status","detail"]},"DreamRun":{"type":"object","properties":{"id":{"type":"string"},"mode":{"type":"string"},"status":{"type":"string","description":"running | awaiting_client | done | failed | undone | abandoned"},"report":{"type":"object","additionalProperties":{"nullable":true}},"started_at":{"type":"string"},"finished_at":{"type":"string","nullable":true}},"required":["id","mode","status","report","started_at","finished_at"]},"DreamJob":{"type":"object","nullable":true,"properties":{"run_id":{"type":"string"},"instructions":{"type":"string","description":"System prompt for your model."},"input":{"type":"object","additionalProperties":{"nullable":true},"description":"Send this to your model as the user message (JSON)."},"output_schema":{"type":"object","additionalProperties":{"nullable":true},"description":"JSON Schema the model's answer must match."},"max_changes":{"type":"number"}},"required":["run_id","instructions","input","output_schema","max_changes"]},"DreamResult":{"type":"object","properties":{"merges":{"type":"array","items":{"type":"object","properties":{"keep_id":{"type":"string"},"remove_ids":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":20},"subject":{"type":"string","maxLength":200},"text":{"type":"string","minLength":1,"maxLength":4000}},"required":["keep_id","remove_ids"]},"maxItems":50,"default":[],"description":"Near-duplicate facts to merge into keep_id. Optional new wording for keep_id."},"promotions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"tier":{"$ref":"#/components/schemas/Tier"}},"required":["id","tier"]},"maxItems":50,"default":[],"description":"Tier changes, e.g. often-recalled long facts to core."},"contradictions":{"type":"array","items":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string"},"minItems":2,"maxItems":10},"note":{"type":"string","minLength":1,"maxLength":500}},"required":["ids","note"]},"maxItems":20,"default":[],"description":"Facts that disagree. They are flagged, not changed."},"weekly_digest":{"type":"object","nullable":true,"properties":{"week_start":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"summary":{"type":"string","maxLength":4000},"decisions":{"type":"array","items":{"type":"string","maxLength":500},"maxItems":50,"default":[]},"open_loops":{"type":"array","items":{"type":"string","maxLength":500},"maxItems":50,"default":[]}},"required":["week_start","summary"]},"proposals":{"type":"array","items":{"type":"object","properties":{"text":{"type":"string","minLength":1,"maxLength":500},"counterparty":{"type":"string","maxLength":200},"due":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"source_date":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["text"]},"maxItems":20,"default":[],"description":"Unfinished items worth tracking. Stored in the dream.proposals collection with status 'proposed'."},"profile":{"type":"string","maxLength":4000,"description":"A short profile of the owner built only from the facts given."}}}},"parameters":{}},"paths":{"/v1/spaces":{"post":{"operationId":"space_create","tags":["Space"],"summary":"Create a memory space and get its key","description":"No account needed. The key is shown once. Rate limited per IP address.","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"timezone":{"type":"string","maxLength":64,"description":"IANA timezone, e.g. Europe/Athens"}}}}}},"responses":{"201":{"description":"Space created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewSpace"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/space":{"get":{"operationId":"space_get","tags":["Space"],"summary":"Show this space's settings, usage, and limits","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"responses":{"200":{"description":"The space","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Space"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"space_update","tags":["Space"],"summary":"Change the timezone or dream mode","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpacePatch"}}}},"responses":{"200":{"description":"Updated space","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Space"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"space_delete","tags":["Space"],"summary":"Delete this space and everything in it","description":"Permanent. Export first if you want a copy.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"string"}},"required":["deleted"]}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/export":{"get":{"operationId":"space_export","tags":["Space"],"summary":"Export everything in this space as JSON","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"responses":{"200":{"description":"Full export","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/context":{"get":{"operationId":"context_get","tags":["Context"],"summary":"Everything an agent needs at the start of a run, in one call","description":"Core profile (bounded), due and open records, pending actions, recent journal days, the latest weekly digest, and selected KV namespaces.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"integer","minimum":200,"maximum":20000,"default":4000},"required":false,"name":"budget_chars","in":"query"},{"schema":{"type":"integer","nullable":true,"minimum":0,"maximum":31,"default":7},"required":false,"name":"journal_days","in":"query"},{"schema":{"type":"integer","nullable":true,"minimum":0,"maximum":90,"default":7},"required":false,"name":"due_within_days","in":"query"},{"schema":{"type":"string","maxLength":500,"description":"Comma-separated KV namespaces to include, e.g. settings,cursors."},"required":false,"description":"Comma-separated KV namespaces to include, e.g. settings,cursors.","name":"kv","in":"query"},{"schema":{"type":"string","maxLength":500,"description":"Comma-separated record collections for due items. Default: all."},"required":false,"description":"Comma-separated record collections for due items. Default: all.","name":"collections","in":"query"}],"responses":{"200":{"description":"Context","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Context"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/batch":{"post":{"operationId":"batch_apply","tags":["Context"],"summary":"Apply several writes atomically","description":"All ops succeed or none do. Version and status checks abort the whole batch with 409. Ops that read first (record.update, journal merge, action.propose) see the state from before the batch.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchInput"}}}},"responses":{"200":{"description":"One result per op, in order","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"nullable":true}}},"required":["results"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/memories":{"post":{"operationId":"memory_remember","tags":["Memories"],"summary":"Remember a fact","description":"An identical fact (same subject and text) is returned instead of stored twice.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryInput"}}}},"responses":{"200":{"description":"Already known","content":{"application/json":{"schema":{"type":"object","properties":{"memory":{"$ref":"#/components/schemas/Memory"},"created":{"type":"boolean","enum":[false]}},"required":["memory","created"]}}}},"201":{"description":"Stored","content":{"application/json":{"schema":{"type":"object","properties":{"memory":{"$ref":"#/components/schemas/Memory"},"created":{"type":"boolean","enum":[true]}},"required":["memory","created"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"memory_recall","tags":["Memories"],"summary":"Recall facts by words, subject, tier, or tag","description":"Full-text search, accent- and case-insensitive. Without q, lists facts: pinned and core first.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","maxLength":500,"description":"Words to search for. Any word may match; best matches first."},"required":false,"description":"Words to search for. Any word may match; best matches first.","name":"q","in":"query"},{"schema":{"$ref":"#/components/schemas/Tier"},"required":false,"name":"tier","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"subject","in":"query"},{"schema":{"type":"string","maxLength":50},"required":false,"name":"tag","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"anyOf":[{"type":"boolean"},{"type":"string","enum":["true","false"]}],"default":true,"description":"Count this as a recall (feeds dreaming's promotion step)."},"required":false,"description":"Count this as a recall (feeds dreaming's promotion step).","name":"touch","in":"query"}],"responses":{"200":{"description":"Matching facts","content":{"application/json":{"schema":{"type":"object","properties":{"memories":{"type":"array","items":{"$ref":"#/components/schemas/Memory"}}},"required":["memories"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/memories/{id}":{"get":{"operationId":"memory_get","tags":["Memories"],"summary":"Get one fact","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The fact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Memory"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"memory_update","tags":["Memories"],"summary":"Change a fact","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryPatch"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Memory"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"memory_delete","tags":["Memories"],"summary":"Delete one fact","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"string"}},"required":["deleted"]}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/forget":{"post":{"operationId":"memory_forget","tags":["Memories"],"summary":"Forget: hard-delete matching facts, records, and journal text","description":"Facts match when they contain ALL the words in query. Records and journal entries match the exact phrase. Journal entries are redacted by default. Use dry_run to preview. Leaves content-free tombstones.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForgetInput"}}}},"responses":{"200":{"description":"What was (or would be) forgotten","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForgetResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/journal/{date}":{"put":{"operationId":"journal_put","tags":["Journal"],"summary":"Write the journal entry for a date","description":"One entry per date and kind. merge=true appends to an existing entry instead of replacing it.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"required":true,"name":"date","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JournalInput"}}}},"responses":{"200":{"description":"Saved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JournalEntry"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/journal":{"get":{"operationId":"journal_list","tags":["Journal"],"summary":"List journal entries, newest first","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","enum":["day","week"]},"required":false,"name":"kind","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":31},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Entries","content":{"application/json":{"schema":{"type":"object","properties":{"entries":{"type":"array","items":{"$ref":"#/components/schemas/JournalEntry"}}},"required":["entries"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/collections/{collection}/records":{"post":{"operationId":"record_put","tags":["Records"],"summary":"Create a record, or update the one with the same key","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Collection name, e.g. commitments, goals, routines."},"required":true,"description":"Collection name, e.g. commitments, goals, routines.","name":"collection","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordInput"}}}},"responses":{"200":{"description":"Updated by key","content":{"application/json":{"schema":{"type":"object","properties":{"record":{"$ref":"#/components/schemas/Record"},"created":{"type":"boolean","enum":[false]}},"required":["record","created"]}}}},"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"record":{"$ref":"#/components/schemas/Record"},"created":{"type":"boolean","enum":[true]}},"required":["record","created"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"record_query","tags":["Records"],"summary":"Query records by status, key, or due date","description":"Ordered by due date (undated last), then creation. Page with next_cursor.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Collection name, e.g. commitments, goals, routines."},"required":true,"description":"Collection name, e.g. commitments, goals, routines.","name":"collection","in":"path"},{"schema":{"type":"string","maxLength":200,"description":"Comma-separated statuses."},"required":false,"description":"Comma-separated statuses.","name":"status","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"key","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"due_before","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"cursor","in":"query"}],"responses":{"200":{"description":"Records","content":{"application/json":{"schema":{"type":"object","properties":{"records":{"type":"array","items":{"$ref":"#/components/schemas/Record"}},"next_cursor":{"type":"string","nullable":true}},"required":["records","next_cursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/collections/{collection}/records/{id}":{"get":{"operationId":"record_get","tags":["Records"],"summary":"Get one record","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Collection name, e.g. commitments, goals, routines."},"required":true,"description":"Collection name, e.g. commitments, goals, routines.","name":"collection","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The record","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Record"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"record_update","tags":["Records"],"summary":"Update a record (compare-and-set with expected_version)","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Collection name, e.g. commitments, goals, routines."},"required":true,"description":"Collection name, e.g. commitments, goals, routines.","name":"collection","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordPatch"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Record"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"record_delete","tags":["Records"],"summary":"Delete a record","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Collection name, e.g. commitments, goals, routines."},"required":true,"description":"Collection name, e.g. commitments, goals, routines.","name":"collection","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"string"}},"required":["deleted"]}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/actions":{"post":{"operationId":"action_propose","tags":["Actions"],"summary":"Propose an action that needs approval","description":"Gets a short id (A1, A2, ...) and status 'pending'. Reusing an idempotency_key with the same payload returns the existing action; with a different payload it is a 409.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActionInput"}}}},"responses":{"200":{"description":"Already proposed with this key","content":{"application/json":{"schema":{"type":"object","properties":{"action":{"$ref":"#/components/schemas/Action"},"created":{"type":"boolean","enum":[false]}},"required":["action","created"]}}}},"201":{"description":"Proposed","content":{"application/json":{"schema":{"type":"object","properties":{"action":{"$ref":"#/components/schemas/Action"},"created":{"type":"boolean","enum":[true]}},"required":["action","created"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"action_list","tags":["Actions"],"summary":"List actions, newest first (default: open ones)","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","maxLength":200,"description":"Comma-separated statuses. Default: pending,approved,executing."},"required":false,"description":"Comma-separated statuses. Default: pending,approved,executing.","name":"status","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Actions","content":{"application/json":{"schema":{"type":"object","properties":{"actions":{"type":"array","items":{"$ref":"#/components/schemas/Action"}}},"required":["actions"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/actions/{id}":{"get":{"operationId":"action_get","tags":["Actions"],"summary":"Get one action","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":32,"description":"Short action id, e.g. A7"},"required":true,"description":"Short action id, e.g. A7","name":"id","in":"path"}],"responses":{"200":{"description":"The action","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Action"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/actions/{id}/transition":{"post":{"operationId":"action_transition","tags":["Actions"],"summary":"Move an action to a new status, only if it is still in `from`","description":"Compare-and-set: two callers cannot both move A7 from approved to executing. Allowed: pending→approved|executing|denied|expired|superseded|blocked, approved→executing|denied|expired|superseded, executing→done|failed, blocked→pending|denied|superseded, failed→pending. Expired actions cannot be approved or executed.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":32,"description":"Short action id, e.g. A7"},"required":true,"description":"Short action id, e.g. A7","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActionTransition"}}}},"responses":{"200":{"description":"Moved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Action"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/kv/{ns}":{"get":{"operationId":"kv_list","tags":["KV"],"summary":"List keys in a namespace","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Namespace, e.g. settings or cursors. Names starting with '_' are reserved."},"required":true,"description":"Namespace, e.g. settings or cursors. Names starting with '_' are reserved.","name":"ns","in":"path"}],"responses":{"200":{"description":"Items","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/KvItem"}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/kv/{ns}/{key}":{"get":{"operationId":"kv_get","tags":["KV"],"summary":"Get one value","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Namespace, e.g. settings or cursors. Names starting with '_' are reserved."},"required":true,"description":"Namespace, e.g. settings or cursors. Names starting with '_' are reserved.","name":"ns","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":200},"required":true,"name":"key","in":"path"}],"responses":{"200":{"description":"The value","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KvItem"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"kv_set","tags":["KV"],"summary":"Set a value (optionally compare-and-set)","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Namespace, e.g. settings or cursors. Names starting with '_' are reserved."},"required":true,"description":"Namespace, e.g. settings or cursors. Names starting with '_' are reserved.","name":"ns","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":200},"required":true,"name":"key","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KvInput"}}}},"responses":{"200":{"description":"Saved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KvItem"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"kv_delete","tags":["KV"],"summary":"Delete a value","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9][a-z0-9_.-]*$/i","description":"Namespace, e.g. settings or cursors. Names starting with '_' are reserved."},"required":true,"description":"Namespace, e.g. settings or cursors. Names starting with '_' are reserved.","name":"ns","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":200},"required":true,"name":"key","in":"path"}],"responses":{"200":{"description":"deleted is false if it did not exist","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean"}},"required":["deleted"]}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/events":{"post":{"operationId":"event_append","tags":["Events"],"summary":"Append to the event log","description":"Capped per space; the oldest events are dropped first. Keep message bodies and secrets out of detail.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventInput"}}}},"responses":{"201":{"description":"Appended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"event_list","tags":["Events"],"summary":"List events, newest first","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","maxLength":64},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"since","in":"query"},{"schema":{"type":"integer","nullable":true},"required":false,"name":"before_id","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Events","content":{"application/json":{"schema":{"type":"object","properties":{"events":{"type":"array","items":{"$ref":"#/components/schemas/Event"}}},"required":["events"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dream":{"post":{"operationId":"dream_start","tags":["Dreaming"],"summary":"Start a dream now","description":"Runs housekeeping (expired, stale, and duplicate facts; expired actions and KV) immediately. Then, in client mode, waits for you to fetch the job and submit your model's result; in server mode, runs the model here.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"mode":{"$ref":"#/components/schemas/DreamMode"}}}}}},"responses":{"200":{"description":"The run","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DreamRun"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dream/runs":{"get":{"operationId":"dream_runs","tags":["Dreaming"],"summary":"List recent dream runs and their reports","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"responses":{"200":{"description":"Runs","content":{"application/json":{"schema":{"type":"object","properties":{"runs":{"type":"array","items":{"$ref":"#/components/schemas/DreamRun"}}},"required":["runs"]}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dream/runs/{id}/undo":{"post":{"operationId":"dream_undo","tags":["Dreaming"],"summary":"Undo every change a dream run made","description":"Available for 7 days after the run.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Undone","content":{"application/json":{"schema":{"type":"object","properties":{"run_id":{"type":"string"},"reverted":{"type":"number"}},"required":["run_id","reverted"]}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dream/jobs/next":{"get":{"operationId":"dream_job_next","tags":["Dreaming"],"summary":"Client-mode dreaming: get the job for your model","description":"Returns the waiting job, or null. With start_if_due=true, starts a dream first when the last one is older than the dream interval. Call it from a nightly run, give instructions + input to your model, and submit the JSON it returns.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"start_if_due","in":"query"}],"responses":{"200":{"description":"The job, if any","content":{"application/json":{"schema":{"type":"object","properties":{"job":{"$ref":"#/components/schemas/DreamJob"},"due":{"type":"boolean"}},"required":["job","due"]}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dream/jobs/{id}/result":{"post":{"operationId":"dream_job_submit","tags":["Dreaming"],"summary":"Client-mode dreaming: submit your model's result","description":"Validated against the job's output schema and applied under the safety rules: pinned and user-stated facts are never rewritten or removed, and at most max_changes are applied. Every change can be undone.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DreamResult"}}}},"responses":{"200":{"description":"Applied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DreamRun"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unknown space key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: version or status precondition failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}