Skip to content
cyril-fl edited this page Nov 30, 2026 · 2 revisions

API

Everything goes through a JSON API under /api. The web app, the CLI and the MCP server are its clients; so can be your scripts. The full contract is docs/swagger.yaml (OpenAPI, generated from the routes), and the rules behind it are in the reference.

Running it

make api                                                         # in Docker, with WEB_ORIGIN set in .env
go run ./cmd/tide-server serve --origin http://localhost:3000    # or directly on the machine
Flag Role
--addr Listening address, 127.0.0.1:8080 by default
--origin The allowed origin of the web app
--web A folder of the generated app, served at the same address as the API
--add-user-mode Who creates an account: invitation (default) or public
--published In a container, the address published on the machine side (TIDE_LISTEN)
--mcp-addr Also serves the MCP tools over HTTP at /mcp on that address, with its OAuth
--mcp-published The MCP's address on the machine side (TIDE_MCP_LISTEN)

Authentication

Everything but POST /login, GET /add-user and POST /signup requires a session, otherwise 401.

  • Session cookie. Login sets a tide_session cookie (HttpOnly, Secure, SameSite=Strict), which lasts 30 days extended at each request. This is the web app's.
  • Bearer token. A script sends Authorization: Bearer <token>. A CLI token comes from tide login; an API token (notes_…) from tide add token or Settings > Applications.

Tokens

An API token does everything the account does on notes, folders, tags and files, but does not manage the account: its tokens, its password, its settings, the purge, the logout and the admin routes answer 403. A --read-only token reads and changes nothing. The database only keeps the token's fingerprint (SHA-256). An expired token is refused (401), then purged by the hourly cleanup.

Routes

The prefix is /api.

Resource Routes
Accounts (admin) GET, DELETE /users/{id}, GET, POST /invites, DELETE /invites/{id}
Account creation GET /add-user[?invite=<token>], POST /signup
Account POST /login, POST /logout, GET, PATCH /me, PATCH /me/password, DELETE /me/data
Notes POST /notes, GET, PATCH, DELETE /notes/{id}, GET /notes/{id}/neighbors, GET /pinned
Versions GET, POST /notes/{id}/versions, GET /notes/{id}/versions/{version}
Folders GET, POST /folders, GET, PATCH, DELETE /folders/{id}
Browse GET /items?parent=<uuid>, POST /move
Tags GET, POST /tags, GET, PATCH, DELETE /tags/{value}
Graph GET /graph, GET /graph/notes
Search GET /search?q=<text>, GET /recent
Links GET /links/broken
Trash GET, DELETE /trash, DELETE /trash/{id}, POST /restore
Export and import GET /export (zip), POST /import?parent=<uuid>
Images and attachments GET /files, POST /files?name=<name>, GET /files/{id}
Live changes GET /events (server-sent events)

The exact bodies and answers are in the OpenAPI file.

Errors

Errors have the form {"error": "..."}, with status 400, 401, 403, 404, 409, 413, 415, 429 or 500. Only an unknown route (404) and an unhandled method (405) answer in plain text.

Writing a note

  • PATCH /notes/{id} only changes the fields sent. {"pinned": true} alone pins the note without touching its text or its modification date. It answers the complete note.
  • Without tags, the tags are the #words of the content. With tags, this list rewrites the content: "tags": [] erases all its #words.
  • {"readonly": true} locks the note: content and tags are then refused (409), unless with "readonly": false in the same request.
  • With updated_at (read by GET, or created_at for a note never modified), content and tags are refused (409) if the note changed since: a device left open never overwrites what another wrote.
  • POST /notes/{id}/versions with {"content": "..."} keeps a text refused by a 409 as a version marked conflict, so as not to lose it.
  • The API refuses a title field for a note: the title comes from the text (Titles and tags).

Live changes

GET /api/events is a stream of server-sent events: the account's changes, whichever client made them. The web app uses it to refresh. Your reverse proxy must not buffer it.

From the browser's point of view

The web app calls /api on its own origin in production, and on NUXT_PUBLIC_API_BASE in development. A page outside WEB_ORIGIN cannot call the API.

Clone this wiki locally