JSON API

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 a summary.
  • New fields can appear at any time; ignore ones you don't know. Fields are only removed in a major version.
Exit codeMeaning
0Success
1Failure (or an error document on stderr)
130Cancelled (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.

Terminal
export MUSTER_TOKEN=$(muster auth create ci --scope deploy | awk '/Token:/{print $2}')
muster deploy --json --stop-on-failure

Exceptions: muster env and muster flag are local and not gated, and verify --json needs no token.

Commands

CommandScopeOutput
status --jsonreaddocument
history --json [--all] [svc]readarray
insights --json [svc] [--days N]readdocument
doctor --jsonreaddocument
hooks status --jsonreaddocument
hooks approve --yes --jsondeploydocument
deploy --json [svc…]deployNDJSON
rollback / restart <svc> --jsondeployNDJSON
rollout status --json [--watch]readdocument / NDJSON
promote / abort <svc> --jsondeployNDJSON
logs <svc> --json [--tail N]readNDJSON
fleet list / status / test --jsonreaddocument
cloud status / activity --jsonreaddocument
cloud notify test --jsondeploydocument
env … --json, flag … --jsonnone (local)document

The full reference lists every command and flag.

status --json

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
    }
  }
}
statusstring
healthy, unhealthy, disabled, no_health_check or blocked (health hook failed the security check).
stackstring
k8s, compose, docker, dev or bare.
locked_by / deployingobject / bool
A deploy of this service is running, on any terminal or machine.
replicasobject | null
k8s only, when kubectl answers within 5s.
version / image / revisionstring | null
What the service runs: from the cluster on k8s, from history elsewhere.
rolloutobject | null
The rollout object while a blue-green or canary rollout is in progress.

deploy --json

NDJSON events, in order. The main ones:

EventFields
startservice, name, index, total, log_file
git_pullservice, status (pulling / done / failed), remote, branch
logservice, line
doneservice, status (success / failed / timeout / blocked; paused / aborted for rollouts), exit_code
healthservice, status (checking / healthy / unhealthy)
diagnosisAfter a failed k8s deploy: pattern, summary, pod, events, logs
hintAfter a failure the rules engine recognises: title, try, fix
skippedservice, reason (no_hook, locked, rollout_in_progress)
cancelledservice, exit_code: 130
errorreason (hooks_not_approved, preflight_failed…), message, services
summaryTotals 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).

Never run 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):

JSON
[{"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

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}]}}}}
statestring
progressing, paused, awaiting_promotion, degraded, or idle when nothing is rolling out.
effective_weightnumber
Canary's real share of ready pods; differs from weight with few replicas.
next_gate.typestring | null
manual (run promote), promotion (blue-green) or timer.

--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

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.