API v1: design (endpoints, auth, token permissions) #121
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jfro/rm-analyzer#121
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of the Ink Lantern rename & API project. Goal: a full JSON API so native clients can do what the web app does.
Write
docs/api.mdas the design, before the endpoints are built:/api/v1, JSON,Authorization: Bearer rma_…using the same API keys as MCP (RmAnalyzer.ApiKeys,Scope.libraryfor item limits).toolslist andcan_writemap onto endpoints, and what has to be added for things MCP doesn't cover (naming, migration, defaults for existing keys so no key gains access silently, settings UI).API v1 design draft is ready (full text:
docs/api.md, handed to Haystack; on my local branchdocs/121-api-design, not pushed).Shape: JSON at
/api/v1,Authorization: Bearer rma_…(same keys as MCP; chat answer tokens not accepted). Cursor pagination (limit≤ 200,next_cursor), one error body{"error": {"code", "message", "permission"}}, 404 for anything a limited key doesn't reach, ETags from the document hash + transcription time,Idempotency-Keyon writes.Permissions
ApiKeys.allowed?/2is used by both NotesMCP and the API, so there's one permission path.grantsfield (default[], never nil), so existing keys gain nothing:suggestions,quick_notes,todos,sync. Grants that write also needcan_write. They can't be new tool names, becausetools: nilkeys would get them silently.Scope.libraryisn't honoured by Sorting, Tagging, Todos or QuickNotes, so the API filters per item the wayAgentTools.suggestions/1does. Limited-key tests are required for each.Endpoints (perm in brackets; † needs can_write)
GET /me[any],GET /openapi.json[public]GET /documents,/documents/:id,/folders,/tags[list_documents];/documents/:id/pages,/pages/:n[read_pages];/pages/:n/image[view_page];/search[search_notes];/stats[get_stats];/suggestions[list_suggestions];/changes,/events[list_changes];GET /sync[any]POST /documents/:id/pages[add_page / draw_page],POST /notebooks[create_notebook],POST /folders[create_folder],PATCH /documents/:id[move_document],POST /reports[make_pdf],POST /pdfs[upload_pdf],POST /reviews[send_for_review]POST /suggestions/moves/:id/{approve,reject,undo,retry},/suggestions/tags/:id/{approve,dismiss}[suggestions †];GET|POST /quick-notes[quick_notes, † to add];GET /todos/pages,POST /todos/pages/:id/sync[todos, † to sync];POST /sync[sync]Change feed:
/changes?since=returns the same objects and integer cursor as webhooks andlist_changes, plus an SSE/eventsstream of refetch hints. Gaps to close: add atranscribedchange kind (OCR finishing isn't a change today), and tell clients in mcp.md to ignore change kinds they don't know.Out of v1: backups/restore, settings, key management, chat, issue filing, transcription edits, rename/delete, raw file downloads, and APNs push. The design says why for each.
Choices for Jeremy (my pick first)
grantslist ✔ / b) new tool names / c) one all-or-nothing switchapigrant first/events✔ / b) poll only / c) + APNsopenapi.json+ route-match test, no new dep ✔ / b) open_api_spex / c) noneThe design landed on main in docs/api.md with PR #125 (merge
d588049), status agreed: Jeremy took all eight picks (A to H) on Dec 3. Closing; the writes and grants follow in #123 / PR #126.