How to call the commands an App exposes, from a terminal, a script or an AI agent. To make an App expose commands, see Expose App commands; what is checked and refused is in ctl security.
Required on add. An https:// origin with no path, query or credentials.
--username
The DSM account. Prompted if omitted.
--password-stdin
Read the password from stdin (up to 4096 bytes).
--ssh-tunnel
Allow http://127.0.0.1 or http://[::1] for an SSH tunnel to the NAS.
--no-remember-device
Do not keep a DSM device token; OTP is asked at every sign-in.
Password and OTP prompts are hidden. Never pass them as arguments.
An account with OTP needs a terminal for the six-digit code, unless a remembered device token exists. Without a terminal and without --password-stdin the command fails with CTL_INTERACTION_REQUIRED.
Host names are letters, digits, ., _ and -, up to 64 characters. A name that exists gives CTL_HOST_EXISTS; use host login to renew it. To change the URL or account, add a second host name.
There is no current host. One registered host is used by default. With several, give --host nas, --host a,b or --all-hosts, otherwise CTL_HOST_REQUIRED (exit 3). Up to 4 hosts run in parallel.
Certificate trust, --strict-tls, --ca, host trust, environment credentials and session storage are shared by every command; see CLI reference.
ctl lists the installed packages with your session.
Before it reads any description it shows the candidate package@version batch and asks once. Without a terminal, pass --approve-installed. An agent must get the user’s authorization first.
It reads each App’s description, validates it and pins its hash. Same version and hash: the cache is used. --refresh reads again.
A new version needs approval again. A changed hash for the same version gives CTL_DESCRIPTION_CHANGED; approve with --refresh --approve-installed only after you know why.
--app <package> narrows the batch to one package. The result:
Field
Content
apps[]
One entry per valid App: package, aliases, protocolVersion, developedBy (provenance is always self-declared), hash, commands[].
commands[]
id, summary, cli, effect, permission, parameters (the schema, or a note that parameters are undescribed), flow, examples (runnable command lines).
diagnostics[]
Apps left out, each with package, code, message, hint. Codes: CTL_TRUST_REQUIRED, CTL_DESCRIPTION_CHANGED, CTL_DESCRIPTION_UNAVAILABLE, CTL_DESCRIPTOR_INVALID.
cacheHits
How many descriptions came from the cache.
Only valid Apps appear as commands. A failed App is a diagnostic and never runs. Discovery that returns diagnostics still exits 0.
string, integer, number and boolean parameters are typed flags: --text "Buy milk", --text=Hello, --limit 20. A boolean flag alone means true; --flag false sets it off. Integers must be safe integers.
Defaults of top-level properties are filled in; a default inside a nested object is not, so send nested values in --input. Required, type, enum and range errors are rejected before any request (CTL_PARAMS_INVALID, exit 3). The error never repeats your values.
Arrays and objects, and commands without a schema, take --input file.json or --input - (stdin). --input must be the only argument; the input is one strict JSON object of at most 1 MiB.
Flag values are in the process arguments, visible to other local users and shell history. Send secrets through --input -.
Reserved flag names, which a parameter cannot use as a typed flag (it must use --input): --ca, --strict-tls, --host, --all-hosts, --json, --app, --refresh, --yes, --dry-run, --approve-installed, --help, --input, --wait, --no-wait, --timeout.
Without a terminal on stdout the output is compact JSON. --json forces it. In a terminal it is indented JSON.
One host: {"ok":true,"data":...} or {"ok":false,"error":{"code","message","hint","allowed?","plan?"}}. Follow hint; allowed is the complete list of valid values.
Several hosts: {"ok":false,"results":[{"host":"nas","ok":true,"data":...},{"host":"lab","ok":false,"error":...}]}. Each host has its own envelope.
Sensitive values print as <redacted> in plans, dry runs, errors and output; the real request is unchanged.
A multi-host command had at least one failed host, including when all failed.
Any other ctl error without its own code exits 3 (for example CTL_HOST_EXISTS, CTL_URL_INVALID, CTL_INPUT_FILE).
The diagnostic codes of ctl list are not exit codes. Running an App that discovery left out gives CTL_APP_UNKNOWN (exit 3), and no business request is sent.
host list and host show exit 0 even with authenticated: false. Read the field.
With several hosts, exit 8 hides the per-host codes. Read each results[].error.code.
A missing session fails with 2 before confirmation is checked; 7 appears once discovery and validation succeeded.
check, build, inspect, status and test propagate their own exit code as well.
Waits by default. --no-wait returns {"accepted":true,"job":...} at once. --timeout <seconds> (1 to 3600) overrides the declared limit. A failed state is CTL_JOB_FAILED (5); a timeout is CTL_JOB_TIMEOUT (6), and the job may still be running.
paginate
{"items":[...]} from all pages.
Reads only. Over 100000 items or the page limit is an error, never a silent partial list.
ndjson
{"items":[...]} from the line stream.
At most 8 MiB and 10000 lines.
upload
The App’s response.
Typed flags carry the local file, the target parent and name, as the command’s schema names them. One regular file, up to 16 GiB, streamed once.
ctl never replays a request. After a network error or timeout the outcome is unknown: read the App’s state before repeating a write.
A job start is never repeated. After CTL_JOB_TIMEOUT query the job through the App.
Exit 7 means nothing ran; repeat with --yes if authorized.
After exit 8, do not rerun the whole command. Check the hosts that failed, then target them with --host.
--timeout <seconds> accepts 1–3600 and applies to discovery, JSON requests, polling and transfer inactivity. The default transport allowance is 62 seconds; calls within one operation share its remaining allowance.