{"openapi":"3.1.0","info":{"title":"Cedula agent HTTP API","version":"1.2.0","description":"Scoped complete reads, history, conditional atomic edits, persistent receipts and selected-note exports. Read is the default. Browser grants require an open paired tab; signed-in server grants survive tab closure and API restart."},"servers":[{"url":"/api/agent/v1"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"schemas":{"Mutation":{"$schema":"https://json-schema.org/draft/2020-12/schema","anyOf":[{"type":"object","properties":{"operations":{"minItems":1,"maxItems":100,"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","const":"set_view"},"viewId":{"type":"string","minLength":1,"maxLength":100},"language":{"type":"string","enum":["szekcio-summary","szekcio-chart","szekcio-metric","szekcio-layout"]},"definition":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}},"required":["type","viewId","language","definition"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"replace_section"},"sectionId":{"type":"string","minLength":1,"maxLength":100},"source":{"type":"string","minLength":1,"maxLength":100000}},"required":["type","sectionId","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"append_section"},"afterSectionId":{"anyOf":[{"type":"string","minLength":1,"maxLength":100},{"type":"null"}]},"source":{"type":"string","minLength":1,"maxLength":100000}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"set_cells"},"tableId":{"type":"string","minLength":1,"maxLength":100},"changes":{"minItems":1,"maxItems":100,"type":"array","items":{"type":"object","properties":{"rowId":{"type":"string","minLength":1,"maxLength":100},"columnId":{"type":"string","minLength":1,"maxLength":100},"value":{"anyOf":[{"type":"string","maxLength":100000},{"type":"boolean"},{"type":"null"}]},"provenance":{"type":"object","properties":{"sourceUrl":{"type":"string","maxLength":2000,"format":"uri"},"observedAt":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"},{"type":"null"}]},"currency":{"type":"string","pattern":"^[A-Z]{3}$"}},"additionalProperties":false},"override":{"type":"boolean"}},"required":["rowId","columnId","value"],"additionalProperties":false}}},"required":["type","tableId","changes"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"insert_rows"},"tableId":{"type":"string","minLength":1,"maxLength":100},"afterRowId":{"anyOf":[{"type":"string","minLength":1,"maxLength":100},{"type":"null"}]},"rows":{"minItems":1,"maxItems":100,"type":"array","items":{"type":"object","properties":{"values":{"type":"object","propertyNames":{"type":"string","minLength":1,"maxLength":100},"additionalProperties":{"anyOf":[{"type":"string","maxLength":100000},{"type":"boolean"},{"type":"null"}]}},"provenance":{"type":"object","properties":{"sourceUrl":{"type":"string","maxLength":2000,"format":"uri"},"observedAt":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"},{"type":"null"}]},"currency":{"type":"string","pattern":"^[A-Z]{3}$"}},"additionalProperties":false}},"required":["values"],"additionalProperties":false}}},"required":["type","tableId","rows"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"set_formula"},"tableId":{"type":"string","minLength":1,"maxLength":100},"columnId":{"type":"string","minLength":1,"maxLength":100},"rowId":{"type":"string","minLength":1,"maxLength":100},"formula":{"anyOf":[{"type":"object","properties":{"expression":{"type":"string","minLength":1,"maxLength":2048},"bindings":{"default":{},"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"object","properties":{"tableId":{"type":"string","minLength":1,"maxLength":100},"columnId":{"type":"string","minLength":1,"maxLength":100},"rowId":{"type":"string","maxLength":100},"rangeId":{"type":"string","minLength":1,"maxLength":100},"rowIds":{"maxItems":100000,"type":"array","items":{"type":"string","minLength":1,"maxLength":100}},"columnIds":{"maxItems":1000,"type":"array","items":{"type":"string","minLength":1,"maxLength":100}}},"required":["tableId","columnId"],"additionalProperties":false}}},"required":["expression","bindings"],"additionalProperties":false},{"type":"null"}]}},"required":["type","tableId","columnId","formula"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"set_override"},"tableId":{"type":"string","minLength":1,"maxLength":100},"rowId":{"type":"string","minLength":1,"maxLength":100},"columnId":{"type":"string","minLength":1,"maxLength":100},"enabled":{"type":"boolean"},"value":{"anyOf":[{"type":"string","maxLength":100000},{"type":"boolean"},{"type":"null"}]},"provenance":{"type":"object","properties":{"sourceUrl":{"type":"string","maxLength":2000,"format":"uri"},"observedAt":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"},{"type":"null"}]},"currency":{"type":"string","pattern":"^[A-Z]{3}$"}},"additionalProperties":false}},"required":["type","tableId","rowId","columnId","enabled"],"additionalProperties":false}]}}},"required":["operations"],"additionalProperties":false},{"type":"object","properties":{"content":{"type":"string","maxLength":4000000},"sectionIds":{"maxItems":100000,"type":"array","items":{"type":"string","pattern":"^(?:[a-f\\d]{32}|[a-f\\d]{8}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{12})$"}}},"required":["content","sectionIds"],"additionalProperties":false}]},"CreateNote":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"folderId":{"anyOf":[{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"},{"type":"null"}]},"content":{"default":"","type":"string","maxLength":4000000}},"required":["title","folderId","content"],"additionalProperties":false},"Grant":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"id":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"},"scope":{"type":"string","enum":["workspace","notes"]},"noteIds":{"default":[],"maxItems":100,"type":"array","items":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"}},"permissions":{"default":["notes:read"],"minItems":1,"maxItems":4,"type":"array","items":{"type":"string","enum":["notes:read","notes:history","notes:write","notes:create"]}},"write":{"type":"object","properties":{"noteIds":{"maxItems":100,"type":"array","items":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"}},"fields":{"maxItems":100,"type":"array","items":{"type":"object","properties":{"noteId":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"},"tableId":{"type":"string","minLength":1,"maxLength":100},"columnIds":{"minItems":1,"maxItems":100,"type":"array","items":{"type":"string","minLength":1,"maxLength":100}}},"required":["noteId","tableId","columnIds"],"additionalProperties":false}},"operations":{"maxItems":8,"type":"array","items":{"type":"string","enum":["replace_section","append_section","set_cells","insert_rows","set_formula","set_override","replace_source","set_view"]}}},"additionalProperties":false},"createDestination":{"type":"object","properties":{"folderId":{"anyOf":[{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"},{"type":"null"}]}},"required":["folderId"],"additionalProperties":false}},"required":["id","scope","noteIds","permissions"],"additionalProperties":false}}},"paths":{"/session":{"get":{"summary":"Inspect permissions, workspace binding, availability and limits","security":[{"bearerAuth":[]}],"parameters":[],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/notes":{"get":{"summary":"List/search granted note metadata","security":[{"bearerAuth":[]}],"parameters":[],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}},"post":{"summary":"Create a note in the explicitly permitted destination","security":[{"bearerAuth":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","maxLength":200}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateNote"}}}},"responses":{"201":{"description":"Durably committed creation receipt"},"403":{"description":"Missing create permission or wrong destination"},"409":{"description":"Idempotency mismatch"}}}},"/notes/{noteId}":{"get":{"summary":"Read the complete current note","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/notes/{noteId}/structure":{"get":{"summary":"Read note/table structure","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/notes/{noteId}/tables/{tableId}":{"get":{"summary":"Read the entire table","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}},{"name":"tableId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/notes/{noteId}/download":{"get":{"summary":"Download complete Markdown, lossless JSON or standalone HTML","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}},{"name":"format","in":"query","schema":{"type":"string","enum":["markdown","json","html"],"default":"markdown"}},{"name":"includeHistory","in":"query","description":"Requires notes:history; JSON includes all section versions and document audit","schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/notes/{noteId}/operations":{"post":{"summary":"Validate and commit one atomic batch","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}},{"name":"If-Match","in":"header","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Mutation"}}}},"responses":{"200":{"description":"Persisted receipt with revision/ETag, saved=true, sync state, changed targets and diagnostics"},"202":{"description":"Unknown transport outcome; resolve operationId"},"403":{"description":"Exceeds write/field grant"},"409":{"description":"Active human edit, concurrent batch or idempotency mismatch"},"412":{"description":"Stale revision; refetch and reconcile"},"422":{"description":"Invalid batch; no changes committed"},"428":{"description":"Missing If-Match or Idempotency-Key"}}}},"/notes/{noteId}/source":{"put":{"summary":"Conditionally replace source with explicit unchanged-section identities; prohibited for field grants","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}},{"name":"If-Match","in":"header","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["content","sectionIds"],"additionalProperties":false,"properties":{"content":{"type":"string","maxLength":4000000},"sectionIds":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Committed receipt"},"412":{"description":"Stale revision"},"422":{"description":"Ambiguous/invalid identity map or unsupported-source loss"},"428":{"description":"Missing preconditions"}}}},"/notes/{noteId}/changes":{"get":{"summary":"Read paginated document audit; requires notes:history","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/notes/{noteId}/revisions":{"get":{"summary":"Read bounded complete source snapshots with identities and actor; requires notes:history. Restore by conditional source replacement.","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/notes/{noteId}/sections":{"get":{"summary":"Read active and deleted section metadata; requires notes:history","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/notes/{noteId}/sections/{sectionId}/versions":{"get":{"summary":"Read complete historical paragraph versions; requires notes:history","security":[{"bearerAuth":[]}],"parameters":[{"name":"noteId","in":"path","required":true,"schema":{"type":"string"}},{"name":"sectionId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/operations/{operationId}":{"get":{"summary":"Resolve this grant’s committed, failed, pending or unknown operation","security":[{"bearerAuth":[]}],"parameters":[{"name":"operationId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/exports":{"post":{"summary":"Prepare a complete ZIP for selected permitted notes; temporary cache expires after five minutes","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["noteIds"],"additionalProperties":false,"properties":{"noteIds":{"type":"array","minItems":1,"maxItems":1000,"uniqueItems":true,"items":{"type":"string","format":"uuid"}},"includeHistory":{"type":"boolean","default":false}}}}}},"responses":{"201":{"description":"Ready exportId, filename, bytes, expiresAt and authenticated downloadUrl"},"413":{"description":"Complete encoded archive exceeds the 8 MiB relay limit"},"429":{"description":"At most ten temporary exports per grant"}}}},"/exports/{exportId}":{"get":{"summary":"Inspect an unexpired private export","security":[{"bearerAuth":[]}],"parameters":[{"name":"exportId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}},"/exports/{exportId}/download":{"get":{"summary":"Download the complete binary ZIP; active grant still required","security":[{"bearerAuth":[]}],"parameters":[{"name":"exportId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete scoped result; no viewport truncation"},"401":{"description":"Expired or invalid grant"},"404":{"description":"Missing or ungranted resource"},"503":{"description":"Paired browser unavailable"}}}}}}