Skip to content

Admin API

Miravo's HTTP and WebSocket admin API — health checks, metrics, commands, event streaming, instance inspection, model schemas, and remote simulation control.

The admin HTTP server runs alongside every Miravo simulation. Default bind: http://127.0.0.1:8080.

MethodPathPurpose
GET/healthzLiveness check
GET/readyzReadiness check (engine + adapters)
GET/metricsEngine metrics snapshot
GET/stateEngine state snapshot
POST/commandsExecute an engine command
POST/shutdownGraceful shutdown (daemon mode)
GET/instances/:idFull detail for one instance
GET/models/:nameModel schema
GET/eventsPaginated event log
GET/wsWebSocket upgrade for real-time streaming

Returns 200 when the engine is running and the tick loop is progressing. Returns 503 when stopped or stalled.

Terminal window
curl -s http://127.0.0.1:8080/healthz | jq .

Returns 200 when the engine is running and all enabled adapters are connected. Returns 503 if any adapter is disconnected or the engine is paused/stopped.

Structural snapshot with models, instances, configuration, and available adapters.

Terminal window
curl -s http://127.0.0.1:8080/state | jq .

Runtime metrics including tick count, instance count, and per-adapter statistics.

Full detail for a single instance: member values, parameters, methods, lifecycle, faults.

Terminal window
curl -s http://127.0.0.1:8080/instances/pump-001 | jq .

Model schema with parameters, members, methods, faults, and lifecycle definition.

Terminal window
curl -s http://127.0.0.1:8080/models/centrifugal-pump | jq .

Execute an engine command. Accepts a JSON command object — see supported command types below.

Terminal window
curl -s http://127.0.0.1:8080/commands \
-H 'content-type: application/json' \
-d '{"type":"pause"}'

Supported command types:

CommandKey fields
pause
resume
setSpeedmultiplier
spawnmodel, count, variation, parameterOverrides
removeInstanceinstanceId
setParameterinstanceId, parameter, value
triggerFaultinstanceId, fault
clearFaultinstanceId, fault
unquarantineinstanceId
invokeMethodinstanceId, method, arguments
loadTemplatetemplatePath, count
unloadTemplateRuntemplateRunId
resetSimulationclearPersistence
enableAdapteradapter, config
disableAdapteradapter

Example — invoke a model method:

Terminal window
curl -s http://127.0.0.1:8080/commands \
-H 'content-type: application/json' \
-d '{
"type": "invokeMethod",
"instanceId": "pump-001",
"method": "SetSpeed",
"arguments": {"speed_rpm": 900}
}'

Paginated event log with cursor-based pagination.

Fetch recent fault events:

Terminal window
curl -s 'http://127.0.0.1:8080/events?type=fault:triggered&limit=10'

Query parameters:

ParamDescription
typeFilter: fault:triggered, fault:cleared, lifecycle:changed, instance:created, instance:removed, engine:state-changed
instanceIdFilter by instance
limitPage size (default 100, max 1000)
cursorCursor for backward pagination

Response: { "events", "nextCursor", "total" }

Upgrade to WebSocket for real-time event streaming.

Terminal window
websocat ws://127.0.0.1:8080/ws

On connect, the server sends a snapshot message with current state. Then it pushes events on subscribed channels.

Channels: tick, faults, lifecycle, instances, engine, adapters (all enabled by default).

Change subscriptions:

{"type": "subscribe", "channels": ["faults", "lifecycle"]}

Max 10 concurrent WebSocket connections. Messages carry monotonic revision numbers for ordering.

Set MIRAVO_ADMIN_TOKEN to require bearer token auth on mutation endpoints:

Terminal window
export MIRAVO_ADMIN_TOKEN=my-secret-token

Commands now require the token:

Terminal window
curl -s http://127.0.0.1:8080/commands \
-H 'content-type: application/json' \
-H 'Authorization: Bearer my-secret-token' \
-d '{"type":"pause"}'

Read-only endpoints (/healthz, /readyz, /metrics, /state, /instances/*, /models/*, /events) do not require auth.

When binding to a non-loopback address, MIRAVO_ADMIN_TOKEN is required for mutation endpoints. Without it, POST /commands and POST /shutdown return 403.

OptionEnv VarDefaultDescription
--admin-portMIRAVO_ADMIN_PORT8080Admin server port
--admin-hostMIRAVO_ADMIN_HOST127.0.0.1Admin server bind host
MIRAVO_ADMIN_TOKENBearer token for mutation endpoints