Skip to content
Exit codes and JSON output

Exit codes and JSON output

Exit codes

CodeMeaningTypical cause
0Success
1Other errorI/O error, unexpected response or redirect from the portal
2Usage or configurationBad flags, no key, no organization chosen, config file readable by others
3Not authenticated or not allowedHTTP 401 (missing, unknown, revoked or expired key) or 403
4Not foundHTTP 404: no such machine, checkpoint, organization or SSH key
5Rejected or failedHTTP 400, 409 or 422; a machine or checkpoint ended in failed
6Timeout--wait ran past --timeout
7UnavailableHTTP 429 or 5xx (after retries for reads), network error or timeout

space ssh is the exception: it exits with ssh’s status.

Output streams

  • Data goes to stdout: tables for lists, key: value lines for one object.
  • Messages, progress and errors go to stderr. Without --json, an error is error: <message>, followed by a hint: line for 401 and 403.
  • Wait progress (dev: creating…) is shown only when stderr is a terminal.
  • No colours yet.

JSON output

With --json, stdout holds the portal API’s object, pretty-printed, without the envelope: space machines show dev --json prints the machine, space machines list --json the list of machines. Field names and values are the API’s, so they do not change with the CLI’s table layout.

A machine:

{
  "id": "0b7c6f9e-3c1d-4a51-9f0e-2d5a8c1e7b44",
  "name": "dev",
  "state": "running",
  "vcpus": 2,
  "mem_mib": 2048,
  "disk_gib": 10,
  "base": null,
  "error": null,
  "ingress_mode": null,
  "ingress_port": null,
  "ssh_host_keys": ["ssh-ed25519 AAAA…"],
  "created_by": "user:3f1c8a52-7d4e-4b9a-8c21-5e6f7a8b9c0d",
  "on_behalf_of": "user:3f1c8a52-7d4e-4b9a-8c21-5e6f7a8b9c0d",
  "created_at": "2026-11-06T10:00:00Z",
  "updated_at": "2026-11-06T10:00:04Z"
}

Errors go to stderr as one line of JSON:

{"error": {"code": "invalid", "message": "…", "details": {"name": ["has already been taken"]}}}
codeHTTPExit
bad_request4005
unauthorized4013
forbidden4033
not_found4044
conflict4095
invalid4225
rate_limited4297
region_unavailable502, 5037

Errors that do not come from the portal use the same shape with their own codes:

codeExitMeaning
usage2Bad flags or configuration
network7Could not reach the portal
failed5A machine or checkpoint ended in failed
timeout6--wait ran past --timeout
error1Anything else (exit code 1)
Last updated on