{"openapi":"3.1.0","info":{"title":"Messages API","version":"0.1.0","description":"The one API every Messages client uses: the web app, the mobile and desktop apps, your scripts, and AI assistants. Everything acts on the caller's own data.\n\n- **Signing in.** Send a personal API key (`stk_…`, from Account → API keys) or a Logto access token as `Authorization: Bearer …`. In a signed-in browser, the session cookie goes along by itself, so *Try it out* works here without a key.\n- **Errors** are `{ \"error\": \"…\" }` with the status.\n- **Lists** come a page at a time: pass the answer's `nextCursor` back as `?cursor=`.\n\nGenerated from the server's routes and the shared contract. The MCP tools and the NATS events have their own references."},"tags":[{"name":"Conversations","description":"End-to-end encrypted: every message's content, and every file, is ciphertext the clients made."},{"name":"Calls","description":"One-to-one voice and video calls: the server keeps who called whom and signs the token that opens the call's room; the audio and video never pass through it."},{"name":"Encryption","description":"Keys sealed on the devices; the server never sees a passphrase or a readable key."},{"name":"Profiles"},{"name":"Notes"},{"name":"Files","description":"Uploads go straight to storage through presigned links."},{"name":"Account"},{"name":"Servers","description":"Every HomeLab environment runs its own copy of this app: a server. Each keeps the caller's list of them; switching merges it."},{"name":"API keys","description":"Managed with the web session or a Logto token, never with a key."},{"name":"Activity"},{"name":"Notifications"},{"name":"AI","description":"Answer 503 when the server has no AI provider."},{"name":"Commands"},{"name":"Sign-in","description":"The web app's own sign-in flow."},{"name":"Server"},{"name":"AI assistants (MCP)"},{"name":"Reference"}],"paths":{"/api/account/api-keys":{"get":{"operationId":"getApiAccountApiKeys","summary":"List API keys","description":"The caller's API keys: list, create (the secret is answered once), revoke (`?id=`).\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["API keys"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"The keys, without their secrets","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}}},"required":["items"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"postApiAccountApiKeys","summary":"Create an API key","description":"The caller's API keys: list, create (the secret is answered once), revoke (`?id=`).\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["API keys"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"expiresInDays":{"default":90,"anyOf":[{"type":"number","const":30},{"type":"number","const":90},{"type":"number","const":365},{"type":"null"}]}},"required":["name"]}}}},"responses":{"201":{"description":"The key, and its secret: shown this once","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"$ref":"#/components/schemas/ApiKey"},"token":{"type":"string"}},"required":["key","token"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteApiAccountApiKeys","summary":"Revoke an API key","description":"The caller's API keys: list, create (the secret is answered once), revoke (`?id=`).\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["API keys"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"204":{"description":"Revoked, or already gone"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/account/appearance":{"put":{"operationId":"putApiAccountAppearance","summary":"Save the appearance to the profile","description":"`PUT /api/account/appearance` with `{ \"appearance\": \"v1.dark.signal.blue\" }`: saves the shared appearance to the signed-in person's Logto profile, so the next browser they sign in to starts from it. The browser's `hl_appearance` cookie is already set by then; this only makes the choice durable.\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["Account"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"appearance":{"type":"string"}},"required":["appearance"]}}}},"responses":{"204":{"description":"Saved to the Logto profile"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider or the sign-in service failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/account/avatar":{"post":{"operationId":"postApiAccountAvatar","summary":"Set the profile photo","description":"The signed-in user's own avatar. POST the image bytes as the request body (Content-Type image/png|jpeg|webp|gif); DELETE goes back to the identity provider's picture, which the next sign-in restores.","tags":["Account"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"description":"The image's bytes: PNG, JPEG, WebP, or GIF, at most 2 MB","content":{"image/png":{"schema":{"type":"string","format":"binary"}},"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/webp":{"schema":{"type":"string","format":"binary"}},"image/gif":{"schema":{"type":"string","format":"binary"}}}},"responses":{"200":{"description":"The person, with the new photo","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"image":{"anyOf":[{"type":"string"},{"type":"null"}]},"emailVerified":{"type":"boolean"},"suspended":{"type":"boolean"}},"required":["id","name","email","image","emailVerified","suspended"],"additionalProperties":false}},"required":["user"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Too large","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteApiAccountAvatar","summary":"Remove the profile photo","description":"The signed-in user's own avatar. POST the image bytes as the request body (Content-Type image/png|jpeg|webp|gif); DELETE goes back to the identity provider's picture, which the next sign-in restores.","tags":["Account"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"The person, back to the sign-in provider's picture","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"image":{"anyOf":[{"type":"string"},{"type":"null"}]},"emailVerified":{"type":"boolean"},"suspended":{"type":"boolean"}},"required":["id","name","email","image","emailVerified","suspended"],"additionalProperties":false}},"required":["user"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/account/preferences":{"get":{"operationId":"getApiAccountPreferences","summary":"Get the global preferences","description":"The signed-in person's global preferences in their Logto profile (ADR 0033), for the web session (cookies); native clients reach the profile through Logto's Account API themselves.\n\n`GET` answers `{ \"preferences\": \"v2.…\" | null }`. `PUT` with `{ \"preferences\": \"v2.dark.signal.blue.cyberpunk.110.ru.<stamp>\" }` saves the value when it is newer than the profile's, with the v1 appearance in step, and answers with whichever the profile holds afterwards. The browser's `hl_preferences` cookie already carries the choice.\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["Account"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"The global preferences in the Logto profile, or null when it holds none (ADR 0033)","content":{"application/json":{"schema":{"type":"object","properties":{"preferences":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["preferences"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider or the sign-in service failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"putApiAccountPreferences","summary":"Save the global preferences","description":"The signed-in person's global preferences in their Logto profile (ADR 0033), for the web session (cookies); native clients reach the profile through Logto's Account API themselves.\n\n`GET` answers `{ \"preferences\": \"v2.…\" | null }`. `PUT` with `{ \"preferences\": \"v2.dark.signal.blue.cyberpunk.110.ru.<stamp>\" }` saves the value when it is newer than the profile's, with the v1 appearance in step, and answers with whichever the profile holds afterwards. The browser's `hl_preferences` cookie already carries the choice.\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["Account"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"preferences":{"type":"string"}},"required":["preferences"]}}}},"responses":{"200":{"description":"Saved when newer than the profile's; either way, the value the profile holds now","content":{"application/json":{"schema":{"type":"object","properties":{"preferences":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["preferences"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider or the sign-in service failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/account/servers":{"get":{"operationId":"getApiAccountServers","summary":"List servers","description":"The caller's server list (ADR 0032): the servers, each a HomeLab environment running its own copy of this app, that the web, mobile and clients switch between. `GET` answers this server and the list; `PUT { servers: [{ alias, url }] }` replaces the list (this server always stays in it). Each server keeps its own copy: switching to another one merges the list there with `POST /api/account/servers/sync`.","tags":["Servers"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"This server, and the caller's server list (this server always in it)","content":{"application/json":{"schema":{"type":"object","properties":{"current":{"$ref":"#/components/schemas/Server"},"items":{"type":"array","items":{"$ref":"#/components/schemas/Server"}}},"required":["current","items"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"putApiAccountServers","summary":"Replace the server list","description":"The caller's server list (ADR 0032): the servers, each a HomeLab environment running its own copy of this app, that the web, mobile and clients switch between. `GET` answers this server and the list; `PUT { servers: [{ alias, url }] }` replaces the list (this server always stays in it). Each server keeps its own copy: switching to another one merges the list there with `POST /api/account/servers/sync`.","tags":["Servers"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"servers":{"maxItems":20,"type":"array","items":{"$ref":"#/components/schemas/Server"}}},"required":["servers"]}}}},"responses":{"200":{"description":"The list as stored: this server added back, first, if it was left out","content":{"application/json":{"schema":{"type":"object","properties":{"current":{"$ref":"#/components/schemas/Server"},"items":{"type":"array","items":{"$ref":"#/components/schemas/Server"}}},"required":["current","items"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/account/servers/sync":{"post":{"operationId":"postApiAccountServersSync","summary":"Merge a server list from another server","description":"`POST { servers: [{ alias, url }] }`: merges a server list a client brings from another server into the caller's list here, as a client does on switching servers. The caller's servers here keep their order and names; new addresses are added after them. Answers the merged list; nothing is stored when nothing is new.","tags":["Servers"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"servers":{"maxItems":20,"type":"array","items":{"$ref":"#/components/schemas/Server"}}},"required":["servers"]}}}},"responses":{"200":{"description":"The merged list: the caller's servers here first, then the new addresses","content":{"application/json":{"schema":{"type":"object","properties":{"current":{"$ref":"#/components/schemas/Server"},"items":{"type":"array","items":{"$ref":"#/components/schemas/Server"}}},"required":["current","items"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/activity":{"get":{"operationId":"getApiActivity","summary":"List activity","description":"The caller's activity, newest first: `?category=business|technical` for one kind, `?limit` and `?cursor` to page. The sentences follow the web app's language cookie, else Accept-Language, else English.","tags":["Activity"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":50,"type":"integer","minimum":1,"maximum":200}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}},{"name":"category","in":"query","required":false,"schema":{"type":"string","enum":["business","technical"]}}],"responses":{"200":{"description":"A page of activity, newest first","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Activity"}},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["items","nextCursor"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/chat":{"post":{"operationId":"postApiAiChat","summary":"Chat with the AI","description":"Authenticated chat completion. The client sends messages; the server holds the gateway key and forwards to whichever model the platform routes. With `stream: true` the response is a text/event-stream of token deltas.","tags":["AI"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"messages":{"minItems":1,"maxItems":50,"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["system","user","assistant"]},"content":{"type":"string","minLength":1,"maxLength":32000}},"required":["role","content"]}},"model":{"type":"string","minLength":1,"maxLength":100},"temperature":{"type":"number","minimum":0,"maximum":2},"maxTokens":{"type":"integer","exclusiveMinimum":0,"maximum":8192},"stream":{"type":"boolean"}},"required":["messages"]}}}},"responses":{"200":{"description":"The reply; with `stream: true`, server-sent events of `data: {\"delta\"}`, ending `data: [DONE]` (an error arrives as `data: {\"error\"}`)","content":{"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string"},"model":{"type":"string"},"finishReason":{"anyOf":[{"type":"string"},{"type":"null"}]},"usage":{"anyOf":[{"type":"object","properties":{"prompt_tokens":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"completion_tokens":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"total_tokens":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["prompt_tokens","completion_tokens","total_tokens"],"additionalProperties":false},{"type":"null"}]}},"required":["text","model","finishReason","usage"],"additionalProperties":false}},"text/event-stream":{"schema":{"type":"string"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The AI provider is rate-limited or out of quota","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider or the sign-in service failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/models":{"get":{"operationId":"getApiAiModels","summary":"List AI models","description":"Lists the models the gateway is configured to route — a cheap way for a client to discover what's available (and to health-check the platform).","tags":["AI"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"The models the server's AI provider routes","content":{"application/json":{"schema":{"type":"object","properties":{"models":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string"},"owned_by":{"type":"string"}},"required":["id"],"additionalProperties":false}}},"required":["models"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The AI provider is rate-limited or out of quota","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider or the sign-in service failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/summarize":{"post":{"operationId":"postApiAiSummarize","summary":"Summarize a note","description":"Summarises one of the caller's own notes via the gateway or an OpenAI-compatible API (OpenAI, Ollama, …). Demonstrates the platform end-to-end: auth → ownership check → LLM → typed response.","tags":["AI"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"noteId":{"type":"string","minLength":1}},"required":["noteId"]}}}},"responses":{"200":{"description":"One or two sentences","content":{"application/json":{"schema":{"type":"object","properties":{"summary":{"type":"string"}},"required":["summary"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The AI provider is rate-limited or out of quota","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider or the sign-in service failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/transcribe":{"post":{"operationId":"postApiAiTranscribe","summary":"Transcribe audio","description":"Server-side speech-to-text. A `multipart/form-data` POST with an audio `file` (optional `language`) is transcribed via the gateway's whisper model. This is the portable replacement for the browser-only Web Speech API — every client (web, mobile, desktop) records audio and posts it here.","tags":["AI"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","description":"The audio, at most 25 MB (webm, mp4, wav, …)"},"language":{"type":"string","description":"The spoken language, e.g. `en`; detected when left out"}}}}}},"responses":{"200":{"description":"What was said","content":{"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string"}},"required":["text"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The AI provider is rate-limited or out of quota","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider or the sign-in service failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/attachments":{"get":{"operationId":"getApiAttachments","summary":"List files","description":"The caller's files: list (ready only; one note's with `?noteId=`), complete an upload (PATCH, after /api/storage/upload-url and the PUT to the bucket), delete (`?id=`).","tags":["Files"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":50,"type":"integer","minimum":1,"maximum":200}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}},{"name":"noteId","in":"query","required":false,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"A page of ready files, newest first","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Attachment"}},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["items","nextCursor"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"postApiAttachments","summary":"Not used: upload through a link","description":"The caller's files: list (ready only; one note's with `?noteId=`), complete an upload (PATCH, after /api/storage/upload-url and the PUT to the bucket), delete (`?id=`).","tags":["Files"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"405":{"description":"Ask for an upload link with POST /api/storage/upload-url, then complete it with PATCH /api/attachments","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"patchApiAttachments","summary":"Complete an upload","description":"The caller's files: list (ready only; one note's with `?noteId=`), complete an upload (PATCH, after /api/storage/upload-url and the PUT to the bucket), delete (`?id=`).\n\nAfter the bytes are PUT to the upload link: the server checks the object and marks the file ready. Completing a file already ready answers it again.","tags":["Files"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","minLength":1}},"required":["id"]}}}},"responses":{"200":{"description":"The ready file","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Attachment"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteApiAttachments","summary":"Delete a file","description":"The caller's files: list (ready only; one note's with `?noteId=`), complete an upload (PATCH, after /api/storage/upload-url and the PUT to the bucket), delete (`?id=`).","tags":["Files"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"204":{"description":"Deleted, or already gone"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/backchannel-logout":{"post":{"operationId":"postApiAuthBackchannelLogout","summary":"Back-channel logout (Logto calls it)","description":"OpenID Connect Back-Channel Logout, called by Logto (server to server) when the person signs out of any app sharing their Logto session. Registered in Logto as this client's back-channel logout URI, with \"session required\".","tags":["Sign-in"],"security":[],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["logout_token"],"properties":{"logout_token":{"type":"string","description":"Logto's signed logout token"}}}}}},"responses":{"200":{"description":"The named session's web sessions are revoked"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/refresh":{"post":{"operationId":"postApiAuthRefresh","summary":"Renew the web session","description":"Trades the web session's refresh cookie for a new access-token cookie. The client calls this when the API answers 401, then retries once.\n\nUses the refresh cookie; the web client calls it after a 401, then retries once.","tags":["Sign-in"],"security":[],"responses":{"204":{"description":"New session cookies are set"},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/session":{"get":{"operationId":"getApiAuthSession","summary":"Who am I","description":"The signed-in user, from the session cookie (web) or a Bearer token (native clients). 401 when there is none — the web client then tries a refresh.","tags":["Account"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"The signed-in person","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"image":{"anyOf":[{"type":"string"},{"type":"null"}]},"emailVerified":{"type":"boolean"},"suspended":{"type":"boolean"}},"required":["id","name","email","image","emailVerified","suspended"],"additionalProperties":false}},"required":["user"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/sign-in":{"get":{"operationId":"getApiAuthSignIn","summary":"Start web sign-in","description":"Starts the web sign-in: `GET /api/auth/sign-in?returnTo=/notes`, optionally with `provider=google` to skip Logto's picker and go straight to Google.","tags":["Sign-in"],"security":[],"parameters":[{"name":"returnTo","in":"query","required":false,"schema":{"type":"string"}},{"name":"provider","in":"query","required":false,"schema":{"type":"string","enum":["google"]}}],"responses":{"302":{"description":"To Logto's sign-in page"},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/sign-out":{"get":{"operationId":"getApiAuthSignOut","summary":"Sign out","description":"Signs out of this app and of Logto — and so, through Logto's back-channel logout, of every other app this browser signed in to — then returns home.","tags":["Sign-in"],"security":[],"responses":{"302":{"description":"Through Logto's end-session, which signs this browser out of every HomeLab app, back to the home page"},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/avatars/{userId}":{"get":{"operationId":"getApiAvatarsUserId","summary":"Get a profile photo","description":"Serves an uploaded avatar from object storage under a stable same-origin URL. Callers put `?v=` on it (see /api/account/avatar), so the response can be cached for good — a new upload is a new URL.","tags":["Account"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"userId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The image","content":{"image/png":{"schema":{"type":"string","format":"binary"}},"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/webp":{"schema":{"type":"string","format":"binary"}},"image/gif":{"schema":{"type":"string","format":"binary"}}}},"304":{"description":"Not modified (If-None-Match)"},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No uploaded photo"},"503":{"description":"File storage isn't set up on this server"}}}},"/api/calls":{"get":{"operationId":"getApiCalls","summary":"List calls, or read one","description":"The caller's calls (ADR 0045): `GET` lists them, newest first (only one conversation's with `?conversationId=`), or reads one with `?id=`; `POST` rings the other person in a conversation and answers the room to join.\n\nWithout `id`, your calls, newest first (only one conversation's with `conversationId`). With `id`, that call. Ringing calls whose time ran out are missed by then.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":false,"schema":{"type":"string","minLength":1}},{"name":"conversationId","in":"query","required":false,"schema":{"type":"string","minLength":1}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"Your calls, or the one asked for","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false}}},"required":["items"],"additionalProperties":false},{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false}]}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"postApiCalls","summary":"Call someone","description":"The caller's calls (ADR 0045): `GET` lists them, newest first (only one conversation's with `?conversationId=`), or reads one with `?id=`; `POST` rings the other person in a conversation and answers the room to join.\n\nRings the other person in the conversation for 30 seconds, and answers the call server, the room and a two-minute token to join it. 409 `busy` when either of you is already in a call; 503 when this server has no call server.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"conversationId":{"type":"string","minLength":1},"video":{"default":false,"type":"boolean"}},"required":["conversationId"]}}}},"responses":{"201":{"description":"The call, ringing, and its room","content":{"application/json":{"schema":{"type":"object","properties":{"call":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false},"url":{"type":"string"},"room":{"type":"string"},"token":{"type":"string"}},"required":["call","url","room","token"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/calls/answer":{"post":{"operationId":"postApiCallsAnswer","summary":"Answer a call","description":"`POST ?id=`: The person called takes a ringing call; answers the room to join.\n\nThe person called takes a ringing call: it is active, and the answer holds its room and a token.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The call and its room","content":{"application/json":{"schema":{"type":"object","properties":{"call":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false},"url":{"type":"string"},"room":{"type":"string"},"token":{"type":"string"}},"required":["call","url","room","token"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/calls/beat":{"post":{"operationId":"postApiCallsBeat","summary":"Say a call is still on","description":"`POST ?id=`: A client in an active call says it is still on; answers the call as it is.\n\nA client in an active call sends this every 30 seconds; a call either person hasn't beaten for 120 seconds ends at that person's last beat. Answers the call as it is, so a client learns it is over.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The call as it is","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/calls/cancel":{"post":{"operationId":"postApiCallsCancel","summary":"Cancel a call","description":"`POST ?id=`: The caller stops ringing before anyone answers.\n\nThe caller stops ringing before anyone answers; the person called sees a missed call.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The call, cancelled (or as it already was)","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/calls/decline":{"post":{"operationId":"postApiCallsDecline","summary":"Decline a call","description":"`POST ?id=`: The person called turns a ringing call down. The phone's call listener sends it with its ring token (ADR 0046), from the notification.\n\nThe person called turns a ringing call down.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The call, declined (or as it already was)","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/calls/end":{"post":{"operationId":"postApiCallsEnd","summary":"Hang up","description":"`POST ?id=`: Either person hangs up (a ringing call is cancelled or declined).\n\nEither person ends an active call; a ringing one is cancelled by the caller or declined by the person called. A call that is over is answered as it is.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The call, over","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/calls/ring-stream":{"get":{"operationId":"getApiCallsRingStream","summary":"Hear calls ring (ring token)","description":"The phone's call listener's stream (ADR 0046), opened with a ring token only: `event: ring` when a call rings for this person (and for any already ringing as it opens), `event: ring-ended` when it stops ringing — answered, declined, cancelled or missed. Nothing else about the person is in it.\n\nServer-sent events for the phone's call listener, opened with `Authorization: Bearer rtk_…` only: `ring` `{ callId, conversationId, callerName, video, state, ringUntil }` when a call rings for you (and for any ringing as it opens), `ring-ended` with the same fields when it stops ringing.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"The stream","content":{"text/event-stream":{"schema":{"type":"string"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/calls/token":{"get":{"operationId":"getApiCallsToken","summary":"Get a call's room again","description":"`GET ?id=`: A fresh token for the call's room: the caller while it rings, either person while it runs.\n\nA fresh two-minute token for the call's room, to join or rejoin: the caller while it rings, either person while it runs.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The call and its room","content":{"application/json":{"schema":{"type":"object","properties":{"call":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false},"url":{"type":"string"},"room":{"type":"string"},"token":{"type":"string"}},"required":["call","url","room","token"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/commands":{"post":{"operationId":"postApiCommands","summary":"Understand a command","description":"One spoken or typed command → the action it asks for (ADR 0028). Changes nothing: the client runs the action through the matching route.\n\nWhat one spoken or typed sentence (at most 2,000 characters) asks for. Built-in phrases need no AI; other wording goes to the server's model. Nothing runs: call the action's own endpoint.","tags":["Commands"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string","minLength":1,"maxLength":2000}},"required":["text"]}}}},"responses":{"200":{"description":"The action, and how it was understood","content":{"application/json":{"schema":{"type":"object","properties":{"intent":{"oneOf":[{"type":"object","properties":{"action":{"type":"string","const":"create_note"},"content":{"type":"string","minLength":1,"maxLength":10000}},"required":["action","content"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"append_to_note"},"noteId":{"type":"string","minLength":1},"noteExcerpt":{"type":"string"},"text":{"type":"string","minLength":1,"maxLength":10000}},"required":["action","noteId","noteExcerpt","text"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"delete_note"},"noteId":{"type":"string","minLength":1},"noteExcerpt":{"type":"string"}},"required":["action","noteId","noteExcerpt"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"summarize_note"},"noteId":{"type":"string","minLength":1},"noteExcerpt":{"type":"string"}},"required":["action","noteId","noteExcerpt"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"count_notes"}},"required":["action"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"open_page"},"page":{"type":"string","enum":["attachments","notes","chat","activity","account","settings","help"]}},"required":["action","page"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"ask_ai"},"prompt":{"type":"string","minLength":1,"maxLength":32000}},"required":["action","prompt"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"set_mode"},"mode":{"type":"string","enum":["light","dark","system"]}},"required":["action","mode"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"set_design"},"design":{"type":"string","enum":["soft","signal"]}},"required":["action","design"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"set_accent"},"accent":{"type":"string","enum":["green","rose","amber","blue","red"]}},"required":["action","accent"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"mark_all_notifications_read"}},"required":["action"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"sign_out"}},"required":["action"],"additionalProperties":false},{"type":"object","properties":{"action":{"type":"string","const":"unknown"},"reply":{"type":"string","minLength":1,"maxLength":500}},"required":["action","reply"],"additionalProperties":false}]},"source":{"type":"string","enum":["phrase","ai"]}},"required":["intent","source"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The AI provider is rate-limited or out of quota","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider or the sign-in service failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/config":{"get":{"operationId":"getApiConfig","summary":"Public configuration","description":"Public, unauthenticated config: this server's name and address, what native clients need to start an OIDC flow (their own Logto application ids here included, so a client switching servers needs no rebuild), and which sign-in options the web UI should offer.","tags":["Server"],"security":[],"responses":{"200":{"description":"What a native client needs to sign in, and which sign-in options to offer","content":{"application/json":{"schema":{"type":"object","properties":{"server":{"$ref":"#/components/schemas/Server"},"logto":{"anyOf":[{"type":"object","properties":{"endpoint":{"type":"string"},"apiResource":{"type":"string"},"clients":{"type":"object","properties":{"mobile":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["mobile"],"additionalProperties":false}},"required":["endpoint","apiResource","clients"],"additionalProperties":false},{"type":"null"}]},"auth":{"type":"object","properties":{"configured":{"type":"boolean"},"google":{"type":"boolean"}},"required":["configured","google"],"additionalProperties":false},"calls":{"type":"object","properties":{"enabled":{"type":"boolean"},"ringSeconds":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["enabled","ringSeconds"],"additionalProperties":false}},"required":["server","logto","auth"],"additionalProperties":false}}}}}}},"/api/conversations":{"get":{"operationId":"getApiConversations","summary":"List conversations, or read one","description":"The caller's conversations: `GET` lists them (most recent first) or, with `?id=`, reads one; `POST` opens the one with a person, starting it when there is none; `DELETE ?id=` deletes it for both people.\n\nWithout `id`, your conversations, most recent first, each with the other person, the last message (encrypted), and how many are unread. With `id`, that one.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":false,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"Your conversations, or the one asked for","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Conversation"}}},"required":["items"],"additionalProperties":false},{"$ref":"#/components/schemas/Conversation"}]}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"postApiConversations","summary":"Open a conversation with someone","description":"The caller's conversations: `GET` lists them (most recent first) or, with `?id=`, reads one; `POST` opens the one with a person, starting it when there is none; `DELETE ?id=` deletes it for both people.\n\nNames the person by `userId` or `handle`; starts the conversation when there is none, and answers the same one when there is.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string","minLength":1},"handle":{"type":"string","pattern":"^[A-Za-z0-9_]{3,30}$"}}}}}},"responses":{"201":{"description":"The conversation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Conversation"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteApiConversations","summary":"Delete a conversation","description":"The caller's conversations: `GET` lists them (most recent first) or, with `?id=`, reads one; `POST` opens the one with a person, starting it when there is none; `DELETE ?id=` deletes it for both people.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"204":{"description":"Deleted for both people, with its messages and files, or already gone"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/conversations/keys":{"get":{"operationId":"getApiConversationsKeys","summary":"Read a conversation's keys","description":"A conversation's keys (ADR 0042): `GET ?id=` answers the keys sealed for the caller and each participant's public key; `POST ?id=` stores keys sealed for participants. A stored key is never replaced.","tags":["Encryption"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The keys sealed for you, and each participant's public key and keys","content":{"application/json":{"schema":{"type":"object","properties":{"shares":{"type":"array","items":{"type":"object","properties":{"keyId":{"type":"string"},"wrappedKey":{"type":"string"}},"required":["keyId","wrappedKey"],"additionalProperties":false}},"participants":{"type":"array","items":{"type":"object","properties":{"userId":{"type":"string"},"publicKey":{"anyOf":[{"type":"string"},{"type":"null"}]},"keyIds":{"type":"array","items":{"type":"string"}}},"required":["userId","publicKey","keyIds"],"additionalProperties":false}},"hasMessages":{"type":"boolean"}},"required":["shares","participants","hasMessages"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"postApiConversationsKeys","summary":"Share a conversation key","description":"A conversation's keys (ADR 0042): `GET ?id=` answers the keys sealed for the caller and each participant's public key; `POST ?id=` stores keys sealed for participants. A stored key is never replaced.\n\nStores conversation keys sealed for participants. A key already stored is kept as it is, and nobody holds more than 20 in one conversation.","tags":["Encryption"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"shares":{"minItems":1,"maxItems":10,"type":"array","items":{"type":"object","properties":{"userId":{"type":"string","minLength":1},"keyId":{"type":"string","pattern":"^[0-9a-f]{16}$"},"wrappedKey":{"type":"string","pattern":"^v1\\.B[A-Za-z0-9_-]{86}\\.[A-Za-z0-9_-]{16}\\.[A-Za-z0-9_-]{64}$"}},"required":["userId","keyId","wrappedKey"]}}},"required":["shares"]}}}},"responses":{"200":{"description":"How many were new","content":{"application/json":{"schema":{"type":"object","properties":{"accepted":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["accepted"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/conversations/read":{"post":{"operationId":"postApiConversationsRead","summary":"Mark a conversation read","description":"`POST ?id=`: everything in the conversation up to now is read.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"204":{"description":"Read up to now; the other person sees it as seen"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/conversations/stream":{"get":{"operationId":"getApiConversationsStream","summary":"Follow your conversations live","description":"Changes to the caller's conversations as they happen, as server-sent events (ADR 0043): `event: conversation` with `{ conversationId, change }`, never content. Nothing is replayed, so a client reloads what it shows each time the stream opens.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"Server-sent events: `event: conversation` with `{ conversationId, change }` (started, message, read, keys, deleted), never content, and a `: ping` comment every 25 s. Nothing is replayed: reload what you show each time the stream opens.","content":{"text/event-stream":{"schema":{"type":"string"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/devices":{"get":{"operationId":"getApiDevices","summary":"List devices","description":"The caller's devices (ADR 0036): every sign-in — browsers, the phone, the the desktop app, AI assistants. `GET` lists them, `PATCH ?id=` renames one or lets a signed-out assistant back in, `DELETE ?id=` forgets one already signed out.","tags":["Devices"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"Every device the caller signed in on, most recently seen first; `current` marks the one asking","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["web","admin","phone","desktop","assistant","app"]},"name":{"anyOf":[{"type":"string"},{"type":"null"}]},"label":{"anyOf":[{"type":"string"},{"type":"null"}]},"platform":{"anyOf":[{"type":"string"},{"type":"null"}]},"appVersion":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"signedInAt":{"type":"string"},"lastSeenAt":{"type":"string"},"signedOutAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"online":{"type":"boolean"},"current":{"type":"boolean"},"capabilities":{"type":"array","items":{"type":"string","enum":["pages","notes"]}}},"required":["id","kind","name","label","platform","appVersion","createdAt","signedInAt","lastSeenAt","signedOutAt","online","current","capabilities"],"additionalProperties":false}}},"required":["items"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"patchApiDevices","summary":"Rename a device, or let an assistant back in","description":"The caller's devices (ADR 0036): every sign-in — browsers, the phone, the the desktop app, AI assistants. `GET` lists them, `PATCH ?id=` renames one or lets a signed-out assistant back in, `DELETE ?id=` forgets one already signed out.\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["Devices"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"anyOf":[{"type":"string","minLength":1,"maxLength":60},{"type":"null"}]},"allow":{"type":"boolean","const":true}}}}}},"responses":{"200":{"description":"The device","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["web","admin","phone","desktop","assistant","app"]},"name":{"anyOf":[{"type":"string"},{"type":"null"}]},"label":{"anyOf":[{"type":"string"},{"type":"null"}]},"platform":{"anyOf":[{"type":"string"},{"type":"null"}]},"appVersion":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"signedInAt":{"type":"string"},"lastSeenAt":{"type":"string"},"signedOutAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"online":{"type":"boolean"},"current":{"type":"boolean"},"capabilities":{"type":"array","items":{"type":"string","enum":["pages","notes"]}}},"required":["id","kind","name","label","platform","appVersion","createdAt","signedInAt","lastSeenAt","signedOutAt","online","current","capabilities"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteApiDevices","summary":"Forget a signed-out device","description":"The caller's devices (ADR 0036): every sign-in — browsers, the phone, the the desktop app, AI assistants. `GET` lists them, `PATCH ?id=` renames one or lets a signed-out assistant back in, `DELETE ?id=` forgets one already signed out.\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["Devices"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"204":{"description":"Forgotten, or already gone"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/devices/command":{"post":{"operationId":"postApiDevicesCommand","summary":"Control a device","description":"Remote control (ADR 0038): `POST ?id=` with a command sends it to one of the caller's open devices, which follows it within a second. 202 once sent; 409 `device_offline` when the device isn't open, 400 `unsupported` when it can't do that, 429 when too many come at once.\n\nSends one navigation command to one of the person's open devices, which follows it within a second and shows who sent it.","tags":["Devices"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"action":{"type":"string","const":"open_page"},"page":{"type":"string","enum":["attachments","notes","chat","activity","account","settings","help"]}},"required":["action","page"]},{"type":"object","properties":{"action":{"type":"string","const":"open_note"},"noteId":{"type":"string","minLength":1,"maxLength":100}},"required":["action","noteId"]},{"type":"object","properties":{"action":{"type":"string","const":"next_note"}},"required":["action"]},{"type":"object","properties":{"action":{"type":"string","const":"previous_note"}},"required":["action"]},{"type":"object","properties":{"action":{"type":"string","const":"scroll"},"direction":{"type":"string","enum":["up","down"]}},"required":["action","direction"]},{"type":"object","properties":{"action":{"type":"string","const":"back"}},"required":["action"]}]}}}},"responses":{"202":{"description":"Sent: the command's id","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"}},"required":["id"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`device_offline`: the device isn't open, so nothing was sent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The AI provider is rate-limited or out of quota","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/devices/current":{"put":{"operationId":"putApiDevicesCurrent","summary":"Describe this app's device","description":"A native app describing its own device (ADR 0036): `PUT { kind, label, platform, appVersion }` with the X-Device-Key header it keeps. The phone, the desktop app send it after every sign-in and start.\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["Devices"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["phone","desktop"]},"label":{"anyOf":[{"type":"string","minLength":1,"maxLength":60},{"type":"null"}]},"platform":{"anyOf":[{"type":"string","minLength":1,"maxLength":60},{"type":"null"}]},"appVersion":{"anyOf":[{"type":"string","minLength":1,"maxLength":40},{"type":"null"}]}},"required":["kind"]}}}},"responses":{"200":{"description":"The device named by the X-Device-Key header, as the list shows it","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["web","admin","phone","desktop","assistant","app"]},"name":{"anyOf":[{"type":"string"},{"type":"null"}]},"label":{"anyOf":[{"type":"string"},{"type":"null"}]},"platform":{"anyOf":[{"type":"string"},{"type":"null"}]},"appVersion":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"signedInAt":{"type":"string"},"lastSeenAt":{"type":"string"},"signedOutAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"online":{"type":"boolean"},"current":{"type":"boolean"},"capabilities":{"type":"array","items":{"type":"string","enum":["pages","notes"]}}},"required":["id","kind","name","label","platform","appVersion","createdAt","signedInAt","lastSeenAt","signedOutAt","online","current","capabilities"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/devices/ring-token":{"post":{"operationId":"postApiDevicesRingToken","summary":"Get a ring token for this device","description":"The current device's ring token (ADR 0046): `POST` issues one (shown once, replacing any before it) for the phone's call listener; `DELETE` ends it.\n\nFor the phone's call listener (ADR 0046): a secret that opens only `GET /api/calls/ring-stream` and `POST /api/calls/decline`. Shown once; a new one replaces it; signing the device out ends it. Needs a device key.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"201":{"description":"The token","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string"}},"required":["token"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteApiDevicesRingToken","summary":"End this device's ring token","description":"The current device's ring token (ADR 0046): `POST` issues one (shown once, replacing any before it) for the phone's call listener; `DELETE` ends it.","tags":["Calls"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"204":{"description":"Ended, or there was none"},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/devices/sign-out":{"post":{"operationId":"postApiDevicesSignOut","summary":"Sign a device out","description":"Signs one of the caller's devices out from here (ADR 0036): `POST ?id=`. Its browser sessions end at their next request; an app or an AI assistant is refused with `device_signed_out`. Needs a sign-in, never a key.\n\nTakes the web session or a Logto access token, never a personal API key.","tags":["Devices"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The device, signed out: its browser sessions end, and an app or assistant is refused with `code: device_signed_out`","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["web","admin","phone","desktop","assistant","app"]},"name":{"anyOf":[{"type":"string"},{"type":"null"}]},"label":{"anyOf":[{"type":"string"},{"type":"null"}]},"platform":{"anyOf":[{"type":"string"},{"type":"null"}]},"appVersion":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"signedInAt":{"type":"string"},"lastSeenAt":{"type":"string"},"signedOutAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"online":{"type":"boolean"},"current":{"type":"boolean"},"capabilities":{"type":"array","items":{"type":"string","enum":["pages","notes"]}}},"required":["id","kind","name","label","platform","appVersion","createdAt","signedInAt","lastSeenAt","signedOutAt","online","current","capabilities"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/devices/stream":{"get":{"operationId":"getApiDevicesStream","summary":"Follow remote-control commands","description":"Remote control (ADR 0038): the caller's device listens for commands, as server-sent events, `GET ?can=pages,notes` naming what it can do. Each command arrives as `event: command` with its envelope as JSON; nothing is replayed. The stream ends after 30 s and the device reconnects; each connect and ping keeps it online. Once the device is signed out the stream says `event: signed_out` and ends.\n\nThe caller's device listens for commands another of the person's devices sends (ADR 0038). While it is open the device is online. A personal API key isn't a device and is refused with 400.","tags":["Devices"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"can","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Server-sent events: `event: command` with the command's envelope (id, from, sentAt, command) as JSON, a `: ping` comment every 25 s, and `event: signed_out` before the stream ends once the device is signed out. Nothing is replayed.","content":{"text/event-stream":{"schema":{"type":"string"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/docs/asyncapi":{"get":{"operationId":"getApiDocsAsyncapi","summary":"The events (AsyncAPI 3.0)","description":"The events published on NATS as an AsyncAPI 3.0 document, generated from the event contract. Public.","tags":["Reference"],"security":[],"responses":{"200":{"description":"Every event published on NATS: subject, envelope, and consumers","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/docs/mcp":{"get":{"operationId":"getApiDocsMcp","summary":"The MCP tools","description":"The MCP server's tools, as `tools/list` answers an assistant, with how to connect. Public.","tags":["Reference"],"security":[],"responses":{"200":{"description":"The MCP server's name, instructions, endpoint, and every tool as `tools/list` answers it","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/docs/openapi":{"get":{"operationId":"getApiDocsOpenapi","summary":"This reference (OpenAPI 3.1)","description":"The HTTP API as an OpenAPI 3.1 document, generated from the routes and the shared contract. Public.","tags":["Reference"],"security":[],"responses":{"200":{"description":"The OpenAPI document","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/encryption":{"get":{"operationId":"getApiEncryption","summary":"Read your encryption keys","description":"The caller's identity key (ADR 0042): `GET` reads it, with the sign-in tag a client keeps its unlocked key under; `PUT` sets it up, seals it under a new passphrase, or (with `reset`) replaces it, naming the version it replaces. Personal API keys can't change it.\n\nYour public key and your private key sealed under your passphrase, which only your devices know. `signInTag` names the sign-in: a client keeps an unlocked key only under it, so a new sign-in asks for the passphrase again.","tags":["Encryption"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"Your keys, or null before set-up","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"anyOf":[{"type":"object","properties":{"publicKey":{"type":"string","pattern":"^B[A-Za-z0-9_-]{86}$"},"wrappedPrivateKey":{"type":"string","pattern":"^v1\\.[A-Za-z0-9_-]{16}\\.[A-Za-z0-9_-]{64}$"},"kdfSalt":{"type":"string","pattern":"^[A-Za-z0-9_-]{22}$"},"kdfIterations":{"type":"integer","minimum":100000,"maximum":10000000},"version":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991}},"required":["publicKey","wrappedPrivateKey","kdfSalt","kdfIterations","version"],"additionalProperties":false},{"type":"null"}]},"signInTag":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["keys","signInTag"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"putApiEncryption","summary":"Set up, change, or reset your keys","description":"The caller's identity key (ADR 0042): `GET` reads it, with the sign-in tag a client keeps its unlocked key under; `PUT` sets it up, seals it under a new passphrase, or (with `reset`) replaces it, naming the version it replaces. Personal API keys can't change it.\n\n`baseVersion` null sets up; the same public key sealed anew changes the passphrase; a new key pair needs `reset: true` and drops your conversation keys, which the other people's apps share again. API keys can't call it.","tags":["Encryption"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"publicKey":{"type":"string","pattern":"^B[A-Za-z0-9_-]{86}$"},"wrappedPrivateKey":{"type":"string","pattern":"^v1\\.[A-Za-z0-9_-]{16}\\.[A-Za-z0-9_-]{64}$"},"kdfSalt":{"type":"string","pattern":"^[A-Za-z0-9_-]{22}$"},"kdfIterations":{"type":"integer","minimum":100000,"maximum":10000000},"baseVersion":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"reset":{"type":"boolean"}},"required":["publicKey","wrappedPrivateKey","kdfSalt","kdfIterations","baseVersion"]}}}},"responses":{"200":{"description":"Your keys","content":{"application/json":{"schema":{"type":"object","properties":{"publicKey":{"type":"string","pattern":"^B[A-Za-z0-9_-]{86}$"},"wrappedPrivateKey":{"type":"string","pattern":"^v1\\.[A-Za-z0-9_-]{16}\\.[A-Za-z0-9_-]{64}$"},"kdfSalt":{"type":"string","pattern":"^[A-Za-z0-9_-]{22}$"},"kdfIterations":{"type":"integer","minimum":100000,"maximum":10000000},"version":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991}},"required":["publicKey","wrappedPrivateKey","kdfSalt","kdfIterations","version"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`keys_changed`: the keys moved on from `baseVersion`; `current` is them as they are now","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string","const":"keys_changed"},"current":{"anyOf":[{"type":"object","properties":{"publicKey":{"type":"string","pattern":"^B[A-Za-z0-9_-]{86}$"},"wrappedPrivateKey":{"type":"string","pattern":"^v1\\.[A-Za-z0-9_-]{16}\\.[A-Za-z0-9_-]{64}$"},"kdfSalt":{"type":"string","pattern":"^[A-Za-z0-9_-]{22}$"},"kdfIterations":{"type":"integer","minimum":100000,"maximum":10000000},"version":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991}},"required":["publicKey","wrappedPrivateKey","kdfSalt","kdfIterations","version"],"additionalProperties":false},{"type":"null"}]}},"required":["error","code","current"],"additionalProperties":false}}}}}}},"/api/health":{"get":{"operationId":"getApiHealth","summary":"Health","tags":["Server"],"security":[],"responses":{"200":{"description":"The database answers","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","const":"ok"}},"required":["status"],"additionalProperties":false}}}},"503":{"description":"The database doesn't answer","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","const":"unavailable"}},"required":["status"],"additionalProperties":false}}}}}}},"/api/mcp":{"get":{"operationId":"getApiMcp","summary":"MCP: not used","tags":["AI assistants (MCP)"],"security":[],"responses":{"405":{"description":"The server is stateless: POST only"}}},"post":{"operationId":"postApiMcp","summary":"MCP (Streamable HTTP)","description":"One JSON-RPC message per request, stateless. The tools are listed in the MCP reference (`GET /api/docs/mcp`).\n\nTakes a Bearer token only: a personal API key or a Logto access token.","tags":["AI assistants (MCP)"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["jsonrpc","method"],"properties":{"jsonrpc":{"const":"2.0"},"id":{"type":["string","integer"]},"method":{"type":"string","examples":["initialize","tools/list","tools/call"]},"params":{"type":"object"}}}}}},"responses":{"200":{"description":"The JSON-RPC answer","content":{"application/json":{"schema":{"type":"object"}},"text/event-stream":{"schema":{"type":"string"}}}},"202":{"description":"A notification, accepted"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Too large","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteApiMcp","summary":"MCP: not used","tags":["AI assistants (MCP)"],"security":[],"responses":{"405":{"description":"The server is stateless: POST only"}}}},"/api/message-files":{"get":{"operationId":"getApiMessageFiles","summary":"Download an encrypted file","description":"Encrypted files in conversations (ADR 0042, 0044). `POST ?conversationId=&kind=&meta=` takes the encrypted bytes as the body and answers the unsent file, which a message then sends; `GET ?id=` answers the encrypted bytes to a participant.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The encrypted bytes, to decrypt with the conversation key","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"postApiMessageFiles","summary":"Upload an encrypted file","description":"Encrypted files in conversations (ADR 0042, 0044). `POST ?conversationId=&kind=&meta=` takes the encrypted bytes as the body and answers the unsent file, which a message then sends; `GET ?id=` answers the encrypted bytes to a participant.\n\nThe body is the encrypted file, up to 25 MB (a video 50 MB, a voice message 10 MB). It waits, unsent, until a message names its id.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"conversationId","in":"query","required":true,"schema":{"type":"string","minLength":1}},{"name":"kind","in":"query","required":true,"schema":{"type":"string","enum":["image","video","audio","voice","file"]}},{"name":"meta","in":"query","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary","description":"The encrypted file"}}}},"responses":{"201":{"description":"The unsent file","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["image","video","audio","voice","file"]},"size":{"type":"integer","minimum":0,"maximum":9007199254740991},"meta":{"type":"string"}},"required":["id","kind","size","meta"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Too large","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/messages":{"get":{"operationId":"getApiMessages","summary":"List a conversation's messages","description":"Messages in the caller's conversations (ADR 0042: content is ciphertext): `GET ?conversationId=` pages through one conversation, newest first; `POST` sends; `PATCH ?id=` replaces a text message's content and `DELETE ?id=` deletes one, both only by its sender.\n\nA page of messages, newest first. Content is encrypted.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":50,"type":"integer","minimum":1,"maximum":200}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}},{"name":"conversationId","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"A page of messages","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Message"}},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["items","nextCursor"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"postApiMessages","summary":"Send a message","description":"Messages in the caller's conversations (ADR 0042: content is ciphertext): `GET ?conversationId=` pages through one conversation, newest first; `POST` sends; `PATCH ?id=` replaces a text message's content and `DELETE ?id=` deletes one, both only by its sender.\n\nText sends encrypted `content`; an image, video, audio or file sends the `fileId` of your upload, with an optional encrypted caption. A client may make the id: sending it again answers the same message.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"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)$"},"conversationId":{"type":"string","minLength":1},"kind":{"default":"text","type":"string","enum":["text","image","video","audio","voice","file","call"]},"content":{"type":"string","maxLength":60000,"pattern":"^v1\\.[0-9a-f]{16}\\.[A-Za-z0-9_-]{16}\\.[A-Za-z0-9_-]+$"},"replyToId":{"type":"string","minLength":1},"fileId":{"type":"string","minLength":1}},"required":["conversationId"]}}}},"responses":{"201":{"description":"The message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`id_taken`: the id names someone else's message"}}},"patch":{"operationId":"patchApiMessages","summary":"Edit a message","description":"Messages in the caller's conversations (ADR 0042: content is ciphertext): `GET ?conversationId=` pages through one conversation, newest first; `POST` sends; `PATCH ?id=` replaces a text message's content and `DELETE ?id=` deletes one, both only by its sender.\n\nReplaces a text message's encrypted content; only its sender can.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"content":{"type":"string","maxLength":60000,"pattern":"^v1\\.[0-9a-f]{16}\\.[A-Za-z0-9_-]{16}\\.[A-Za-z0-9_-]+$"}},"required":["content"]}}}},"responses":{"200":{"description":"The edited message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteApiMessages","summary":"Delete a message","description":"Messages in the caller's conversations (ADR 0042: content is ciphertext): `GET ?conversationId=` pages through one conversation, newest first; `POST` sends; `PATCH ?id=` replaces a text message's content and `DELETE ?id=` deletes one, both only by its sender.","tags":["Conversations"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"204":{"description":"Deleted with its file, or already gone; only its sender can"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/notes":{"get":{"operationId":"getApiNotes","summary":"List notes, or read one","description":"The caller's notes: list and create; with `?id=`, read, edit, delete. An edit's body and a delete's `?baseVersion=` may name the version they began from (ADR 0037).\n\nWithout `id`, a page of notes, newest first. With `id`, that one note.","tags":["Notes"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":50,"type":"integer","minimum":1,"maximum":200}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}},{"name":"id","in":"query","required":false,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"A page of notes, or the note asked for by `id`","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Note"}},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["items","nextCursor"],"additionalProperties":false},{"$ref":"#/components/schemas/Note"}]}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"postApiNotes","summary":"Write a note","description":"The caller's notes: list and create; with `?id=`, read, edit, delete. An edit's body and a delete's `?baseVersion=` may name the version they began from (ADR 0037).\n\nA client may make the note's id (a UUID): writing the same id again answers the note it already made, so a write can be sent again safely.","tags":["Notes"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"content":{"type":"string","minLength":1,"maxLength":10000},"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)$"}},"required":["content"]}}}},"responses":{"201":{"description":"The new note, or the one this id already made","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Note"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"patchApiNotes","summary":"Replace a note's text","description":"The caller's notes: list and create; with `?id=`, read, edit, delete. An edit's body and a delete's `?baseVersion=` may name the version they began from (ADR 0037).\n\nWith `baseVersion`, the edit applies only while the note is still at that version; every edit adds one to it.","tags":["Notes"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"content":{"type":"string","minLength":1,"maxLength":10000},"baseVersion":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991}},"required":["content"]}}}},"responses":{"200":{"description":"The edited note","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Note"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`note_changed`: the note moved on from `baseVersion` on another device; `current` is the note as it is now. `id_taken` when creating: the id names someone else's note","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string","const":"note_changed"},"current":{"$ref":"#/components/schemas/Note"}},"required":["error","code","current"],"additionalProperties":false}}}}}},"delete":{"operationId":"deleteApiNotes","summary":"Delete a note","description":"The caller's notes: list and create; with `?id=`, read, edit, delete. An edit's body and a delete's `?baseVersion=` may name the version they began from (ADR 0037).","tags":["Notes"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}},{"name":"baseVersion","in":"query","required":false,"schema":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991}}],"responses":{"204":{"description":"Deleted, or already gone; the note's files stay"},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`note_changed`: the note moved on from `baseVersion` on another device; `current` is the note as it is now. `id_taken` when creating: the id names someone else's note","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string","const":"note_changed"},"current":{"$ref":"#/components/schemas/Note"}},"required":["error","code","current"],"additionalProperties":false}}}}}}},"/api/notes/count":{"get":{"operationId":"getApiNotesCount","summary":"Count notes","description":"How many notes the signed-in user has, for clients that show a summary rather than the list (the phone's account screen).","tags":["Notes"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"How many notes, and how many are unread","content":{"application/json":{"schema":{"type":"object","properties":{"count":{"type":"integer","minimum":0,"maximum":9007199254740991},"unreadCount":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["count","unreadCount"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/notes/read":{"post":{"operationId":"postApiNotesRead","summary":"Mark a note read","description":"Marks one of the caller's notes read (`?id=`). Notes the app writes for people, such as the daily greeting, arrive unread; marking again keeps the first time.","tags":["Notes"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The note","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Note"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/notifications":{"get":{"operationId":"getApiNotifications","summary":"List notifications","description":"The caller's notifications: list (with the unread count); `PATCH ?id=` marks one read.","tags":["Notifications"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":50,"type":"integer","minimum":1,"maximum":200}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"A page, newest first, and how many are unread","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Notification"}},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]},"unreadCount":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["items","nextCursor","unreadCount"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"patchApiNotifications","summary":"Mark a notification read","description":"The caller's notifications: list (with the unread count); `PATCH ?id=` marks one read.","tags":["Notifications"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The notification","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Notification"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/notifications/read-all":{"post":{"operationId":"postApiNotificationsReadAll","summary":"Mark every notification read","description":"Marks every notification of the caller read.","tags":["Notifications"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"Nothing left unread","content":{"application/json":{"schema":{"type":"object","properties":{"unreadCount":{"type":"number","const":0}},"required":["unreadCount"],"additionalProperties":false}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/notifications/stream":{"get":{"operationId":"getApiNotificationsStream","summary":"Follow notifications live","description":"The caller's notifications as they are raised, as server-sent events: `event: notification` with the notification as JSON. Nothing is replayed, so a client loads the list each time its stream opens. EventSource sends the session cookie; a script sends its API key as a Bearer token.","tags":["Notifications"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"Server-sent events: `event: notification` with a Notification as JSON, and a `: ping` comment every 25 s. Nothing is replayed: load the list each time the stream opens.","content":{"text/event-stream":{"schema":{"type":"string"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/people":{"get":{"operationId":"getApiPeople","summary":"Find people by handle","description":"`GET ?q=`: people whose handle starts with `q`, up to 20.","tags":["Profiles"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"Up to 20 people, by handle","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Profile"}}},"required":["items"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/presence":{"post":{"operationId":"postApiPresence","summary":"Say you're online","description":"`POST`: the caller is online; visible clients send it every minute.\n\nVisible clients send it every minute; a ping in the last 2 minutes shows as online.","tags":["Profiles"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"204":{"description":"Noted"},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/profile":{"get":{"operationId":"getApiProfile","summary":"Read your profile","description":"The caller's Messages profile, made with a proposed handle the first time: `GET` reads it, `PATCH` changes the handle and/or the status.\n\nMade the first time, with a handle proposed from your sign-in that you can change.","tags":["Profiles"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"responses":{"200":{"description":"Your profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Profile"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"patchApiProfile","summary":"Change your handle or status","description":"The caller's Messages profile, made with a proposed handle the first time: `GET` reads it, `PATCH` changes the handle and/or the status.","tags":["Profiles"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"handle":{"type":"string","pattern":"^[A-Za-z0-9_]{3,30}$"},"statusText":{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}]}}}}}},"responses":{"200":{"description":"Your profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Profile"}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`handle_taken`: someone else has that handle"}}}},"/api/storage/download-url":{"get":{"operationId":"getApiStorageDownloadUrl","summary":"Get a download link","description":"A presigned download URL for one of the caller's ready files (`?id=`).","tags":["Files"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"A short-lived presigned link","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"}},"required":["url"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/storage/upload-url":{"post":{"operationId":"postApiStorageUploadUrl","summary":"Ask for an upload link","description":"A pending attachment and the presigned URL to PUT its bytes to.\n\nCreates a pending file and answers a presigned link: PUT the bytes to it, then PATCH /api/attachments with the id. The server's upload policy limits size and type. A client may make the file's id (a UUID): asking again with it gives the same pending file a fresh link.","tags":["Files"],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":300},"size":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"mimeType":{"type":"string","minLength":1,"maxLength":255},"noteId":{"type":"string","minLength":1,"maxLength":100},"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)$"}},"required":["name","size","mimeType"]}}}},"responses":{"200":{"description":"The pending file's id and its upload link","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"}},"required":["id","url"],"additionalProperties":false}}}},"400":{"description":"Invalid input; `error` says what","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or a missing, expired, or revoked token or key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Doesn't exist, or isn't yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`already_uploaded`: the file with this id is ready, and `attachment` is it. `id_taken`: the id names someone else's file","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"},"attachment":{"$ref":"#/components/schemas/Attachment"}},"required":["error"],"additionalProperties":false}}}},"503":{"description":"A feature this server hasn't set up (sign-in, storage, or AI)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"Activity":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"category":{"type":"string","enum":["business","technical"]},"summary":{"type":"string"},"subject":{"anyOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["note","attachment","api_key"]},"id":{"type":"string"},"label":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["kind","id","label"],"additionalProperties":false},{"type":"null"}]},"occurredAt":{"type":"string"}},"required":["id","type","category","summary","subject","occurredAt"],"additionalProperties":false},"ApiKey":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"prefix":{"type":"string"},"createdAt":{"type":"string"},"lastUsedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"expiresAt":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["id","name","prefix","createdAt","lastUsedAt","expiresAt"],"additionalProperties":false},"Attachment":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"size":{"type":"integer","minimum":0,"maximum":9007199254740991},"mimeType":{"type":"string"},"status":{"type":"string","enum":["pending","ready","delete_failed"]},"noteId":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","size","mimeType","status","noteId","createdAt","updatedAt"],"additionalProperties":false},"Conversation":{"type":"object","properties":{"id":{"type":"string"},"partner":{"anyOf":[{"$ref":"#/components/schemas/Profile"},{"type":"null"}]},"lastMessage":{"anyOf":[{"$ref":"#/components/schemas/Message"},{"type":"null"}]},"unreadCount":{"type":"integer","minimum":0,"maximum":9007199254740991},"partnerLastReadAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","partner","lastMessage","unreadCount","partnerLastReadAt","createdAt","updatedAt"],"additionalProperties":false},"Error":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"],"additionalProperties":false},"Message":{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"senderId":{"type":"string"},"kind":{"type":"string","enum":["text","image","video","audio","voice","file","call"]},"content":{"anyOf":[{"type":"string"},{"type":"null"}]},"replyToId":{"anyOf":[{"type":"string"},{"type":"null"}]},"file":{"anyOf":[{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["image","video","audio","voice","file"]},"size":{"type":"integer","minimum":0,"maximum":9007199254740991},"meta":{"type":"string"}},"required":["id","kind","size","meta"],"additionalProperties":false},{"type":"null"}]},"call":{"anyOf":[{"type":"object","properties":{"id":{"type":"string"},"conversationId":{"type":"string"},"callerId":{"type":"string"},"calleeId":{"type":"string"},"video":{"type":"boolean"},"state":{"type":"string","enum":["ringing","active","ended","declined","cancelled","missed"]},"createdAt":{"type":"string"},"ringUntil":{"type":"string"},"answeredAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"endedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSeconds":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","conversationId","callerId","calleeId","video","state","createdAt","ringUntil","answeredAt","endedAt","durationSeconds"],"additionalProperties":false},{"type":"null"}]},"editedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"}},"required":["id","conversationId","senderId","kind","content","replyToId","file","editedAt","createdAt"],"additionalProperties":false},"Note":{"type":"object","properties":{"id":{"type":"string"},"content":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"readAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"version":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991}},"required":["id","content","createdAt","updatedAt","readAt"],"additionalProperties":false},"Notification":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"title":{"type":"string"},"body":{"anyOf":[{"type":"string"},{"type":"null"}]},"link":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"readAt":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["id","kind","title","body","link","createdAt","readAt"],"additionalProperties":false},"Profile":{"type":"object","properties":{"userId":{"type":"string"},"handle":{"type":"string"},"name":{"type":"string"},"image":{"anyOf":[{"type":"string"},{"type":"null"}]},"statusText":{"anyOf":[{"type":"string"},{"type":"null"}]},"online":{"type":"boolean"},"lastSeenAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"hasKeys":{"type":"boolean"}},"required":["userId","handle","name","image","statusText","online","lastSeenAt","hasKeys"],"additionalProperties":false},"Server":{"type":"object","properties":{"alias":{"type":"string","minLength":1,"maxLength":40,"description":"The server's name in the list, e.g. `warsaw`"},"url":{"type":"string","minLength":1,"maxLength":200,"description":"The app's address on that server, its http(s) origin, e.g. `https://messages.192.168.1.105.sslip.io`"}},"required":["alias","url"],"additionalProperties":false}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"A personal API key (`stk_…`, from Account → API keys) or a Logto access token for this API."},"cookieAuth":{"type":"apiKey","in":"cookie","name":"messages_token","description":"The web app's session cookie, set at sign-in. A signed-in browser sends it by itself."}}},"servers":[{"url":"https://messages.192.168.1.105.sslip.io"}]}