API reference
Every endpoint of the Scholar Lens API, grouped by router. This page is generated from the OpenAPI schema by python -m scripts.api_docs in backend; don't edit it by hand. A running API serves the full schema, with every field, at /openapi.json and an interactive version at /docs.
All endpoints are under /api. They take and return JSON unless a body says multipart. The browser authenticates with cookies (see Security and access); the browser extension with a bearer token, limited to the capture endpoints. Errors return {"detail": {"code": "...", "message": "..."}}.
admin
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| POST | /api/admin/restart | Restart the API (and the worker) so saved settings take effect; back in a few seconds. | RestartOut | |
| GET | /api/admin/settings | Read Settings | SettingsOut | |
| PATCH | /api/admin/settings | Save Settings | SettingsPatch | SettingsOut |
| POST | /api/admin/settings/test | Check a service with the values on the page (blank secrets: the saved ones). | TestRequest | TestOut |
| GET | /api/admin/voices | Read Voices | VoicesOut | |
| PUT | /api/admin/voices | Save Voices | VoicesIn | VoicesOut |
| POST | /api/admin/voices/local/test | Voice two short lines on the local service with these voices; returns a WAV. | LocalIn | |
| POST | /api/admin/voices/local/voices | Ask the local service which engine it runs and which voices it has (Kokoro, Chatterbox …). | LocalIn | LocalVoicesOut |
| POST | /api/admin/voices/test | Voice two short lines with these values (the saved key when none is given); returns a WAV. | ProviderIn | |
| POST | /api/admin/voices/{provider_id}/wake | Try a resting provider again from the next recording. | VoicesOut |
agent
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/agent/graph | Nodes and edges of the compiled graph; conditional edges are the routing decisions. |
auth
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| POST | /api/auth/login | Login | Credentials | UserOut |
| POST | /api/auth/logout | Logout | 204, no body | |
| POST | /api/auth/logout-all | Logout All | 204, no body | |
| POST | /api/auth/refresh | Refresh | UserOut | |
| POST | /api/auth/setup | Create the first admin account. Only allowed while the database has no users. | Credentials | 201, UserOut |
| POST | /api/auth/signup | Self sign-up (when an admin has turned it on): the account waits for an admin's approval. | Credentials | 202, SignupAccepted |
| GET | /api/auth/status | Status | AuthStatus | |
| GET | /api/me | Me | UserOut | |
| GET | /api/me/account | The Account page: who you are, where you're signed in, how much you store. | AccountOut | |
| POST | /api/me/password | Change Password | PasswordChange | 204, no body |
| DELETE | /api/me/sessions/{session_id} | Sign out one device (its refresh token stops working; its access token runs out within minutes). | 204, no body |
capture
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| POST | /api/capture | Save the page the student is looking at: its rendered HTML (html), or the file the tab shows (file, e.g. a PDF). It becomes a private Library item, indexed as usual and added to the chosen Space, with the citation metadata the page carries or metadata sent with a file (a reference's title, authors, DOI…). Saving the same address (or the same file) again returns the earlier item; a file for an item saved as a reference only fills it in. | multipart | 201, CaptureOut |
| GET | /api/capture/check | Whether the page is already in the student's Library (the popup says so before saving). | CaptureCheck | |
| POST | /api/capture/explain | A line or two on each of the top references (at most 10): what it covers and what it can explain for this article, written by the local model from the title and abstract. | ExplainRequest | ExplainOut |
| POST | /api/capture/highlight | A highlight from the browser, saved as a note on the student's item for this page: searchable, and citable as "Your note". 404 not_saved when the page isn't in the Library yet (the extension then saves it first). | HighlightCreate | 201, NoteOut |
| POST | /api/capture/link | A web page the captured page links to (a blog, a guide), ticked by the student: Scholar Lens fetches it like a URL pasted in the Library (public addresses only). The student's earlier item for the same address is reused. | VideoCapture | 201, CaptureOut |
| POST | /api/capture/references | Bring the ticked references into the Library and the Space: open-access ones are fetched by Scholar Lens (arXiv, OpenAlex copies) and indexed; the rest are saved as references only. One already in the Library is just added to the Space. | ImportReferences | 201, list of CaptureOut |
| POST | /api/capture/resolve | Titles, abstracts and availability for the references a page lists, most related to the article and Space first, so the student can tick the few they need. Nothing is saved. | ResolveRequest | list of ResolvedReference |
| POST | /api/capture/video | A YouTube video found on a page, into the Library (its captions, with timestamps) and the Space. The student's earlier import of the same video is reused. | VideoCapture | 201, CaptureOut |
| GET | /api/me/tokens | List Tokens | list of ApiTokenOut | |
| POST | /api/me/tokens | A token for the browser extension. The secret is in this response only; it is stored hashed. | ApiTokenCreate | 201, ApiTokenCreated |
| DELETE | /api/me/tokens/{token_id} | The extension using this token stops working at its next call. | 204, no body |
code
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| DELETE | /api/cells/{cell_id} | Delete Cell | 204, no body | |
| GET | /api/cells/{cell_id}/files/{index} | Cell File | ||
| POST | /api/cells/{cell_id}/run | Run a cell again, edited or not; its outputs are replaced. | CellRerun | CellOut |
| GET | /api/threads/{thread_id}/cells | List Cells | list of CellOut | |
| POST | /api/threads/{thread_id}/cells | Run new code in the chat's kernel (variables from earlier cells are there). | CellIn | 201, CellOut |
| GET | /api/threads/{thread_id}/cells/export | Export Cells | ||
| POST | /api/threads/{thread_id}/kernel/restart | Forget the chat's variables: the next cell starts a fresh kernel. |
invites
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/invites/{token} | What a link is for, so the page can say "join <Space> as a viewer" or "create your account". | InviteInfo | |
| POST | /api/invites/{token}/accept | Accept Space Invite | SpaceOut | |
| GET | /api/spaces/{space_id}/invites | List Space Invites | list of InviteOut | |
| POST | /api/spaces/{space_id}/invites | Create Space Invite | InviteCreate | 201, InviteOut |
| DELETE | /api/spaces/{space_id}/invites/{invite_id} | Revoke Space Invite | 204, no body |
library
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/duplicates | The warnings waiting for the student's decision, newest first. | list of DuplicatePairOut | |
| POST | /api/duplicates/check | The first pass, before saving: items that look the same from their header details. | DuplicateCheck | DuplicateCheckOut |
| POST | /api/duplicates/{pair_id} | replace: the new item takes the existing one's place (Spaces, notes, study sets) and the existing one is deleted. keep: both stay and this pair is not raised again. ignore: the new item is deleted. | DuplicateDecision | DuplicateDecided |
| GET | /api/figures/{figure_id}/image | A figure as PNG, for whoever may read its document (answers show it inline). | ||
| GET | /api/library | view=mine: the user's own items (published ones too); view=shared: the shared Library; view=all: both (what the user can add to a Space). | list of DocumentOut | |
| GET | /api/library/chunks/{chunk_id} | Get Chunk | ChunkOut | |
| POST | /api/library/import | Queue an import of a web page, YouTube video, arXiv paper or DOI. Fetching happens in the worker. | ImportRequest | 202, DocumentOut |
| GET | /api/library/publish-requests | Admins see everyone's requests (pending first); a user sees their own. | list of PublishRequestOut | |
| DELETE | /api/library/publish-requests/{request_id} | The requester withdraws a request that is still waiting. | 204, no body | |
| POST | /api/library/publish-requests/{request_id}/approve | Approve Publish Request | PublishDecision | PublishRequestOut |
| POST | /api/library/publish-requests/{request_id}/reject | Reject Publish Request | PublishDecision | PublishRequestOut |
| POST | /api/library/search | Search | SearchRequest | SearchResponse |
| POST | /api/library/upload | Upload Document | multipart | 202, DocumentOut |
| DELETE | /api/library/{document_id} | Delete Document | 204, no body | |
| GET | /api/library/{document_id} | Get Document | DocumentOut | |
| PATCH | /api/library/{document_id} | Patch Document | DocumentPatch | DocumentOut |
| GET | /api/library/{document_id}/figures | The figures, tables and large images found in a PDF item, in page order. | list of FigureOut | |
| GET | /api/library/{document_id}/file | Download File | ||
| GET | /api/library/{document_id}/page-numbering | How book pages map to PDF pages: "book page 45 is PDF page 61"; none when they are the same. | PageNumbering | |
| PUT | /api/library/{document_id}/page-numbering | Correct the book page numbers: the student reads one page's printed number ("PDF page 61 shows 45"). | PageNumberingIn | PageNumbering |
| POST | /api/library/{document_id}/preview | The indexed text of a scope, by section (the preview of an item that is not a PDF). | ScopeRequest | list of TextPart |
| POST | /api/library/{document_id}/publish | An admin puts an item in the shared Library: their own, or one a user asked about. | DocumentOut | |
| POST | /api/library/{document_id}/publish-request | Ask an admin to put one of your items in the shared Library. | PublishRequestCreate | 201, PublishRequestOut |
| POST | /api/library/{document_id}/reindex | Reindex Document | 202, DocumentOut | |
| POST | /api/library/{document_id}/resolve-scope | Show what a scope like "9.1-9.6" or "pp. 239-262" (book pages), or picked sections, resolves to. | ScopeRequest | ScopeOut |
| GET | /api/library/{document_id}/text | The item's indexed text in reading order, by section: what answers search and cite. Neighbouring chunks repeat a little of each other (the splitter's overlap); that is removed here. | DocumentText | |
| GET | /api/library/{document_id}/toc | Get Toc | list of TocEntry | |
| POST | /api/library/{document_id}/unpublish | Take an item out of the shared Library. It goes back to being its owner's alone; other people's Spaces that used it lose it. | DocumentOut | |
| GET | /api/stats | Stats |
memory
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/memory | The student's own memory and, with space_id, that Space's. Rejected proposals are left out. | MemoryList | |
| POST | /api/memory | Add Memory | MemoryCreate | 201, MemoryOut |
| DELETE | /api/memory/{item_id} | Delete Memory | 204, no body | |
| PATCH | /api/memory/{item_id} | Edit the text, or accept (active) / reject (rejected) a proposal. | MemoryPatch | MemoryOut |
notes
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/notes | The student's notes, on one item or all of them, filtered by words in the note or the highlight. | list of NoteOut | |
| POST | /api/notes | Create Note | NoteCreate | 201, NoteOut |
| DELETE | /api/notes/{note_id} | Delete Note | 204, no body | |
| PATCH | /api/notes/{note_id} | Edit Note | NotePatch | NoteOut |
notifications
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/notifications | List Notifications | list of NotificationOut | |
| POST | /api/notifications/read-all | Mark All Read | 204, no body | |
| GET | /api/notifications/unread | Unread | Unread | |
| POST | /api/notifications/{notification_id}/read | Mark Read | 204, no body |
podcasts
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/podcasts | List Podcasts | list of PodcastOut | |
| POST | /api/podcasts | Start an episode: gather the material and outline it. It waits as a draft for review. | PodcastCreate | 202, PodcastOut |
| POST | /api/podcasts/extract | Read an uploaded file (PDF, DOCX, PPTX, EPUB, Markdown, HTML, TXT) into plain text for a "text" source. | multipart | ExtractOut |
| POST | /api/podcasts/script | Record a hand-written two-host script: each segment's turns are voiced and joined into one MP3. | ScriptCreate | 202, PodcastOut |
| POST | /api/podcasts/uploads | Keep a file for episodes (not added to the Library). It is read with POST …/read; a file that looks like a whole book says so first (large), so the student can upload one chapter instead. | multipart | UploadOut |
| GET | /api/podcasts/uploads/{upload_id}/file | Upload Download | ||
| GET | /api/podcasts/uploads/{upload_id}/page-numbering | Upload Numbering | PageNumbering | |
| POST | /api/podcasts/uploads/{upload_id}/preview | The text of the picked pages or sections (the preview of a file without pages). | UploadScopeIn | list of TextPart |
| POST | /api/podcasts/uploads/{upload_id}/read | Read Upload | UploadOut | |
| POST | /api/podcasts/uploads/{upload_id}/resolve-scope | Upload Resolve | UploadScopeIn | ScopeOut |
| GET | /api/podcasts/uploads/{upload_id}/toc | Upload Toc | list of TocEntry | |
| GET | /api/podcasts/voices | The voice engine and the voices it offers (empty with a reason when the service is not set up). | ||
| DELETE | /api/podcasts/{podcast_id} | Delete Podcast | 204, no body | |
| GET | /api/podcasts/{podcast_id} | Get Podcast | PodcastDetail | |
| POST | /api/podcasts/{podcast_id}/analyse | Make the concept map and the script-quality report again (e.g. for an episode written before M14f). | 202, PodcastOut | |
| GET | /api/podcasts/{podcast_id}/audio | The episode's MP3 (range requests work, so the player can seek). | ||
| POST | /api/podcasts/{podcast_id}/generate | Write and check the script of the reviewed outline, then record it. A failed episode whose outline was approved resumes at its first unwritten segment. | 202, PodcastOut | |
| PATCH | /api/podcasts/{podcast_id}/outline | Save the reviewed outline: segments kept, reordered or edited, and new instructions. | OutlinePatch | PodcastDetail |
| POST | /api/podcasts/{podcast_id}/outline/regenerate | Outline again, with an extra instruction for the outline (e.g. "less on history, more on matching"). | RegenerateIn | 202, PodcastOut |
| POST | /api/podcasts/{podcast_id}/record | Record a written episode again or for the first time (after the voice service was set up). | 202, PodcastOut | |
| GET | /api/podcasts/{podcast_id}/transcript.md | The script to read or keep: segments with their core idea and key points, then the lines with page references. | ||
| GET | /api/podcasts/{podcast_id}/transcript.vtt | Captions for the player and offline listening: one cue per line, with the speaker's name. | ||
| GET | /api/podcasts/{podcast_id}/video | Download Video | ||
| POST | /api/podcasts/{podcast_id}/video | Make the episode's video (map, source, captions; 1920x1080) in the background; a notice follows. | 202, PodcastDetail |
quality
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/eval/reports | Newest first; answer-eval reports only (retrieval-only runs print to the console). | list | |
| GET | /api/eval/reports/{name} | One report with every question's score and judge verdict (the evidence text is left out to keep it small). |
sign-in
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| POST | /api/runs/{run_id}/sign-in | Open the gated source of a paused run in the sign-in browser. | SigninStart | |
| DELETE | /api/sign-in/{session_id} | Cancel Sign In | 204, no body | |
| POST | /api/sign-in/{session_id}/done | Save the sign-in (the site's cookies, sealed) and let the paused run continue with it. | SigninDone | |
| DELETE | /api/sign-ins/{grant_id} | Revoke Grant | 204, no body | |
| GET | /api/spaces/{space_id}/sign-ins | Your saved sign-ins in a Space (other members' stay private). | list of GrantOut |
spaces
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/spaces | List Spaces | list of SpaceOut | |
| POST | /api/spaces | Create Space | SpaceCreate | 201, SpaceOut |
| DELETE | /api/spaces/{space_id} | Deletes the space and its chats (everyone's). Library items stay in their owners' libraries. | 204, no body | |
| GET | /api/spaces/{space_id} | Get Space | SpaceOut | |
| PATCH | /api/spaces/{space_id} | Patch Space | SpacePatch | SpaceOut |
| GET | /api/spaces/{space_id}/members | List Members | list of MemberOut | |
| DELETE | /api/spaces/{space_id}/members/{user_id} | The owner removes someone, or a member leaves. | 204, no body | |
| PATCH | /api/spaces/{space_id}/members/{user_id} | Change Member | MemberPatch | MemberOut |
| GET | /api/spaces/{space_id}/sources | List Sources | list of SourceOut | |
| POST | /api/spaces/{space_id}/sources | Assign a library item to the space, optionally narrowed with a scope such as "9.1-9.6". Editors add their own items or shared-Library ones; everyone in the Space can then read them. | SourceAssign | 201, SourceOut |
| DELETE | /api/spaces/{space_id}/sources/{document_id} | Remove Source | 204, no body | |
| PATCH | /api/spaces/{space_id}/sources/{document_id} | Patch Source | SourcePatch | SourceOut |
study
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| DELETE | /api/study/attempts/{attempt_id} | Delete Attempt | 204, no body | |
| GET | /api/study/attempts/{attempt_id} | Get Attempt | AttemptOut | |
| POST | /api/study/attempts/{attempt_id}/retry | Mark the short answers again after the model failed. | 202, AttemptOut | |
| GET | /api/study/guide | The student's ready study sets in a Space (all, or those listed in sets) as one study guide: Markdown, Word or PDF, cited in APA, Harvard or BibTeX. | ||
| DELETE | /api/study/items/{item_id} | Delete an item; a concept takes its links with it. | 204, no body | |
| PATCH | /api/study/items/{item_id} | Edit an item's wording. Its citation stays; an item the student rewrote is theirs to vouch for. | StudyItemPatch | StudyItemOut |
| POST | /api/study/items/{item_id}/review | Record how well the student recalled a card and schedule its next review (SM-2). | ReviewRequest | StudyItemOut |
| GET | /api/study/review | Cards to review now in a Space (or one set): those due, oldest first, then up to 20 new ones. | ReviewQueue | |
| GET | /api/study/sets | List Sets | list of StudySetOut | |
| POST | /api/study/sets | Queue a set for the whole Space, or for one of its sources narrowed by a scope such as "9.6". | StudySetCreate | 202, StudySetOut |
| DELETE | /api/study/sets/{set_id} | Delete Set | 204, no body | |
| GET | /api/study/sets/{set_id} | Get Set | StudySetDetail | |
| GET | /api/study/sets/{set_id}/attempts | List Attempts | list of AttemptOut | |
| POST | /api/study/sets/{set_id}/attempts | Hand in a quiz. Multiple choice is marked at once; short answers are marked by the model (a job). | AttemptCreate | 202, AttemptOut |
| GET | /api/study/sets/{set_id}/export | The set's cards (or glossary terms) as CSV or as an Anki package. | ||
| POST | /api/study/sets/{set_id}/retry | Generate a failed set again (its scope may have been indexed since). | 202, StudySetOut |
system
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/health | Database status decides the HTTP code; model status comes from the last probe. | HealthOut | |
| GET | /api/system/probe | System Probe | ||
| GET | /api/system/status | What the server is configured to use, without secrets, plus whether the reranker answers (Settings page). |
threads
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/runs/{run_id} | Get Run | ||
| POST | /api/runs/{run_id}/cancel | Cancel Run | ||
| POST | /api/runs/{run_id}/continue | Continue a run that failed or timed out from its last finished step (its checkpoint in this app's database), with a fresh time budget: on a slow machine a Comprehensive answer often stops in verification, after the search and the draft are done. Refused when anything came after it in the chat (another question, a regenerated answer), so two answers never compete. | RunAccepted | |
| GET | /api/runs/{run_id}/events | Stream Events | ||
| GET | /api/runs/{run_id}/log | Every stored event of a run in order, as JSON: the Agent Flow replays a past run from this. | ||
| POST | /api/runs/{run_id}/resume | Answer a paused run: skip the gated source, or run (or skip) the answer's code. | ResumeRequest | RunAccepted |
| POST | /api/runs/{run_id}/resume/upload | Answer a paused run with the gated source's file: it is attached to the chat, indexed, and searched for this answer in place of the source. | RunAccepted | |
| GET | /api/spaces/{space_id}/threads | List Threads | list of ThreadOut | |
| POST | /api/spaces/{space_id}/threads | Create Thread | ThreadCreate | 201, ThreadOut |
| DELETE | /api/threads/{thread_id} | Delete Thread | 204, no body | |
| GET | /api/threads/{thread_id} | Get Thread | ThreadOut | |
| PATCH | /api/threads/{thread_id} | Patch Thread | ThreadPatch | ThreadOut |
| PUT | /api/threads/{thread_id}/branch | Show the branch through a message (its newest continuation). | BranchRequest | ThreadOut |
| GET | /api/threads/{thread_id}/export | Export Thread | ||
| DELETE | /api/threads/{thread_id}/files/{file_id} | Delete Attachment | 204, no body | |
| GET | /api/threads/{thread_id}/messages | List Messages | MessagePage | |
| POST | /api/threads/{thread_id}/messages | Post Message | 202, RunAccepted | |
| POST | /api/threads/{thread_id}/messages/{message_id}/regenerate | Answer a question again, optionally in another style; the new answer is a sibling of the old. | RegenerateRequest | 202, RunAccepted |
users
| Method | Path | What it does | Body | Returns |
|---|---|---|---|---|
| GET | /api/users | Accounts waiting for approval first, then the rest by creation. | list of UserOut | |
| POST | /api/users | Create User | UserCreate | 201, UserOut |
| DELETE | /api/users/{user_id} | Delete an account and everything it owns (Spaces, chats, Library items, notes, study sets). Their items in the shared Library stay: they move to the admin who deletes the account. | 204, no body | |
| PATCH | /api/users/{user_id} | Patch User | UserPatch | UserOut |
| POST | /api/users/{user_id}/approve | Let a self sign-up in: the account becomes an active user. | UserOut | |
| POST | /api/users/{user_id}/reject | Turn a self sign-up down: the account is removed (it has no content yet). | 204, no body | |
| GET | /api/users/{user_id}/view | Their Spaces (with their own chats and study sets in each), Library items and how many notes. | Overview | |
| GET | /api/users/{user_id}/view/notes | View Notes | list of NoteOut | |
| GET | /api/users/{user_id}/view/study-sets/{set_id} | View Study Set | StudySetDetail | |
| GET | /api/users/{user_id}/view/threads/{thread_id} | View Thread | ThreadOut | |
| GET | /api/users/{user_id}/view/threads/{thread_id}/messages | Older messages of a chat (paging back). | MessagePage |