Use the CLI in scripts and agents
This guide describes the new interface in the current CLI source checkout. Its
package publication is pending; use your installed --help as the reference for
a previously published version.
Use Node.js 20 or later and the installed saaslayer CLI. Commands that reach
SaaSLayer need a login or the authentication method documented in their help.
Inspect the interface without signing in:
saaslayer --help
saaslayer --version --json
saaslayer deployment settings set --help --jsonHelp and installed-version inspection do not load credentials or contact services.
Command-local --version, such as a deployment release selection, keeps its own meaning.
Find commands by object
Use account for cached management logins, project for projects, catalog for
available modules, and deployment for deployed instances. Bare groups show help.
The everyday deploy, status, update and destroy shortcuts share their
corresponding deployment actions.
saaslayer account list
saaslayer project list
saaslayer catalog list
saaslayer deployment status
saaslayer login sessions listdeployment status always returns a collection. Add selectors to narrow it;
there is no separate command selected implicitly by whether you supplied an ID.
--deployment accepts an exact deployment ID or an environment such as dev.
Use --region when an environment has more than one matching deployment.
User-service configuration lives under users; enterprise sign-in remains under
sso. Foundation, connection, trust rotation and SMS commands live under aws.
See the CLI reference for every command.
Read one JSON result
Add global --json to get exactly one JSON document on stdout for handled success
or failure. You can place it before, between or after command words. JSON mode
never prompts and does not mix progress, child output or ANSI formatting into stdout.
saaslayer --json account listWith no cached accounts, the result is:
{"schemaVersion":1,"command":"account.list","ok":true,"data":{"items":[]},"error":null,"meta":{"operation":null,"pagination":null,"next":[]}}Read command results from data. Lists use data.items; binding exports use
data.variables. command is the canonical dotted action, so deploy --json
reports deployment.create. Unknown commands use null. JSON help uses cli.help;
installed-version inspection uses cli.version and data.version.
Failures have ok:false and an error with code, message, retryable and
details. A failure can also retain observed data or an operation handle. Do not
assume data is null on failure, or treat an accepted operation as completed.
An unrecognized service error becomes a safe CLI error rather than a raw response dump.
To preserve the exit status while inspecting a result in a POSIX shell:
if saaslayer account list --json > result.json; then
jq '.data.items' result.json
else
cli_status=$?
jq '.error' result.json
exit "$cli_status"
fi| Exit | Meaning |
|---|---|
| 0 | Completed, preview, staged success or accepted --no-wait |
| 1 | Action or internal failure |
| 2 | Syntax, validation, missing input or consent |
| 3 | Authentication or permission |
| 4 | Missing resource, conflict, protection or required approval |
| 5 | Transport, service unavailability or deadline |
| 6 | Partial work, including an acknowledged change whose result could not be delivered |
| 130 / 143 | Local SIGINT / SIGTERM interruption |
If stdout closes, a result cannot always be delivered. The CLI does not write a second document or retry the action to compensate for a broken output pipe. A forced kill, runtime crash or power loss can also prevent a complete document; inspect existing state before retrying a mutation.
Follow managed operations
Managed mutations wait for completion by default. Where supported, --no-wait
returns acceptance with the real operation handle and a structured continuation:
saaslayer users create --email teammate@example.com --delivery invitation --deployment dev --no-wait --jsonThis example creates an account and can send an invitation when you run it. Use your development deployment and an address you control. Read the returned operation ID, then inspect or follow that existing operation:
saaslayer users operations get op_example --deployment dev --json
saaslayer users operations watch op_example --deployment dev --jsonReplace op_example with the returned ID. Deployment operations use
deployment operations get|watch. Other command families can return their own
supported status action in meta.next. Each continuation has command, args
and flags; dotted command IDs correspond to space-separated CLI words.
Credentials are not copied into continuations. Supply your authorized login or
credential source when following one.
Local interruption stops local waits and children. It does not remotely cancel
an operation or replay a write whose outcome is uncertain. Inspect the known state
before submitting another mutation. Caller-run migrations, standalone management
and foreground foundation work do not gain fabricated operation handles or a
--no-wait mode.
Control interaction and diagnostics
| Global flag | Behavior |
|---|---|
--json | One versioned result document on stdout; no prompts |
--non-interactive | No prompts; missing inputs become handled errors |
--debug | Safe CLI diagnostics on stderr |
--no-color | Disables ANSI colors and terminal cursor control |
--silent | Suppresses optional diagnostics, progress and prompts, including debug; primary results and required errors remain |
Non-TTY stdin never prompts. --yes accepts an existing confirmation only. It
cannot replace a required reason, permissions, protected-environment checks,
foundation requirements, data-custody choices or secret-delivery gates.
DEBUG=saaslayer:cli:* selects CLI diagnostics; existing DEBUG exclusions are
respected. --debug enables the CLI namespaces when no DEBUG selector is set.
--no-color, NO_COLOR or TERM=dumb disables diagnostic colors; redirected stderr has no colors.
Debugging does not enable token, request-body or arbitrary object dumps and does
not create log files. A deliberately returned one-time key remains primary result
data: protect captured result files accordingly.
-- ends option processing. Words after it are positional values, even when they
look like flags. Do not put a global policy flag after -- and expect it to apply.
Update older scripts
Use the replacement named in migration guidance. Removed spellings do not execute as compatibility aliases. Common replacements include:
| Previous spelling | Current spelling |
|---|---|
accounts, bare executable account | account list |
projects | project list |
stacks | catalog list |
deployment logins, deployment use | login sessions list, login sessions use |
env export | bindings export |
| Top-level settings, releases and operations | Commands under deployment |
| Top-level foundation and SMS | Commands under aws |
Managed users admin … --wait | Omit --wait; use --no-wait for acceptance |
Settings patches use repeatable --set MODULE.Setting=VALUE and JSON settings files
use --settings FILE. Module types use --module; a deployed instance keeps its
--service selector. --aws-account selects the target AWS account; --profile
selects credentials. Management login labels use --control-plane.
SSO connection organizations use --allowed-org; hook grant pairs use --grant-org.
Verifier-key purpose uses --purpose. The Users and Permissions API endpoints stay
distinct as --api-base and --permissions-api-base. Private secret file destinations
use --to-file where documented. --config-url remains the global control-plane
endpoint selector.
Results now use command-specific data objects; update jq paths against the
command's schema. For example, a completed users create result puts the user ID
at data.user.id. Read its schema with saaslayer users create --help --json.
A --no-wait acceptance can have a null user and an operation to follow.
Without --json, binding exports retain their selected plain dotenv or JSON format:
saaslayer bindings export --binding bind_example > .env.localReplace bind_example with your consumer binding ID. --json instead wraps the
variables under data.variables. Migration approval-required results now use exit4;
applied-but-unreported migration work uses exit6.