Request → Response handlers in web/server, mounted as /api routes by web/app. All endpoints bind to loopback by default; there is no authentication layer. Set VITE_FLEET_PI_CHAT_RUNTIME_URL to point the browser at a remote runtime.
Every API handler checks the request’s origin. Requests from local clients are allowed. Error responses use a standard message and code shape that stays compatible with older payloads.
Session commands, resume, and other session-scoped requests are rejected when the session’s project is no longer registered, including sessions that are already open. Resource discovery never reads snapshots from a session you cannot access. Session and project listing is read-only.
Chat
| Method | Path | Purpose |
|---|---|---|
| POST | /api/chat | Run a turn. Streams NDJSON ChatStreamEvent frames; the first frame advertises adapterCapabilities. Pass an optional childId with the parent sessionId to send a text message to a subagent. |
| POST | /api/chat/abort | Abort the active turn and cancel its pending dialogs. With childId, abort only that subagent. |
| POST | /api/chat/question | Answer a pending tool-Question. The web workspace sends a skip automatically. |
| GET | /api/chat/events?sessionId= | SSE channel for out-of-turn pushes, with ring-buffer replay via Last-Event-ID. |
| POST | /api/chat/command | Execute a slash command. |
| GET | /api/chat/commands | Slash command autocomplete. |
| POST | /api/chat/completion | Inline composer completion for a draft. An empty response means no suggestion. |
| GET | /api/chat/intent | Composer command routing status for Settings → Chat. |
| POST | /api/chat/intent | Route a composer draft to a built-in command, or decline. |
| PATCH | /api/chat/intent | Turn composer command routing on or off. |
| PUT | /api/chat/intent | Store or clear the TypeSafe API key. The key is never returned. |
| PUT | /api/chat/artifacts | Store an OpenUI HTML artifact. |
| GET | /api/chat/dashboards | Dashboard status for Settings → Dashboards: configured, mode (cloud or self-hosted), keySource (settings, environment, or none), model, and modelSource (settings, environment, or default). |
| PUT | /api/chat/dashboards | Store or clear the Thesys API key (apiKey) and the dashboard builder model (model). Pass null to clear a field. The key is never returned. Returns the updated status. |
| POST | /api/chat/dashboards/token | Create an OpenUI Cloud frontend token for the dashboard view. Returns 404 when no Thesys API key is set. |
| POST | /api/chat/dashboards/interpreter?sessionId=&dashboardId= | Fetch data for an OpenUI Cloud dashboard in a session. Returns 404 for an unknown session or when no Thesys API key is set. |
| POST | /api/chat/openui/tool | Run a read-only data tool for an OpenUI Query(...) in generated UI. Body { name, args?, sessionId? }, where name is workspace_tree, list_sessions, list_resources, session_stats, or session_outputs. sessionId selects the open session and is used only by session_outputs. Returns { ok, rows } with at most 200 rows (50 by default); session_outputs also returns columns, total, and toolCalls. An unknown or malformed request returns 400. See Data for generated UI. |
Sessions
| Method | Path | Purpose |
|---|---|---|
| POST | /api/chat/new | Create a session ({ cwd, model?, thinkingLevel? }). |
| POST | /api/chat/resume | Resume by sessionId or sessionFile. |
| GET | /api/chat/session | One session with its messages; with attachmentId, fetch an attachment; with parentSessionId and childId, fetch a subagent transcript. |
| POST | /api/chat/session | Upload attachments to a session. |
| PUT | /api/chat/session | Store a plan presentation. |
| PATCH | /api/chat/session | Edit or delete a queued steering or follow-up message. |
| GET | /api/chat/session-tree | Branch tree of a session. |
| POST | /api/chat/session-tree | Rewind the session to an earlier entry and return the updated tree. |
| GET | /api/chat/sessions?cwd= | List sessions for the session picker. |
| PATCH | /api/chat/sessions | Rename a session. |
| DELETE | /api/chat/sessions | Delete a session. |
Models, providers, and settings
| Method | Path | Purpose |
|---|---|---|
| GET | /api/chat/models | Model catalog from the Prime Agent daemon, cached by Fleet for about 5 seconds. diagnostics reports custom providers in models.json that are missing apiKey. |
| POST | /api/chat/models/discover | Probe an OpenAI-compatible endpoint’s /v1/models. On failure, returns an empty models array with an optional error string that never contains credentials, for example Could not refresh models. Previous results are retained; try again. Discovery URLs that include a username or password are rejected. |
| GET | /api/chat/providers | Provider catalog and credential status. Credentials in a stored custom provider baseUrl are removed from the response. |
| POST | /api/chat/providers/oauth | Always returns 501. Sign in from the Prime Agent terminal with /login instead. |
| GET | /api/chat/settings | Resolved engine settings. |
| PATCH | /api/chat/settings | Write settings to the Prime Agent settings.json. Pass scope: "project" to write <project>/.prime/agent/settings.json or scope: "global" to write ~/.prime/agent/settings.json. Without scope, Fleet writes to the project file only if it already has settings. Returns the updated settings plus updateImpact (changedKeys, newSessionRecommended, resourceReloadRequired). Returns 409 with code UNWRITABLE when the file cannot be parsed or written. |
| GET | /api/chat/resources | Skills, prompts, and extensions available to the session. |
| GET | /api/chat/mcp | List the MCP connections reported by the Prime Agent daemon. Each status (connected, needs_auth, disabled, anonymous) reflects a verified credential, and acceptsPastedToken marks servers that accept a token through POST /api/chat/mcp/token. If the daemon request fails, the endpoint returns the error instead of a fallback list. |
| POST | /api/chat/mcp | Add or update an MCP server connection. |
| DELETE | /api/chat/mcp | Remove an MCP server connection. |
| POST | /api/chat/mcp/oauth | With action: "logout", sign out of an MCP server that uses OAuth. login (the default) and reconnect return 501; sign in from the Prime Agent terminal with /mcp login <name> instead. |
| POST | /api/chat/mcp/token | Store a pasted token (name, token) for an MCP server that accepts one. The token is never echoed back. Returns verified, toolCount, an optional error, and connections. A token that fails verification is still stored and returns 200 with verified: false. |
Projects
| Method | Path | Purpose |
|---|---|---|
| GET | /api/projects | List projects with their sessions and statuses. |
| POST | /api/projects | Create a project. |
| PATCH | /api/projects | Rename a project. |
| DELETE | /api/projects | Delete a project. |
| POST | /api/projects/fork | Fork a project session. |
| GET | /api/projects/browse | Directory picker for binding a project to a path. |
Workspace
| Method | Path | Purpose |
|---|---|---|
| GET | /api/workspace/tree | File tree of the active project’s directory. |
| GET | /api/workspace/file | File preview. |
Health
| Method | Path | Purpose |
|---|---|---|
| GET | /api/health | Liveness check. Returns ok and the server’s uptimeMs. |