Wizard

Search documentation

Jump to any page or section

REST API & WebSocket Event Protocol Specification

Wizard exposes a high-performance control plane over HTTP/REST and bidirectional WebSockets. This reference documents the transport models, authentication headers, session management, and the streaming event protocol.

Interactive OpenAPI 3.1 documentation is served live on your instance at http://localhost:8000/docs.


1. Authentication & Session Headers

HeaderRequiredPurposeExample
X-Session-IdOptionalBinds the request to an existing analytical session. Auto-created if omitted.7ce22de891044f8e82342468aafe940c
X-API-KeyConditionalRequired for mutating routes when API_KEY is configured in backend/.env.wiz_secret_key_994
Content-TypeYesStandard MIME type for JSON payloads (application/json) or multipart uploads.application/json

2. Core REST Endpoints

System, Health & SRE Diagnostics

  • GET /health: Comprehensive cluster readiness check (alias to /health/ready).
  • GET /health/live: Kubernetes process liveness probe returning HTTP 200 {"status": "ok"} when the process is alive.
  • GET /health/ready: Kubernetes cluster readiness probe that actively validates SQLite writeability, Redis reachability, and Docker socket health. Returns HTTP 503 if any critical dependency is degraded.
  • GET /metrics: Prometheus-compatible exposition format reporting Time-To-First-Token (TTFT), rolling p50/p90/p95/p99 latency quantiles, token generation counters, and error budgets.
  • GET /api/config: Capabilities manifest used by the frontend to render feature workbenches (data modes, sandbox capabilities, active tier, embedding status).
  • PATCH /api/config: Dynamically updates runtime configuration (API_PROVIDER, DATA_MODE, EMBEDDING_PROVIDER, EMBEDDING_REMOTE_MODEL, etc.) with atomic .env persistence and dynamic embedding service re-warming.
  • GET /api/sandbox/selftest: Probes live OS sandbox enforcement (Landlock, seccomp, seatbelt) and returns containment verdict.

Session Lifecycle

  • POST /api/session: Creates a new isolated analytical session. Returns SessionResponse with unique session_id.
  • GET /api/session: Returns current session state, loaded tables, models, and data privacy policies.
  • DELETE /api/session: Destroys the session, drops ephemeral dataframes, and terminates execution sandboxes.
  • POST /api/session/reset: Resets Python execution variables while preserving loaded datasets.

Datasets & Ingestion

  • POST /api/datasets: Ingests multipart files (CSV, Parquet, Excel, Feather, JSON) into the session workspace.
    • Query parameter clean=true|false: Triggers automated data cleaning pass.
  • GET /api/datasets: Lists all mounted tables and preview metadata in the session catalog.
  • DELETE /api/datasets/{name}: Unmounts a table and purges cached vector embeddings.

Skills & Knowledge

  • GET /api/skills: Returns all discovered built-in, user, and project skills.
  • POST /api/skills/install: Stages and imports an external skill from a Git URL.

Analytical Turn Execution

  • POST /api/chat: Executes a synchronous analytical turn and returns the complete synthesized response with code and citations. Includes idempotency locking.
  • POST /api/chat/stream: Server-Sent Events (SSE) streaming endpoint for environments where bidirectional WebSockets are restricted or subject to backpressure shedding. Returns streaming event frames identical to /ws/chat.

3. WebSocket Streaming Protocol (/ws/chat)

For interactive real-time UX, clients establish a persistent WebSocket connection to /ws/chat. The server streams granular event frames as the agent observes, reasons, and executes:

json
{
"type": "iteration_start",
"iteration": 1,
"budget": 12,
"timestamp": 1787907459.12
}

Complete Event Frame Specification:

Event TypePayload FieldsArchitectural Significance
sessionsession_id, data_modeEmitted once on handshake to confirm session binding.
reasoning_deltacontentStreamed tokens from the Manager's chain-of-thought deliberation.
plansteps, hypothesisStructured multi-stage plan authored by the Manager.
actionkind, targetMove chosen by the agent (code, consult, reflect, parallel, answer).
codecode, languageSandboxed Python code generated by the Worker model.
stdoutcontentReal-time standard output from the isolated execution sandbox.
observationoutput, okResult of the action fed back into the agent's observation loop.
findingcontentIntermediate statistical insight discovered from execution output.
assumptiondescription, sourceTransparent extraction of silent data operations (null drops, joins, type coercions).
verificationmetric, match, discrepancyResult of dual-calculation verification re-deriving the headline conclusion.
content_deltacontentStreamed tokens of the final synthesized answer.
artifactname, type, urlInteractive chart (Plotly HTML), exported Parquet file, or report document.
approval_requiredaction_id, promptPauses the turn; prompts user for explicit consent before running privileged actions.
usageprompt_tokens, completion_tokens, cost_usdFinancial and token accounting (emitted only when cloud models run).
doneturn_id, duration_secSignals completion of the analytical turn.

4. Subagent Branching Multiplexing

When an analytical task fans out into parallel sub-investigations (e.g. comparing 4 marketing channels simultaneously), each branch reuses the same event frames, qualified by a branch field:

json
{
"type": "code",
"branch": "channel_search_paid",
"code": "df[df['channel'] == 'paid_search'].describe()"
}

The frontend multiplexes these events into concurrent subagent cards without requiring separate WebSocket connections.

Reviewed for Wizard v1.0.15Edit this page on GitHub