Skip to content

JSON output

Every command accepts --json. Results go to stdout; prompts, masked diffs and human-readable diagnostics go to stderr. Check the exit code to detect failure.

A failing command prints one object on stdout:

{ "error": { "code": "ambiguous_target", "message": "shop-prod matches 2 services: …" } }
Code Meaning
usage Invalid arguments
resolution_failed No target matched
ambiguous_target Several candidates; use a prefix or a pin
unreachable_or_auth A server didn’t answer, refused the token, or has an incompatible API
command_failed The command failed
declined A confirmation was declined or couldn’t be asked
stack_locked Another job holds the stack
restart_timeout A self-update hand-off didn’t finish in time
interrupted Ctrl-C
env_conflict A concurrent env edit needs manual reconciliation
env_apply_failed The env file was saved but an apply failed

In streaming commands, an error arrives as a final NDJSON record after the records already emitted. An env apply failure can follow a successful save record.

server ls, ls and jobs keep per-host reachability errors inside their results instead of failing.

Command Output
--help {usage}
--version {version}
server add {host, url, client}
server ls {servers: [{host, url, reachable, version, api, client, error}]}
server rm {host}
ls {containers, unreachable}
status (container) A container object with host, stackInfo and jobs
status (stack) {host, containers, stackInfo, jobs}
logs NDJSON: {host, t, stream, line}
update, apply, restart, start, stop NDJSON: {host, …JobEvent}. With --detach: {host, job}
jobs {jobs, unreachable}
jobs attach NDJSON: {host, …JobEvent}
env {host, stack, file, changed: false}, or after a save {host, stack, file, changed: true, etag, backup}
env history {host, stack, file, entries: [{id, kind, time}]}
env restore --yes {host, stack, file, etag, backup}
pin {name, host}
unpin {name}
hide, show {targets, hidden}
ui {url} for each login URL
completion Not available with --json (usage error)
  • unreachable entries are {host, error}.
  • Containers are the API’s container objects with a host field. Jobs are job objects with a host field.
  • stackInfo is the stack response without services, or null for an unmanaged container.
  • In server ls, an unreachable server has reachable: false, null version, API and client, and an error string.
  • In logs, t is an RFC 3339 time or null without --timestamps, and stream is stdout or stderr.

Action and jobs attach streams emit line records and one final end record:

{"host":"edge","type":"line","t":"2026-11-22T14:00:01Z","stream":"stdout","line":"→ pull"}
{"host":"edge","type":"end","job":{"id":"k3f9x2","action":"update","state":"succeeded","exitCode":0,"…":"…"}}

Example: update everything with image drift

Section titled “Example: update everything with image drift”
Terminal window
moira ls --drift --json |
jq -r '.containers[] | select(.drift.image) | "\(.host)/\(.stack)/\(.service)"' |
sort -u |
xargs -n1 moira update --yes --json