Machine API
The /api/agents/* surface is the canonical machine contract. The browser, CLI, and MCP server all sit on top of it.
Authentication
Local dev defaults to no auth. For production, machine clients authenticate with a device token:
curl -H "X-Agents-Token: YOUR_DEVICE_TOKEN" \
http://localhost:8080/api/agents/sessionsDevice tokens are managed from the Devices page in the browser or via the API. Browser access uses cookie-based auth separately.
Sessions
Ship transcripts
# The Machine Agent ships transcripts as storage-v2 envelopes
# (X-Longhouse-Storage-Lane: live|repair). That is the engine's wire format,
# not a scripting contract. To import a file by hand:
longhouse-server ship --file path/to/session.jsonl
# GET /api/agents/storage/v2/capabilities returns the protocol version,
# ingest path, and size limits for the calling machine
curl -H "X-Agents-Token: $LONGHOUSE_DEVICE_TOKEN" \
http://localhost:8080/api/agents/storage/v2/capabilitiesList sessions
curl "http://localhost:8080/api/agents/sessions?query=auth+retry&limit=10"
# Query parameters:
# query - search query
# limit - max results (default 20, max 100)
# offset - pagination offset
# project - filter by project name
# provider - filter by provider id (claude, codex, cursor, opencode, pi, omp, antigravity)
# environment - filter by environment (production, development, test, e2e)
# device_id - filter by device ID
# days_back - look back N days; with a query, omit to search all
# indexed history (default: 14-day window when listing
# without a query)
# include_test - include test/e2e sessions (default: false)
# hide_autonomous - hide sub-agents (default: true)
# mode - search mode: lexical|semantic|hybrid (default: lexical)
# sort - sort order: relevance|recency|balancedGet session detail
curl http://localhost:8080/api/agents/sessions/SESSION_IDReturns full session metadata, event count, timing, and project context.
Get session events
curl "http://localhost:8080/api/agents/sessions/SESSION_ID/events?limit=100"
# Query parameters:
# limit - max results (default 100, max 1000)
# offset - pagination offset
# roles - comma-separated roles to filter (assistant, user, system, tool)
# tool_name - exact tool name filter (e.g., Bash)
# query - content search within session
# context_mode - forensic|active_context
# branch_mode - head|all (include abandoned branches)Returns the raw event stream — messages, tool calls, tool outputs, and system events in chronological order.
Get session tail
curl "http://localhost:8080/api/agents/sessions/SESSION_ID/tail?limit=30"
# Returns the last N events from a session
# Useful for cross-session reading of recent activityGet session thread
curl "http://localhost:8080/api/agents/sessions/SESSION_ID/thread"
# Returns all continuations in the logical threadGet session projection
curl "http://localhost:8080/api/agents/sessions/SESSION_ID/projection?branch_mode=head"
# Returns the stitched lineage-path projection for a focused session
# Combines thread with events in one viewGet session workspace
curl "http://localhost:8080/api/agents/sessions/SESSION_ID/workspace"
# Returns focused session, thread, and projection in one round trip
# Optimized for single HTTP call on session openExport session
curl "http://localhost:8080/api/agents/sessions/SESSION_ID/export?branch_mode=head" \
> session.jsonl
# Export session as JSONL for Claude Code --resumeCoordination
Wall (active sessions)
curl "http://localhost:8080/api/agents/sessions/wall?project=zerg&days=7"
# Query parameters:
# repo - filter by git_repo (substring match)
# project - filter by project name
# days - look back N days (default 7)
# limit - max results (default 50, max 200)Returns raw signal metadata for active and recently active sessions.
Send directed input
curl -X POST http://localhost:8080/api/agents/directed-inputs \
-H "X-Agents-Token: $LONGHOUSE_COORDINATION_TOKEN" \
-H "X-Longhouse-Session-Id: $SOURCE_SESSION_ID" \
-H "Content-Type: application/json" \
-d '{"target_session_id": "TARGET_SESSION_ID", "text": "Check the failing test", "client_request_id": "check-test-1"}'
# Persists before any safe-boundary delivery attemptRecover directed input
curl "http://localhost:8080/api/agents/directed-inputs?direction=inbound&after_id=0&limit=20" \
-H "X-Agents-Token: $LONGHOUSE_COORDINATION_TOKEN" \
-H "X-Longhouse-Session-Id: $CURRENT_SESSION_ID"
# Query parameters:
# direction - inbound|outbound|all (default: inbound)
# after_id - stable input cursor (default: 0)
# limit - max results (default 50, max 200)Reply to directed input
curl -X POST http://localhost:8080/api/agents/directed-inputs/INPUT_ID/reply \
-H "X-Agents-Token: $LONGHOUSE_COORDINATION_TOKEN" \
-H "X-Longhouse-Session-Id: $CURRENT_SESSION_ID" \
-H "Content-Type: application/json" \
-d '{"text": "The test is fixed", "client_request_id": "check-test-reply-1"}'Send live message to active session
curl -X POST http://localhost:8080/api/agents/sessions/SESSION_ID/send-live \
-H "X-Agents-Token: YOUR_DEVICE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text": "Check that test"}'
# Sends message to an actively running session (if connected)Set session action
curl -X POST http://localhost:8080/api/agents/sessions/SESSION_ID/action \
-H "Content-Type: application/json" \
-d '{"action": "park"}'
# Actions: park|snooze|archive|resumeSend presence signal
curl -X POST http://localhost:8080/api/agents/presence \
-H "X-Agents-Token: YOUR_DEVICE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"session_id": "SESSION_ID", "state": "running", "provider": "claude"}'
# state: thinking|running|idle|needs_user|blocked|stalled. Returns 204.Health
Health check
curl http://localhost:8080/api/health
# Returns status (healthy, degraded, or unhealthy with HTTP 503) and the
# build identity. Loopback, admin, and internal callers also get per-check detail.Readiness
curl http://localhost:8080/api/readyz
# Readiness: returns 200 when the catalog service answers, 503 otherwiseResponse format
All endpoints return JSON. List endpoints support limit and offset for pagination. Errors return a JSON object with a detail field.
Same surface everywhere. The browser, CLI, and MCP server are all thin wrappers around these endpoints. Anything you can do in the browser, you can script against the API.