HTTP API

Responses are JSON unless a route streams events, downloads a file, or serves static assets. Errors generally use:

1
{ "error": "human-readable message" }

Authentication

GET /health, GET /authcheck, and static application assets are open. Every other API route requires the configured token via bearer header, X-Auth-Token, or the pi_ui_token cookie.

The token query parameter is allowed only on GET requests. Auth failures are rate-limited by client IP.

Health and runners

RoutePurpose
GET /healthLiveness and safe process, backend, and database diagnostics
GET /authcheckReport whether supplied token locations are valid without exposing the token
GET /eventsSSE stream for runner output and server events
GET /runnersList runner status
DELETE /runners?id=…Stop and remove a runner
POST /open-sessionCreate or resume a runner for a session
POST /restart?runner=…Restart one runner
POST /rpc?runner=…Forward a pi RPC object verbatim
POST /workdirSet the workspace and spawn a runner there

Sessions

Canonical session references are opaque ps1_… keys. JSONL path parameters remain compatibility inputs and should not be used by new clients.

RoutePurpose
GET /sessionsList saved sessions and live-runner status
GET /session-by-idResolve a session by pi session ID
GET /session-entriesRead durable active-branch entries
GET /session-messagesRead durable active-branch messages
GET /session-foldersList known session workspaces
GET /searchSearch conversations by session, folder, or all sessions
DELETE /session?key=ps1_…Delete through the selected backend capability
GET /analytics/usageAggregate SQLite session token and cost usage

Credentials

RoutePurpose
GET /api-keysReturn safe provider and source status, never key material
POST /api-keysSave or replace an API key
DELETE /api-keysRemove a locally stored API key
POST /oauth/startBegin a transient Pi-owned OAuth flow
POST /oauth/statusPoll a flow's current interaction or terminal state
POST /oauth/respondAnswer one pending interaction
POST /oauth/cancelCancel and abort a flow
DELETE /oauthRemove a local OAuth credential

Credential mutations can restart runners that were active at mutation time. Local removal does not revoke provider keys or grants.

Files

RoutePurpose
GET /browseList a confined directory; files=1 includes files
GET /file-contentRead an editable text file up to 2 MiB
GET /file-downloadDownload a confined file
POST /file-saveAtomically save UTF-8 text
POST /file-uploadUpload raw data, optionally in ordered chunks
POST /mkdirCreate a directory

File routes accept only paths under the configured safe roots and deny known credential stores.

Routines and hublots

RoutePurpose
GET /routinesList routines, bindings, and live state
POST /routinesStart, stop, teardown, or release a routine
GET /tunnelsList hublots and tunnel configuration
POST /tunnelsReserve a port, prepare its service, and open a hublot
PATCH /tunnelsRebind a hublot to a session
DELETE /tunnels?id=…Close a hublot

See the route modules in server/http/routes/ for exact request and response schemas. Clients should tolerate additive response fields.