JSON API
Most commands take --json. That output is a contract: muster-tui, the MCP server, CI and your scripts drive muster through it. This page covers the conventions and the shapes you'll use most.
Conventions
- stdout is JSON only. Streams are NDJSON (one object per line); everything else is one document. Human text goes to stderr.
- Errors before output are one document on stderr:
{"error":"<code>","message":"…"}, non-zero exit. - Errors inside a stream are an
{"event":"error","reason":…}event, then asummary. - New fields can appear at any time; ignore ones you don't know. Fields are only removed in a major version.
| Exit code | Meaning |
|---|---|
| 0 | Success |
| 1 | Failure (or an error document on stderr) |
| 130 | Cancelled (Ctrl+C / SIGTERM) |
status --json and cloud status --json exit 0 even when services are unhealthy or you're logged out: they report state.
Auth: MUSTER_TOKEN
Every --json command needs a token in MUSTER_TOKEN. Read-only commands need the read scope; anything that changes something needs deploy.
export MUSTER_TOKEN=$(muster auth create ci --scope deploy | awk '/Token:/{print $2}')
muster deploy --json --stop-on-failureExceptions: muster env and muster flag are local and not gated, and verify --json needs no token.
Commands
| Command | Scope | Output |
|---|---|---|
status --json | read | document |
history --json [--all] [svc] | read | array |
insights --json [svc] [--days N] | read | document |
doctor --json | read | document |
hooks status --json | read | document |
hooks approve --yes --json | deploy | document |
deploy --json [svc…] | deploy | NDJSON |
rollback / restart <svc> --json | deploy | NDJSON |
rollout status --json [--watch] | read | document / NDJSON |
promote / abort <svc> --json | deploy | NDJSON |
logs <svc> --json [--tail N] | read | NDJSON |
fleet list / status / test --json | read | document |
cloud status / activity --json | read | document |
cloud notify test --json | deploy | document |
env … --json, flag … --json | none (local) | document |
The full reference lists every command and flag.
status --json
{
"project": "acme-store",
"muster_version": "0.7.1",
"checked_at": "2026-11-26T13:40:05-05:00",
"deploying": false,
"deploy_lock": null,
"services": {
"api": {
"name": "API Server",
"status": "healthy",
"stack": "k8s",
"target": "http://localhost:8080/health",
"last_deploy": { "ts": "2026-11-26 13:38:00", "status": "ok", "commit": "4f2a9c1" },
"replicas": { "ready": 3, "desired": 3 },
"version": "v1.4.1",
"strategy": "canary",
"rollout": null
}
}
}statusstringstackstringlocked_by / deployingobject / boolreplicasobject | nullversion / image / revisionstring | nullrolloutobject | nulldeploy --json
NDJSON events, in order. The main ones:
| Event | Fields |
|---|---|
start | service, name, index, total, log_file |
git_pull | service, status (pulling / done / failed), remote, branch |
log | service, line |
done | service, status (success / failed / timeout / blocked; paused / aborted for rollouts), exit_code |
health | service, status (checking / healthy / unhealthy) |
diagnosis | After a failed k8s deploy: pattern, summary, pod, events, logs |
hint | After a failure the rules engine recognises: title, try, fix |
skipped | service, reason (no_hook, locked, rollout_in_progress) |
cancelled | service, exit_code: 130 |
error | reason (hooks_not_approved, preflight_failed…), message, services |
summary | Totals and one result per service (last line) |
{"event":"summary","total":3,"deployed":1,"failed":1,"skipped":0,"not_run":1,"rolled_back":0,"paused":0,
"duration":42,"exit_code":1,"stopped_early":true,
"services":[
{"service":"api","result":"deployed","duration":30,"health":"healthy","version":"4f2a9c1","strategy":"rolling",
"phases":{"preflight":1,"hook":24,"build":15,"health":4,"total":30}},
{"service":"web","result":"failed","duration":12,"health":"-"},
{"service":"worker","result":"not_run","duration":0,"health":"-"}]}result is deployed, failed, skipped, not_run, rolled back or paused (a rollout waiting at a step; exit 0). Useful flags: --stop-on-failure, --from svc, --dry-run, --yes (approve hooks).
hint.fix.command yourself. Ask the user, then run muster explain <svc> --fix --yes, which re-derives and validates it.rollback and restart stream the same events for one service, with "action" set on start and summary.
history --json
An array, oldest first (last 20 unless --all):
[{"timestamp": "2026-11-28 10:15:40", "service": "api", "action": "deploy", "status": "ok",
"commit": "4f2a9c1", "source": "local", "version": "4f2a9c1", "strategy": "rolling",
"duration": 95, "exit_code": 0,
"phases": {"preflight": 2, "git_pull": 3, "hook": 70, "build": 40, "health": 5, "total": 95},
"cache": {"steps": 12, "cached": 10, "ratio": 0.83, "buildkit": true}}]action: deploy, rollback, restart, promote, abort. status: ok, failed, cancelled. Timing fields are null for entries recorded without them; treat every field as optional.
rollout status --json
{"project": "acme-store", "checked_at": "2026-11-28T14:33:05-05:00",
"services": {"api": {
"state": "paused", "strategy": "canary", "traffic_mechanism": "replicas",
"step": 1, "total_steps": 4, "weight": 25, "effective_weight": 25,
"next_gate": {"type": "manual", "next_weight": 50, "remaining_seconds": null},
"versions": [
{"role": "stable", "deployment": "acme-api", "version": "v1.4.1", "weight": 75, "health": "healthy"},
{"role": "canary", "deployment": "acme-api-canary", "version": "v1.4.2", "weight": 25, "health": "healthy"}],
"last_analysis": {"status": "pass", "checks": [{"name": "pod_stability", "ok": true}, {"name": "health", "ok": true}]}}}}statestringeffective_weightnumbernext_gate.typestring | null--watch --json prints one rollout_state line per service per poll. deploy, promote and abort stream rollout_step, traffic_shift, analysis, promoted and aborted events.
insights --json
{"project": "shop", "days": 30, "service_filter": null,
"summary": {"deploys": 61, "ok": 57, "failed": 4, "success_rate": 0.93, "median_seconds": 135,
"previous": {"deploys": 20, "median_seconds": 99}, "rollbacks": 1},
"services": [{"service": "api", "median_seconds": 134, "p95_seconds": 135, "trend_pct": 35,
"phases": {"build": 77, "deploy": 24, "health": 11},
"slowest_phase": {"name": "build", "seconds": 77, "share": 0.66}, "mttr_seconds": null}],
"suggestions": [{"id": "docker_cache_miss", "service": "api",
"savings_per_month_seconds": 946,
"fix": {"label": "Copy the dependency manifests and install before COPY . .", "command": null,
"snippet": "COPY package.json package-lock.json ./\nRUN npm ci\nCOPY . ."},
"auto_fix": null}]}Durations are whole seconds, null without data. Suggestions are ranked by savings_per_month_seconds; auto_fix: "dockerignore" means muster insights --fix can apply it. See Insights.
cloud activity and notify
{"events": [{"v": 1, "id": "…", "ts": "2026-11-28T22:02:00Z", "action": "deploy",
"result": "success", "project": "demo", "services": […]}],
"next_cursor": null}--limit 1–200 (default 20), newest first. Error codes: not_logged_in, pro_required, not_available, network_error, no_channels (notify).
Everything else
doctor, hooks, logs, fleet, env and flag shapes, the rollout events and every timing field are in docs/ENGINE-API.md on GitHub.