# Native messaging API Authenticate REST requests with the existing `token` cookie. WebSockets use `wss://ws.volt.im/?token=...`. All routes below require authentication; chat operations also require current membership. Editing requires ownership; deletion requires ownership in channels, while either DM participant can delete either side's messages for both. These additions preserve existing message history and browser clients. The regional browser entry point is `https://app.volt.im`. It serves the same accounts, APIs and encrypted conversations, with WebSockets at `wss://app.volt.im/ws/?token=...`. Its session uses a separate, host-only `__Host-volt-token` cookie (Secure, HttpOnly, SameSite=Lax, Path=/). Users sign in again on this hostname; the original `volt.im` and native `token` cookie remain supported. The regional nginx entry rejects foreign browser origins and forwards only its own session and language cookies. `app.volt.im` has a DNS-only A record to the existing server. Protected test subdomains suffered the same connection truncation as the apex; changing TLS or Cloudflare edge IPs did not resolve it. This endpoint uses the host's included [Netrix network DDoS protection](https://docs.pulseheberg.com/en/article/comment-fonctionne-la-protection-anti-ddos-sur-un-vps-kvm-1otwpcu), plus nginx request limits. Cloudflare WAF and caching do not cover this endpoint. The apex remains Cloudflare-proxied. Application pages, assets, API calls and WebSockets use Volt's own hostname throughout. First configure an HTTP `/.well-known/acme-challenge/` webroot at `/var/www/voltim-acme` and issue a public certificate with `certbot certonly --webroot -w /var/www/voltim-acme --cert-name app.volt.im -d app.volt.im`. Use a renewal deploy hook of `/usr/sbin/nginx -t && /bin/systemctl reload nginx` and the existing `certbot.timer`. Deploy the backend cookie support and minified `static/volt.js`, then install `deploy/nginx-public-site.conf` and the updated `deploy/nginx-public-website.conf` snippet. Validate HTTPS and large downloads directly before changing the existing redirect rule with `deploy/cloudflare-public-site-redirect.json`: Russian GET/HEAD requests for website, authentication and conversation pages move to `app.volt.im`, preserving path and query. API and POST requests keep their original destinations. `node api_tests/regional_transport_test.mjs` checks browser socket selection; `v -w test auth_session_test.v` checks session naming and expiry. The opt-in `api_tests/regional_chat_browser_test.mjs` uses a fresh Brave instance launched with `--no-proxy-server --remote-debugging-port=9243`. Supply an outside-repository mode-0600 JSON file through `VOLT_REGIONAL_BROWSER_CONFIG`, containing `marker`, `base_url` (`https://app.volt.im`) and two `accounts` with `name`, `email`, and `password`. Names must start with `novpnqa_` and emails use `example.invalid`. It creates those accounts through the encrypted registration form and tests only their private DM: live delivery, large ciphertext, idle heartbeats, reload, password login, history decryption and anonymous isolation. A separate anonymous apex trace checks the Russian connection; the application does not proxy through Cloudflare. The test also rejects requests to the retired external domain. Credentials remain in that file; the report and screenshot are saved alongside it. ## Conversation links `GET /api/links/resolve?server=NAME&channel=NAME` resolves the web client's `/s/SERVER/CHANNEL` paths into `{server, chat}` for native navigation. URL-encode each path component and query value independently. Omitting `channel` selects the first accessible channel; an unknown or inaccessible channel never falls back to another conversation. Community servers require server membership. Historical private groups use `chat.user_ids`, matching roster and chat APIs. Outsiders and members who left, were removed, or whose server was deleted cannot resolve these links. The isolated local `api_tests/protocol_membership_test.py` covers legacy group links, restricted/default channels and revocation. Set `VOLT_NATIVE_BINARY` to a built native Volt executable to exercise the same fixture through its link UI action with isolated credentials and caches. ## Contact nicknames `PUT /api/contacts/:user_id/nickname` accepts and returns `{nickname}`. The caller must have a contact entry or a direct conversation with that account. The server trims surrounding whitespace and accepts up to 64 characters on one line. Send an empty string to restore the original display name. `GET /api/contacts` and `GET /api/chats/:id/peer` include the caller's `nickname`. Direct conversation summaries from `GET /api/me/chats` and `GET /api/allchats` provide `contact_user_id` and `contact_nickname`. Existing names and user IDs retain their original values. ## Messages and events | Method and path | JSON / result | | --- | --- | | `POST /api/chats/:id/messages` | `{text, reply_to_id?}` → confirmed message including its database ID | | `GET /api/chats/:id/messages` | Up to 100 messages, ascending IDs; exclusive `before` or `after` cursor | | `GET /api/chats/:id/history` | `{cleared_id, messages, next_before}` for client-side history search | | `PATCH /api/chats/:id/messages/:message` | `{text}` → edited message | | `DELETE /api/chats/:id/messages/:message` | Soft-delete an authored channel message or either participant's DM message for everyone | | `POST /api/chats/:id/messages/:message/reactions` | `{emoji}` toggles a supported quick reaction; returns decorated message | | `POST /api/chats/:id/read` | `{message_id, thread_id?}` stores a monotonically increasing read cursor for the timeline or the specified thread | | `GET /api/chats/:id/reads` | Every member's timeline cursor, or thread cursor with `?thread_id=ID`: `[{user_id, message_id}]` | | `POST /api/chats/:id/typing` | `{active, thread_id?}` broadcasts transient typing activity for the timeline or thread | History search pages contain up to 25 visible, non-deleted message bodies in descending ID order. The browser and desktop search locally after decrypting. Request another page with `?before=NEXT_BEFORE` until `next_before` is zero. Discard earlier results if `cleared_id` changes between pages. The endpoint accepts no search text and does not modify read state or message history. A DM participant can delete received messages for everyone as well as their own. This never grants editing rights to received messages or deletion of another author's channel messages, including to a server owner. Retries are idempotent; both live devices and offline sync receive deletion tombstones. Per-account history-clear boundaries still apply. Run `VOLT_INTEGRATION_CONFIG=... python3 api_tests/protocol_dm_deletion_test.py` against a local server and dedicated accounts to check these permissions. `GET /api/chats/:id/messages/:message?include_deleted=true` additionally returns a deleted original as a tombstone with empty `text`, for refreshing off-page reply previews. Ordinary navigation rejects deleted originals. Membership, chat identity and per-account history-clear boundaries apply to both forms. Native Volt decrypts display-only snapshots without fetching media or inserting the original into its contiguous history range. Run `api_tests/protocol_reply_test.py` with a dedicated local QA configuration to check these access boundaries. New posts and edits in direct messages, including Saved Messages, use the `enc:v1:` encrypted envelope. Channels and group chats use plain text. Clients can still decrypt older channel and group messages using their original keys. Reply targets must be in the same chat. History excludes deleted messages. Reactions are included in history and message updates. Read state is stored server-side and restored after reconnect/restart. New messages are broadcast to all authorized devices, including the sender's other devices. Clients must deduplicate REST confirmations and WebSocket echoes by message ID. Other events have `event` and `chat_id` fields: - `message_updated`: full `message`, including reactions. - `message_deleted`: `message_id`. - `read`: `user_id`, `message_id`. - `typing`: `user_id`, `user`, `active`, and `thread_id` (zero for the timeline). Clients refresh active typing at most every three seconds and expire it after six seconds. `DELETE /api/chats/:id` clears and hides a DM for the authenticated participant. The optional `?revoke=true` explicitly clears both participants atomically, with the same message-ID boundary. Omitting it or using `revoke=false` affects only the requester. Other values are rejected. Only DM participants can invoke this operation, including when blocked; channels reject it. Saved Messages appears automatically in the account's DM list and stays visible when its history is cleared. Each affected account receives its own `conversation_state` event, and sync/roster responses restore the boundary on offline devices. Cleared messages remain excluded after reopening, including direct navigation, reactions, editing and idempotent send retries. This does not erase copies already downloaded or retained by clients. The message burst limit counts the ten preceding messages only while they are inside the current send's ten-second window. An expired burst does not mute an otherwise eligible new send. Repetition and channel-spread checks still apply. `api_tests/protocol_spam_window_test.py` checks expiry and active-burst rejection using dedicated local QA accounts and PostgreSQL fixtures. ## Message threads Start a thread from any message in a channel, group chat, or DM by posting to `/api/chats/:chat_id/messages` with `thread_id` set to the original message ID. A thread starts when its first reply is posted. Send and render DM thread messages with the parent's encryption keys. The parent message supplies the thread preview, including its normal encryption and deletion behavior. | Route | Response or behavior | |---|---| | `GET /api/chats/:id/threads` | `{threads, next_before}` with root messages in descending ID order | | `GET /api/chats/:id/threads/:root` | `{root, messages, next_before}` with up to 50 replies in ascending ID order | | `POST /api/chats/:id/messages` | With `thread_id`, creates a thread post. Optional `reply_to_id` must identify the root or another post in that thread. | Both reads accept an exclusive `before` cursor. `next_before=0` marks the end. Parent messages expose `thread_reply_count`. Thread posts carry `thread_id` and arrive as `thread_message` events with the confirmed `message`. Message edits, reactions and deletions use the same message-ID endpoints and events. Thread posts stay out of the parent transcript, read cursor, and bridge delivery. A regular quoted reply with no `thread_id` stays in the parent transcript. Deleting the root leaves existing replies accessible and closes the thread to new posts. A DM history clear hides threads anchored at or below the clear boundary, including any later posts in those threads. ## Channel slow mode `GET /api/chats/:id/slow-mode` returns `{chat_id,slow_mode_delay,remaining_ms,exempt}` to channel members. The server owner is exempt. DMs reject this API. Owner-only `PUT` accepts `{slow_mode_delay}` with seconds `0,10,30,60,300,900,3600`; zero disables the policy and resets existing waits. Policy changes and accepted sends in a channel with slow mode emit `slow_mode_changed` with `chat_id`; clients fetch their own remaining time, including after reconnecting. Every new message, including replies and attachment announcements, uses the same atomic eligibility check and insertion. Concurrent sends cannot claim the same slot. A cooldown returns HTTP 429 with `chat_id` and `remaining_ms`; validation failures consume no slot. Deletion does not reset a slot. Confirmed `client_id` retries return the original message during the wait without extending it. Only a newly confirmed insertion is forwarded to bridges. Existing bridge imports retain their platform's delivery rules. Run `VOLT_INTEGRATION_CONFIG=... python3 api_tests/protocol_slow_mode_test.py` against dedicated local accounts to verify concurrency, permissions and expiry. ## Profile photos `PUT /api/me/avatar` accepts `{data}` containing canonical base64 of a file up to 2 MB (2,097,152 decoded bytes). `DELETE /api/me/avatar` clears the photo. Both return `{user_id,revision,data,hidden,unchanged}`. Revisions increase atomically, including clears and concurrent updates. Only the account authenticated by the cookie can change its own photo. `GET /api/users/:id/avatar` returns the same shape. Photos are profile metadata, visible to authenticated users, and are not conversation ciphertext. A bilateral block returns `hidden:true`, revision zero and no data, including when the caller supplies a known revision. Self photos remain visible to their owner. An optional `?known_revision=N` suppresses data and sets `unchanged:true` when the visible photo revision matches; clients must retain their existing cached photo in that case. A missing/cleared photo has empty data. Blocks do not erase copies already downloaded by another device. `GET /api/users/:id/avatar/image` returns the original bytes with the same authentication and block checks. `avatar_updated` WebSocket events contain `user_id`, without photo data. Updates reach the account's devices and existing unblocked DM peers; block/unblock also invalidates both participants' cached views. Clients fetch the current photo after an event and reconcile missed updates after reconnecting. Run `VOLT_INTEGRATION_CONFIG=... python3 api_tests/protocol_avatar_test.py` with dedicated accounts and a local server to verify validation, visibility and concurrent updates. ## Resources and encrypted attachments | Method and path | JSON / result | | --- | --- | | `POST /api/servers` | `{name, long_name, members:[username,...]}` → private server with a general channel | | `POST /api/servers/:id/chats` | Owner-only `{name}` → channel | | `GET /api/servers/:id/channel-management` | Owner/admin-only `{roles,channels}` with channel visibility and role IDs | | `POST /api/servers/:id/roles` | Owner/admin-only `{name}` → role; up to 100 per server | | `GET /api/servers/:id/roles/:role/members?after=ID` | Owner/admin-only assigned members, cursor and `has_more`; 100 per page | | `PUT /api/servers/:id/roles/:role/members` | Owner/admin-only `{username,assigned}`; target must be a server member | | `PUT /api/servers/:id/chats/:chat/visibility` | Owner/admin-only `{restricted,role_ids:[ID,...]}` | | `DELETE /api/servers/:id/chats/:chat` | Owner/admin-only permanent channel deletion, including messages and uploaded files | | `POST /api/dms` | `{username}` or `{user_id}` → existing or newly created private DM; your own ID opens Saved Messages | | `GET /api/servers/:id/members?after=ID` | Member-only public user fields, owner flags, cursor and `has_more`; 100 per page | | `GET /api/servers/:id/invite?username=NAME` | Owner-only private-server invitation target and public encryption key | | `POST /api/servers/:id/members` | Owner-only atomic history-sharing invitation (see below) | | `DELETE /api/servers/:id/members/:user` | Owner-only membership removal; owner cannot remove themselves | | `POST /api/chats/:id/files` | `{data}` → attachment `id` | | `GET /api/chats/:id/files/:file` | `{data}` for an authorized chat member; HTTP 410 `FILE_REMOVED` once an ephemeral file was erased | | `POST /api/chats/:id/files/:file/seen` | Participant confirms a local copy of an ephemeral file → `{removed}` | Server creation allows up to 20 additional members and 10 owned active servers. Self conversations have one stable ID across concurrent devices and one encryption recipient. Their notes, attachments, forwarding and clearing use the ordinary encrypted conversation APIs. Channels default to visibility for everyone with access to the server. A restricted channel requires at least one selected role; the owner and administrators always have access. Selecting no roles makes it visible only to the owner and admins. Visibility applies to channel lists, direct links, message/file APIs, encryption recipients and WebSocket messages. Leaving, removal and banning clear assigned roles. Removing a role assignment or changing channel visibility retires initialized keys before further writes. `channel_access_changed` with `server_id` tells clients to discard cached channel/key data and reload their permitted channels. Previously downloaded content cannot be recalled. Channel deletion permanently removes the channel's messages, reactions, read/mute state, search records and encrypted files; other channels and DMs are preserved. Run `VOLT_INTEGRATION_CONFIG=... python3 api_tests/channel_management_test.py` against a disposable local server/database to exercise access, key retirement and deletion. The config supplies `base_url`, `server_id`, `server_name`, `admin`, and `accounts` in owner/member/outsider order (each with `id`, `name`, `token`). Set `PGHOST`, `PGUSER`, `PGDATABASE` and `VOLT_UPLOAD_DIR` for the same isolated fixture. Including `ws_port` also runs live WebSocket delivery and role revocation checks. Small file uploads accept at most 8 MiB of JSON. Volt uses this endpoint for files up to 4 MiB. In channels and group chats, `data` uses `plain:v1:` followed by base64 file bytes. In DMs, `data` is the existing AES-GCM envelope containing encrypted base64 file bytes. Previously uploaded files keep their original format. Filenames and media metadata appear in the `volt:file:v1:` message manifest with `id`, `name`, `size`, and any media-specific fields. ### Pasted images Pasting an image into the composer sends it as a legacy file whose message JSON also carries `mime` (`image/png`, `image/jpeg`, `image/gif` or `image/webp`) and `ephemeral`. The browser sends supported images up to 4 MiB unchanged and re-encodes larger ones as JPEG, shrinking them until they fit. Bridged channels receive `[Image]` as their readable copy. For click-to-reveal images, the manifest sets `blurred:true` and `is_image:false`. Clients that support blurred images conceal the preview until the recipient activates it. Older clients display an ordinary file entry. In DMs and non-community group chats the upload sets `ephemeral:true` (community channels reject it and keep their files). The uploader counts as having a copy. Every other participant keeps a copy on the device and calls `POST .../files/:file/seen` after the image was on screen; when all participants (both DM users, or the chat's `user_ids`) confirmed, the server erases the file data and keeps a tombstone. Later downloads return HTTP 410 with code `FILE_REMOVED`, so a device without its own copy, including a participant's other devices, cannot recover the image. Confirmations are idempotent and serialized per file; admins and other non-participants do not count. The browser keeps the original file data in IndexedDB (`volt-images`). The mobile app keeps files in its private data directory. Videos use the same endpoint and add `is_video:true` and `mime:"video/mp4"` to the manifest. Clients compress videos on-device and upload MP4s up to 4 MiB. A recipient explicitly downloads the video and sends the existing `/seen` confirmation as soon as its local copy is saved. Community channels keep their videos. Bridges receive the readable `[Video]` placeholder. Run `VOLT_INTEGRATION_CONFIG=... python3 api_tests/protocol_ephemeral_files_test.py` with dedicated alice/bob/outsider accounts; an optional `community_chat_id` checks that community channels keep their files. Larger files use `POST /api/chats/:id/uploads` with `{client_id, size}` to reserve up to 2 GiB of plaintext. `GET /api/chats/:id/uploads/:upload` reports acknowledged chunks; `PUT /api/chats/:id/uploads/:upload/chunks/:index` accepts `{data}` with immutable encrypted chunk contents. `POST /api/chats/:id/uploads/:upload/complete` finishes the file, and `DELETE /api/chats/:id/uploads/:upload` cancels an unfinished reservation. Authorized members download completed chunks with the same GET chunk path. Each plaintext chunk is 1 MiB except the last; an independent file key, file/index binding and SHA-256 digest are carried inside the manifest. Reservations include encrypted storage overhead, with shared legacy/chunked caps of 5 GiB per account and 8 GiB server-wide. Unfinished reservations expire after 48 hours. Native file-drop and clipboard uploads keep private durable copies and resume automatically after restart; their message identity and acknowledged chunks persist. Direct uploads also resume when the same file is selected again. Browser downloads stream when file saving is supported; the memory fallback is limited to 128 MiB. `GET /api/chats/:id/encryption` returns `enc_keys`, `enc_epoch` and `enc_key_history` from one snapshot. History is a serialized JSON map from epoch numbers to serialized recipient key maps. Epoch zero is the original format; envelopes without an `epoch` field use zero. Message and legacy file envelopes include their key epoch. Chunked files retain independent file keys inside their message manifests. DM key updates at `POST /api/chats/:id/encryption` accept `enc_keys`, `enc_epoch`, optional `expected_keys`, and optional `enc_key_history` plus `expected_history`. All key maps and snapshots are serialized JSON strings. Existing wrapped keys must remain unchanged; history may only gain current members' wrapped keys. Updates compare the epoch and previous values atomically. A conflict returns HTTP 409 and requires refetching. Initialization includes every currently initialized member, and clients reuse the winning key after a race. An invitation requires `user_id`. To share legacy encrypted history, also send `expected_public_key` and `channels`, an array of `{chat_id, expected_keys, wrapped_key, enc_epoch, expected_history, history}`. Wrap the current key and every historical key for the target with RSA-OAEP-SHA256; the invitation's `history` maps each epoch to the target's wrapped key. All unrestricted encrypted channels must have matching snapshots. Restricted channel keys supplied by older clients are ignored: new members have no roles yet. Any conflict rolls back all key and membership updates and returns HTTP 409. Epoch-zero invitations may omit the new fields when no history exists. Repeated invitations and removals do not change the member count twice. Removal revokes API access and emits `server_removed` to the removed user's devices; `server_changed` asks remaining and invited members to refresh their roster. Removal, voluntary leave and ban archive initialized keys, clear the current key map and advance its epoch in the membership transaction. Repeated departures and channels without a current legacy key do not advance it again. Server-level locks serialize membership changes, channel creation and writes. In a DM, a stale message, edit or file upload returns HTTP 409 with code `CHAT_KEY_CHANGED` before storage. Clients refetch and encrypt again after this explicit rejection. Clients without epoch support need an update after a rotation. Prior recipients retain downloaded content and old keys. Account recovery remains unimplemented. ## Public workspace logos `GET /img/server_logos/:id.png` serves a workspace's PNG logo without authentication, like the existing static image URLs. Resolve this path against the account's server address. New and replaced files are available immediately, without restarting the service or rebuilding the startup static-file manifest. Both successful and missing-file responses use `Cache-Control: no-store` so browsers and proxies cannot retain a missing or replaced logo. Missing files and noncanonical positive integer IDs return 404. Browser workspace logos use this route too. Include `deploy/nginx-server-logos.conf` inside the nginx `volt.im` server block when a legacy `/img` alias exists. The narrower route passes uploaded logos to the backend instead of an unrelated image directory. Validate with `nginx -t` and reload nginx. With a local server already running, run `python3 api_tests/protocol_server_logos_test.py` from the repository root. It checks runtime creation, replacement, removal, MIME type and invalid filenames using a temporary file, then removes it. ## DM voice calls `POST /api/chats/:id/call` relays call signals to the other participant's authenticated WebSocket. Android and the web client include a UUID `call_id`. A `ring` carries an audio WebRTC offer in `description` and `accept` carries the answer. `reject` and `hangup` carry no description. The offer and answer include gathered ICE candidates. Both clients use STUN for direct connections and can relay encrypted WebRTC audio through TURN when the networks prevent a direct connection. To enable relay, configure the web service with `VOLT_TURN_URLS` (comma-separated TURN URLs) and `VOLT_TURN_SECRET` (the same secret as coturn's `static-auth-secret` with `use-auth-secret` enabled). Include a TCP or TLS URL for networks that block UDP. The authenticated `GET /api/call/ice` endpoint returns temporary credentials and an empty list when relay is unconfigured. ## Validation and deployment Run `node api_tests/protocol_web_test.mjs` for browser-code regressions. The companion Volt repository provides `-voltim-integration-test`, dedicated-account provisioning, and WebCrypto interoperability tests. On 2026-10-26 the built Volt executable passed the complete production integration run using three dedicated ordinary accounts and private resources at `https://volt.im/s/voltqa_1026024306_43_r7`. No credentials are stored in Git. `VOLT_INTEGRATION_CONFIG=/private/local-qa.json python3 api_tests/protocol_revocation_test.py` checks two-sided history clearing, concurrent requests, authorization, stale actions/retries, Saved Messages and reopening against an isolated local server. The native client's `VOLT_INTEGRATION_SUITE=deletion` additionally checks live removal for both accounts, block/unblock and offline history/outbox cleanup. Build Linux binaries locally with `bash deploy.sh --backend-only`; it uploads the binary, keeps a rollback copy, restarts the service, and checks HTTP health. The deployment build explicitly enables Boehm garbage collection (`-gc boehm`) and rejects builds that silently omit it. Some compiler versions disable Boehm for cross-compilation even when requested; use `VEXE=/path/to/compatible/v` to select a compiler with Linux GC support. OpenSSL is selected explicitly for TLS. The runtime host must satisfy the executable's dynamic library dependencies. A production build without GC was killed by the OOM killer during the native integration regression. An isolated local comparison repeated 200 authenticated downloads of the same 292,687-byte encrypted fixture: RSS grew by 259 MiB without GC and 13 MiB with Boehm. The compiler guard rejected both an explicit no-GC build and a Linux cross-build that ignored `-gc boehm`. The compatible Linux executable contains the linked `GC_init`, `GC_malloc` and `GC_gcollect` implementations. The full native Volt protocol regression also passed against this GC-enabled server. Include `deploy/nginx-uploads.conf` inside the `volt.im` nginx server block, then validate with `nginx -t` and reload nginx. Its 12 MiB request limit permits both encrypted legacy attachments and resumable chunks. nginx's default 1 MiB limit rejects encrypted chunks before they reach the API. For this deployment the default compiler lacked `libpq-fe.h`, and V's fallback compiler successfully produced the Linux executable. Both native client builds and the macOS app build passed. Video and full Telegram feature parity remain outside the verified coverage of that integration run.