Every host calls the same function:
Service::dispatch(cmd: &str, args: &Value, host_path: Option<&Path>) -> Result<Value, ApiError>
- Web:
POST /api/<cmd>, body = JSON object, headerAuthorization: Bearer <token>,Content-Type: application/json. - Desktop:
invoke('rpc', { cmd, args }).
Commands other than status, touch, create_vault, unlock, unlock_quick, join_vault, quick_info need an unlocked vault and otherwise fail with locked.
Errors
| Wire string | Meaning |
|---|---|
locked |
The vault is locked; the UI returns to the unlock screen |
throttled:N |
Too many failed attempts; retry in N seconds |
cancelled |
The user closed a native dialog |
| other text | A short, non-sensitive message (invalid input, vault already exists, …) |
HTTP status codes: 200, 400 (bad request), 401 (token), 403 (host/origin), 404, 405, 413, 415. The error body is {"error": "<wire string>"}.
Session and vault
| Command | Arguments | Result |
|---|---|---|
status |
none | {exists, unlocked, sync, sync_label, can_pick, theme, vault_custom, vault_label, idle_lock, quick, settings} |
touch |
none | {ok}; resets the idle timer |
create_vault |
password |
{recovery_key}; applies the password policy |
unlock |
password or recovery |
{ok} |
unlock_quick |
secret (b64url, 32 bytes) |
{ok} |
join_vault |
kind (folder/bundle), password; path from native dialog |
{ok} (desktop only) |
lock |
none | {ok} |
change_password |
old, new |
{recovery_key} (new); throttled; removes the quick slot |
open_vault_folder |
none; path from native dialog | {ok} (desktop only, vault must be locked). Folder must be absolute, a real directory (not a symlink), and either contain vault.json or be empty (dot-files ignored). The current sync target is refused. Locks, loads that vault's own settings and sync target, remembers the choice. Does not reset the unlock throttle |
use_default_vault |
none | {ok} (desktop only, vault must be locked); back to the host's default vault folder |
Notes and folders
| Command | Arguments | Result |
|---|---|---|
tree |
none | nested {folders:[{id,name,folders,notes}], notes:[…], favorites:[…]}; a note entry is {id,title,modified,pinned,favorite,locked,archived}. Archived and trashed notes are left out |
get_note |
id |
{id,title,body,parent,created,modified,pinned,favorite,archived,trashed,locked,open}; also for a note in the trash (read-only). A locked note has an empty body unless open |
create_note |
title?, body?, parent? |
{id} |
create_folder |
name, parent? |
{id} (nesting ≤ 64) |
update_note |
id, body?, title? |
{ok} |
rename_folder |
id, name |
{ok} |
move_item |
id, parent (or null) |
{ok}; refuses cycles |
delete_item |
id |
{ok}; deletes for good (tombstone). The UI uses trash_item |
search |
query (≤ 200 chars) |
list of {id,title,modified}; in memory only |
id and parent are 32 lowercase hex characters.
Note features
See Note features. Every id / note argument must be a 32-hex object id.
| Command | Arguments | Result |
|---|---|---|
set_note_flags |
id, any of pinned, favorite, archived (bool) |
{ok} |
archive |
none | list of note entries |
trash_item / restore_item |
id |
{ok}; a folder takes everything inside with it |
trash |
none | [{id,type,title,trashed}], newest first |
delete_forever |
id (must be in the trash) |
{ok} |
empty_trash |
none | {count} |
revisions |
id |
[{id,created,title,chars}], newest first |
get_revision |
id |
{title,body} |
restore_revision |
id |
{id} of the note |
add_attachment |
note, name, data (base64url, ≤ 4 MB decoded) |
{id,name,mime,bytes}; metadata removed |
attachments |
note |
list of {id,name,mime,bytes} |
get_attachment |
id |
{name,mime,data} |
save_attachment |
id, name (suggested); path from a native save dialog |
{ok} (desktop only; not inside the vault folder) |
remove_attachment |
id |
{ok} |
lock_note |
id, password (password policy applies) |
{ok}; refused if the note has attachments |
open_note |
id, password |
{ok}; throttled separately from the vault |
close_note |
id |
{ok} |
remove_note_lock |
id, password |
{ok}; throttled |
tags |
none | [{tag,count}] |
tag_notes |
tag |
list of note entries (#a includes #a/b) |
backlinks |
id |
list of note entries that link to it |
resolve_link |
title |
{id} or {id: null} |
graph |
none | {nodes:[{id,title,links}], edges:[[from,to]]} |
import_files |
files (≤ 5000 × {path,text}), folder?, into? (folder id) |
{notes,folders,skipped,folder,refs}; refs = [{note, refs:[[link, path]]}], the files of the export each note links to (*/name = find by file name) |
import_attachment |
note, links (≤ 500, as returned in refs), name, data (base64url, ≤ 4 MB) |
{id,name,mime,bytes}; the file becomes an attachment (metadata removed) and those links point to it |
Sync
| Command | Arguments | Result |
|---|---|---|
sync_now |
auto? (bool) |
report {pushed,pulled,conflicts,problems,…}; auto:true does not reset the idle timer |
set_sync |
kind; path from native dialog |
{ok} (desktop) |
clear_sync |
none | {ok} |
Settings
set_theme takes theme = "dark" (default), "light" or "system". Allowed while locked (not secret); stored app-wide, not per vault. status.theme reports it.
set_settings accepts any of: auto_sync (bool), sync_interval (15–3600), live_preview (bool), toolbar (bool), start_note ("blank" or "last"), auto_lock (seconds: 0 = never, otherwise 60–7200). Defaults: true, 60, true, true, "blank", the host's idle limit (300 s). status.settings.auto_lock and status.idle_lock report the effective value; 0 means never. With start_note = "last" the UI opens the most recently modified note after unlocking. status.settings returns the current values.
Export
| Command | Arguments | Result |
|---|---|---|
export_markdown |
ids (32-hex array; absent = everything); folder from native dialog |
{count} (desktop) |
export_download |
ids |
{name, mime, count, data} where data is base64url; a single note returns the .md, anything else a .zip (≤ 32 MiB) |
A selected folder includes everything inside it. An empty ids array is an error. A note's attachments are written to a <note> files folder beside its .md, and its attachment: links become relative links to them (a note with attachments is therefore always a .zip in export_download). count is the number of notes.
Security key
| Command | Arguments | Result |
|---|---|---|
quick_info |
none | {enrolled, cred_id, salt, rp_id, label} |
quick_enroll |
password, secret, cred_id, salt, rp_id, label? |
{ok}; password check is throttled |
quick_remove |
none | {ok} |
Example
# the token is printed in the URL after '#'
curl -s -X POST http://localhost:PORT/api/status \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{}'