Skip to content

Assistant API ​

Project-scoped AI assistant for managing monitors and servers. Uses the same DeepSeek-backed stack as incident analysis and counts toward ai_analysis_limit_per_month.

Architecture (durable runs) ​

Assistant LLM/tool/SSH execution does not run inside the HTTP request.

  1. POST .../messages (or POST .../resume) creates an AssistantRun and enqueues AssistantChatJob on the Que default queue (priority 10).
  2. The que_default / ECS que-default worker runs AssistantAgent + tools (including Net::SSH) and finalizes the assistant message.
  3. Progress streams to clients over ActionCable (AssistantConversationChannel).
  4. Closing the browser tab does not cancel the run.

Statuses: queued → running → (waiting_human) → succeeded | failed | cancelled.

Authentication ​

Requires project authentication (Authorization: Bearer <project_or_user_token>). When using a user token, send X-Project-UUID if needed.

ActionCable requires a user authentication token (session cookie or ?token= / Authorization: Bearer <user_authentication_token>). The channel rejects non-members of the conversation's project.

ActionCable ​

URLwss://api.uptinio.com/cable?token=<user_authentication_token> (local: ws://localhost/cable?token=...)
ChannelAssistantConversationChannel
Params{ "conversation_uuid": "ASC..." }
Streamassistant_conversation_<uuid>
AuthUser must be a project member
OriginsSPA origins allowlisted via action_cable.allowed_request_origins (same list as CORS: www/uptinio.com, staging, Vite localhost)

Subscribe before posting a message so you do not miss early status / delta events.

Cross-process broadcasts (Que → browser) use Solid Cable on the primary Postgres database (solid_cable_messages). REDIS_URL is not required. Web and Que must share the same DB (they already do for Que jobs).

Host nginx in front of the container must forward WebSocket upgrades for /cable (see nginx-host-cable.conf and assistant-cable-ops.md). If Upgrade headers are stripped, ActionCable returns plain 404 Page not found and the SPA hangs on Thinking….

Client timeout / polling fallback ​

Clients must not wait forever for subscription confirmation or for done. Recommended:

  1. Timeout subscription ready (~8–15s) with a clear cable/proxy error.
  2. Timeout the run wait (~90–180s); then GET /api/v1/assistant/runs/:run_uuid and/or refetch the conversation.
  3. If the run is succeeded / failed / waiting_human, settle UI from persisted messages even if cable was silent.

Get run status ​

GET /api/v1/assistant/runs/:uuid

json
{
  "run": {
    "uuid": "ASR...",
    "kind": "chat",
    "status": "succeeded",
    "error": null,
    "conversation_uuid": "ASC...",
    "message_uuid": "ASM...",
    "started_at": "...",
    "finished_at": "...",
    "created_at": "..."
  },
  "conversation": { "uuid": "ASC...", "messages": [ "...included when terminal or waiting_human..." ] }
}

Event shapes ​

Every event includes run_uuid, conversation_uuid, and run_status.

typeWhenClient should
statusRun start, each tool start/end, SSH progressUpdate activity label (not only “Thinking…”)
deltaToken/chunk of assistant reply (frequent)Append content to the in-progress assistant bubble
toolTool start / end / recordedOptional structured activity / debug UI
errorRun failedShow error and stop waiting
doneRun finished (or paused for human)Settle UI from message / refetch
needs_credentials / needs_approvalWaiting on humanShow credential / approval widget
json
{ "type": "status", "content": "Thinking…", "run_uuid": "ASR...", "conversation_uuid": "ASC...", "run_status": "running" }
{ "type": "status", "content": "Looking up recent incidents…", "run_uuid": "ASR...", "conversation_uuid": "ASC...", "run_status": "running" }
{ "type": "tool", "name": "list_incidents", "phase": "start", "arguments": { "status": "ongoing" }, "run_uuid": "ASR...", "conversation_uuid": "ASC...", "run_status": "running" }
{ "type": "tool", "name": "list_incidents", "phase": "end", "success": true, "run_uuid": "ASR...", "conversation_uuid": "ASC...", "run_status": "running" }
{ "type": "delta", "content": "Created ", "run_uuid": "ASR...", "conversation_uuid": "ASC...", "run_status": "running" }
{ "type": "tool", "name": "create_monitor", "phase": "recorded", "action": { "...": "..." }, "run_uuid": "ASR...", "conversation_uuid": "ASC...", "run_status": "running" }
{ "type": "error", "success": false, "error": "...", "run_uuid": "ASR...", "conversation_uuid": "ASC...", "run_status": "failed" }
{ "type": "done", "success": true, "conversation_uuid": "ASC...", "message": { "...": "..." }, "actions_taken": [], "run_uuid": "ASR...", "run_status": "succeeded" }
{ "type": "needs_credentials", "success": true, "pending_action": { "...": "..." }, "message": { "...": "..." }, "run_uuid": "ASR...", "run_status": "waiting_human" }
{ "type": "needs_approval", "success": true, "pending_action": { "...": "..." }, "message": { "...": "..." }, "run_uuid": "ASR...", "run_status": "waiting_human" }

When a run pauses for credentials/approval, clients also receive a done event with waiting_human: true.

Streaming contract: clients must append every delta.content as it arrives. Do not wait for done to render the reply — done only finalizes persistence metadata. If the model withholds token deltas after tool rounds, the worker still emits progressive delta chunks (split from the final text) before done.

Activity status examples: Looking up recent incidents…, Listing monitors…, Checking server details…, Connecting over SSH…, SSH still running… (Ns / Ts), then back to Thinking… between tool rounds.

Conversations ​

List conversations ​

GET /api/v1/assistant/conversations

json
{
  "data": [
    {
      "uuid": "ASC...",
      "title": "Create HTTP monitor",
      "created_at": "2026-11-10T12:00:00Z",
      "updated_at": "2026-11-10T12:05:00Z"
    }
  ]
}

Create conversation ​

POST /api/v1/assistant/conversations

Body (optional):

json
{ "title": "Optional title" }

Get conversation ​

GET /api/v1/assistant/conversations/:uuid

Returns the conversation with messages (oldest first).

Delete conversation ​

DELETE /api/v1/assistant/conversations/:uuid

Resume (credentials / command approval) ​

POST /api/v1/assistant/conversations/:uuid/resume

When a tool needs secrets or allowlist approval, the assistant message includes metadata.ui and the run emits needs_credentials / needs_approval:

  • credential_form — collect credentials via the Credentials API, then resume with refs only (or cancel)
  • command_approval — allow, allow_and_remember, or deny

Credentials submitted (secrets already stored; only UUIDs):

json
{ "type": "credentials_submitted", "credential_uuids": ["CRD..."] }

Credentials cancelled (dismiss the credential form without submitting):

json
{ "type": "credentials_cancelled" }

Command approval:

json
{ "type": "command_approval", "decision": "allow" }

decision may be allow, allow_and_remember (adds the binary to the project allowlist), or deny.

Response (202 Accepted) — run is queued; watch ActionCable for completion:

json
{
  "success": true,
  "conversation_uuid": "ASC...",
  "run_uuid": "ASR...",
  "status": "queued",
  "pending_action": { "...": "..." }
}

Conversation JSON may include pending_action while a widget is outstanding.

Messages ​

Send a message ​

POST /api/v1/assistant/conversations/:uuid/messages

json
{ "content": "Create an HTTP monitor for https://example.com every 5 minutes" }

Success response (202 Accepted):

json
{
  "success": true,
  "conversation_uuid": "ASC...",
  "conversation_title": "Create an HTTP monitor…",
  "run_uuid": "ASR...",
  "status": "queued",
  "user_message": {
    "uuid": "ASM...",
    "role": "user",
    "content": "Create an HTTP monitor…",
    "metadata": {},
    "actions_taken": [],
    "created_at": "2026-11-10T12:01:00Z"
  },
  "pending_action": null
}

The assistant reply is not in this response. Subscribe to AssistantConversationChannel and wait for done (or needs_credentials / needs_approval / error).

When the monthly AI limit is reached, the API returns 402 with limit_reached: true.

Streaming note ​

stream=true / Accept: text/event-stream no longer runs the agent inside the HTTP request. The POST still returns the enqueue JSON above. Use ActionCable for real-time tokens, status, and tool activity.

Capabilities ​

The assistant can:

  • List / get / create / update / pause / resume / delete network monitors
  • List / get servers, update alert settings, delete servers
  • Return Linux agent install instructions (servers self-register; no REST create)
  • Check latest server-agent release via get_server_agent_latest_version (optional compare to a server's reported agent version)
  • Update an agent over SSH with a short path: get_server_install_instructions then one run_ssh_command using update_command / install_command (timeout max 300s; ActionCable emits SSH progress status events)
  • Search incidents with filters, inspect incident detail, and read incident event timelines
  • List monitor check transactions to correlate failures with incident history
  • Inspect tool schemas via get_tool_info (arguments, required fields, and option enums)
  • Request credentials via request_credentials (form schema only — never secret plaintext; see Credentials API)
  • Run customer-server commands via run_server_command (enqueues ServerCommandJob for the Go agent)
  • SSH into customer hosts via run_ssh_command / install packages via install_on_server (vaulted ssh_pem or username_password; see Assistant SSH)
  • No local/platform shell on the Uptinio application host (run_command is removed)
  • Record tool-gap alerts when a capability is missing

Ops / security invariants ​

  • Workflow: clarify → plan → execute; support @server mentions by hostname/UUID and @credential mentions by name
  • Model/AI only sees credential refs (cred:CRD…, names, or @name) — no read_secret tool; CredentialBroker strips @ and matches slugified names
  • Commands (Go agent + SSH) pass CommandAllowlistFilter unless project.allow_all_commands
  • SSH tools never return private keys/passwords; stdout/stderr are secret-scrubbed
  • Unknown/missing tools soft-message the user and record a project-scoped ToolGapAlert
  • Approval policy: allowlist + remember + pending_action / waiting_human (unchanged product behavior)

Incident tools ​

ToolPurposeKey filters / args
list_incidentsSearch project incidentsstatus, severity, incident_type, monitorable_type, resource_uuid, confirmed (true/false/all), snoozed, start_date, end_date, search, has_ai_analysis, include_logs, include_statistics, limit
get_incidentFull incident detail + optional logsuuid, include_logs
get_incident_eventsTimeline / history messagesuuid, limit, order
list_monitor_transactionsCheck-result historymonitor_uuid, start_date, end_date, transaction_type, status, include_statistics, limit

list_incidents defaults to confirmed incidents (confirmed=true) to match the public incidents API. Pass confirmed=all or confirmed=false when investigating flapping/unconfirmed checks.

Supported check regions for monitor create/update: us and eu only.

Destructive deletes require an explicit confirmation turn in chat before the tool runs with confirmed=true.