Use the sasvi CLI
This page is for the practitioner who wants to verify environments, move tenant configuration, manage reference lists, and discover entity metadata from a terminal, without writing Python.
The Python SDK and the CLI sit on the same SVIClient. Anything you can do with sasvi <command> you
can also do from a script; the CLI exists to make common operational tasks short, safe, and
automatable in CI.
Install
Install sasvi from PyPI. The CLI
ships as an optional extra to keep the core SDK dependency-light, so ask for the cli extra:
pip install "sasvi[cli]"
That installs typer and rich and puts a sasvi script on your PATH. The plain
pip install sasvi keeps working for library
consumers; they just don't get the sasvi command.
Verify the install:
sasvi --version
# sasvi 0.2.1
# The legacy `sasvi version` subcommand still works for back-compat:
sasvi version
# sasvi 0.2.1
If sasvi isn't on your PATH, you can also invoke the CLI as a module:
python -m sasvi --help
python -m sasvi.cli does the same.
30-second smoke test
Once you have SASVI_BASE_URL set, sasvi doctor runs a full diagnostic sweep and exits non-zero on
any failure:
export SASVI_BASE_URL="https://viya.example.com"
export SASVI_ACCESS_TOKEN="..." # or use SASVI_USERNAME / SASVI_PASSWORD
sasvi doctor
Sample output:
sasvi doctor
┏━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CHECK ┃ STATUS ┃ DETAIL ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ env-base-url │ PASS │ https://viya.example.com │
│ env-auth │ PASS │ static token │
│ tls │ PASS │ reachable (200) │
│ source │ PASS │ auth: SASVI_ACCESS_TOKEN | base URL from: environment │
│ auth-acquire │ PASS │ token acquired (len=512) │
│ connection │ PASS │ metadata reachable │
│ identity │ PASS │ analyst.user │
│ compat │ PASS │ sdk 0.2.1 │
│ spec-manifest│ PASS │ alerts v9, datahub v11, ... (generator 0.29.1) │
└──────────────┴────────┴──────────────────────────────────────────────────────┘
All checks passed.
sasvi --json doctor produces the same rows as a JSON array under data on stdout, ready for jq
or other tools (see JSON envelope and schemas).
Authenticate
The CLI reuses the SDK's existing auth providers. You have four options: environment variables, an interactive login, a named profile that points at one of them, or any mix of the three.
Environment variables
Set the SASVI_* variables listed below. The CLI auto-loads a .env file from the current
directory if one exists, or the file named by --env-file, which must exist (a mistyped path is a
usage error, exit 2, not a silent fallback to the shell or the login cache). SVIClient.from_env()
reads a .env file only when you pass env_file=
(see from_env() versus the CLI).
The file holds one KEY=value per line. A leading export is accepted, blank lines and lines
starting with # are skipped, a value may be wrapped in single or double quotes, and an unquoted
value ends at the first # (so SASVI_USERNAME=bob # analyst sets bob; quote a value that
contains #).
# .env
SASVI_BASE_URL=https://viya.example.com
SASVI_ACCESS_TOKEN=<pre-acquired token>
Any of these three combinations works:
SASVI_ACCESS_TOKEN. A pre-acquired bearer token.SASVI_USERNAME+SASVI_PASSWORD. SAS Logon password grant.SASVI_CLIENT_ID+SASVI_CLIENT_SECRET. SAS Logon client-credentials grant.
Each variable is taken from the first source that has it:
- The shell environment.
- The
.envfile (--env-file <path>, else./.env). It only fills keys the shell left unset. - The selected profile, which can supply
SASVI_BASE_URL,SASVI_VERIFY_SSLandSASVI_CLIENT_ID. - The
sasvi auth logincache (the profile's own cache when a profile is selected), which can supplySASVI_ACCESS_TOKEN, andSASVI_BASE_URLandSASVI_VERIFY_SSLwhen they are unset.
SVIClient.from_env() uses the same resolver, sasvi.settings.resolve_settings, so a script can
ask for exactly what the CLI does.
SASVI_ALLOW_INSECURE, the switch that allows plaintext http:// to a remote host, is honored only
from the shell environment. In a .env file or a profile it is ignored with a warning.
The cache is used only when SASVI_ACCESS_TOKEN is unset, the cached token has not expired, and
SASVI_BASE_URL (if set) names the host the token was issued for. When it is used, it becomes
SASVI_ACCESS_TOKEN, so it outranks both SASVI_CLIENT_ID + SASVI_CLIENT_SECRET and
SASVI_USERNAME + SASVI_PASSWORD, whether those come from the shell or from .env. Run
sasvi auth logout to make the CLI use them.
Which tenant is this using?
Every command prints one line on stderr saying where it is connecting and where each setting came from:
sasvi: https://viya.example.com | auth: SASVI_USERNAME/SASVI_PASSWORD from .env (/work/.env) | base URL from: .env (/work/.env)
With a profile selected, the base URL source reads profile <name> and the line ends with
profile: <name>.
The line names variables and files, never their values. It adds TLS verification OFF when
verification is disabled, TLS CA bundle: <path> when SASVI_VERIFY_SSL names a CA bundle, and login cache skipped: it was issued for another host than SASVI_BASE_URL or login cache expired when a cache you might expect was not used. --json and
--quiet suppress it, so --json output stays parseable. sasvi auth status reports the same
decision without connecting, and sasvi doctor shows it in its source row.
Check it before a write. A .env in the current directory silently outranks your login cache when
its SASVI_BASE_URL points elsewhere.
Interactive login
For a human-friendly first run, use the PKCE flow:
sasvi auth login --base-url https://viya.example.com
This opens your browser, prompts for the authorization code, and persists the resulting token to
~/.config/sasvi/token.json (chmod 0600). Subsequent commands pick up the cached token
automatically, with no environment variables required.
The command never takes a secret as an argument, so none ends up in shell history or a process list:
- The authorization code is read with a hidden prompt. In a session without a terminal, pass
--code-stdinand write the code, or the callback URL the browser shows, to standard input. - A confidential OAuth client's secret comes from
SASVI_LOGIN_CLIENT_SECRET, or from a hidden prompt with--prompt-client-secret.
The file holds the access token only. The CLI never writes the refresh token, so a cached login
lasts one access-token lifetime (expires_at_iso in sasvi auth status). When it expires, run
sasvi auth login again.
To see what the next command will use:
sasvi auth status
{
"effective_mode": "cached login",
"cached_token": {
"base_url": "https://viya.example.com",
"client_id": "sas.cli",
"expires_at_iso": "2026-06-06T17:30:00+00:00",
"expired": false,
"usable_for_base_url": true,
"verify_ssl": true
},
"env": {
"SASVI_BASE_URL": "https://viya.example.com",
"SASVI_ACCESS_TOKEN": null,
"SASVI_USERNAME": null,
"SASVI_PASSWORD": null,
"SASVI_CLIENT_ID": null,
"SASVI_CLIENT_SECRET": null
},
"env_file": null,
"profile": null,
"profile_auth": null,
"token_file": "/home/me/.config/sasvi/token.json",
"base_url_source": "environment",
"cache_note": null,
"warnings": []
}
(sasvi --json auth status prints this object as the data of the
JSON envelope.)
env lists the credential-related SASVI_* variables, set or not, with secret values replaced by
null or <set>. env_file names the .env that was loaded, profile the selected profile,
token_file the login cache that was consulted, base_url_source where the base URL came from, and
cache_note the reason when a cached login was skipped. warnings lists settings that were ignored
and a profile whose auth does not match the credential in use.
The cached login is used only for the tenant it was made against. SASVI_BASE_URL and the cached
base URL are compared with the scheme and host lowercased, the default port dropped and a trailing
slash stripped, so https://Viya.example.com:443/ matches https://viya.example.com. Another
host, another port or http does not match: usable_for_base_url is false, effective_mode
falls through to the next configured mode, and the token is not sent.
To clear the cache:
sasvi auth logout
sasvi auth logout deletes the token file and prints its path. With --json its data is
{"status": "ok", "removed": true, "path": "..."}. It does not revoke the token at SAS Logon.
Profiles
A profile names a tenant so you can switch between several without editing variables. Profiles live
in ~/.config/sasvi/profiles.toml ($XDG_CONFIG_HOME/sasvi/profiles.toml; SASVI_PROFILES_FILE
names another file):
default = "prod"
[profiles.prod]
base_url = "https://viya.example.com"
verify_ssl = true # or false, or the path of a CA bundle
client_id = "sas.cli"
auth = "login" # login, client-credentials, password or token
[profiles.dev]
base_url = "https://dev.example.com"
verify_ssl = "/etc/ssl/dev-ca.pem"
A profile holds no secret. The file tends to end up in backups and dotfile repositories, so a key
that looks like a credential (password, client_secret, token, api_key and the like) makes
the whole file unreadable with an error that names the key, never the value. Keep secrets in the
environment, in a .env file, or in the login cache. An unknown key and a base URL the client would
refuse are errors too.
Manage the file with sasvi profile:
sasvi profile set dev --base-url https://dev.example.com --verify-ssl /etc/ssl/dev-ca.pem
sasvi profile set dev --auth login # changes only the fields you pass
sasvi profile set dev --unset verify_ssl
sasvi profile list
sasvi profile show dev
sasvi profile use dev # the default for every command
sasvi profile use --clear
sasvi profile delete dev # also removes dev's cached login
The CLI writes the file 0600 in a 0700 directory and refuses to write through a symbolic link.
One profile is selected per command: --profile NAME, else SASVI_PROFILE from the shell, else the
default that sasvi profile use set. A profile sits below the shell environment and the .env
file, so an exported SASVI_BASE_URL still wins over the profile's base_url; the connection line
says which one was used.
sasvi --profile dev auth login logs in to the profile's tenant with its client_id, and caches the
token in token-dev.json next to the default token.json. Each profile's login is separate, and
each is still used only for the origin it was issued for.
auth records the credential the profile expects. It does not change which credential is chosen.
When the credential in use differs, every command prints a warning on stderr and sasvi auth status
lists it under warnings.
Reusing the cached login token programmatically
A script or notebook asks from_env() for the same sources the CLI reads:
from sasvi import SVIClient
client = SVIClient.from_env(env_file=".env", use_login_cache=True)
client = SVIClient.from_env(profile="dev", use_login_cache=True) # the profile's tenant and login
from_env() never writes to os.environ. To select a profile the way the CLI does (SASVI_PROFILE,
then the default), pass profile=sasvi.profiles.active_profile_name(). To see the result and the
source of every setting without building a client, call sasvi.settings.resolve_settings() with the
same arguments.
Programs that read SASVI_* variables themselves (for example the svi-mcp / svi-admin-mcp
servers) can still copy the cached login into the environment:
from sasvi import SVIClient
from sasvi.cli import maybe_inject_cached_token
maybe_inject_cached_token() # sets SASVI_ACCESS_TOKEN (+ SASVI_BASE_URL / SASVI_VERIFY_SSL if unset)
client = SVIClient.from_env()
The call is a no-op (returns False) when SASVI_ACCESS_TOKEN is already set
or the cache is missing/expired, so it composes safely with explicit
environment configuration. It makes the same decision as use_login_cache=True.
When you build the client with an explicit base URL instead of SASVI_BASE_URL,
pass the same URL to the hook. The token is injected only when that URL is the
host the login was made for:
maybe_inject_cached_token(base_url="https://viya.example.com")
client = SVIClient.from_env(base_url="https://viya.example.com")
The login-time TLS trust decision travels with the cache: if you logged in
with a CA bundle in SASVI_VERIFY_SSL, or with --no-verify-ssl (for example
against a dev tenant with a self-signed certificate), the injected
SASVI_VERIFY_SSL carries that into
SVIClient.from_env(), so a spawned process such as an MCP server needs no
manual env config. A preset SASVI_VERIFY_SSL always wins, and the setting is
only injected when the effective SASVI_BASE_URL matches the tenant the login
was made against, so a relaxed trust decision never applies to a different
host.
maybe_inject_cached_token() injects once. It copies the token into the environment, and the
client built from it keeps that token until the process ends. That suits a short command. A
process that outlives one access token, such as an MCP server, passes cached_token_provider()
as auth= instead:
import os
from sasvi import SVIClient
from sasvi.cli import cached_token_provider
base_url = os.environ["SASVI_BASE_URL"]
client = SVIClient(base_url=base_url, auth=cached_token_provider(base_url=base_url))
The provider holds the token it read and reads the cache file again when that token has expired
or the tenant answered 401. Run sasvi auth login in another terminal and the server picks up the
new token on its next request, with no restart. When the file holds no unexpired token, the
request fails with AuthConfigurationError("cached login expired; run sasvi auth login"). The
provider is thread-safe, and it hands a token only to the origin the login was made against:
base_url when given, else SASVI_BASE_URL; with neither, cached_token_provider() raises
AuthConfigurationError. It does not apply the cached verify_ssl decision; pass verify_ssl= to
the client yourself.
cached_token_provider() and maybe_inject_cached_token() read the default token.json. For a
profile's login, pass its file as the first argument: token_path_for("dev"), from
sasvi.cli.token_store.
Output modes and exit codes
Every command supports the same global flags:
| Flag | Effect |
|---|---|
--version, -V | Print the installed sasvi SDK version and exit. |
--json | Emit the JSON envelope on stdout; errors become the error envelope on stderr. |
--quiet, -q | Suppress status lines; print only the primary result. |
--verbose, -v | Print the SDK's log on stderr, one line per HTTP request and response. |
--debug | Print Python tracebacks on any error (separate from --verbose). |
--env-file <path> | Load environment variables from a specific .env file. |
--profile <name> | Use a named profile. |
--json, --quiet, --verbose and --debug work before or after the subcommand, so
sasvi refs list --json and sasvi --json refs list are the same. The short forms -q and -v, and
--env-file, go before the subcommand. Nothing after a bare -- is read as a flag.
JSON envelope and schemas
With --json, every command prints exactly one JSON document on stdout:
{"schema": "sasvi.refs.list/1", "data": [{"name": "risk_level", "label": "Risk level"}]}
schema names the command (its path after sasvi, joined with dots) and the version of its output
contract. data is the result: a list for the list commands, an object for the rest. Read the
result as .data:
sasvi --json refs list | jq -r '.data[].name'
The JSON examples elsewhere in this guide show the data part only.
The version after the slash goes up when the output of that command changes in a way that can break
a consumer: a field removed or renamed, a type changed or narrowed, a required field made optional.
A new field does not change it, so ignore fields you do not know. Check the schema value before you
read data, and fail loudly on a version you were not written for.
Each version has a JSON Schema (draft 2020-12) in the installed package, under
sasvi/cli/schemas/json/, named <schema>.v<n>.schema.json (for example
sasvi.refs.list.v1.schema.json). Find the directory with:
python -c "import sasvi.cli.schemas as s; print(s.SCHEMA_DIR)"
Where a command prints an SDK record's to_dict(), its schema leaves that object open and the
record's API reference documents its fields. Objects the CLI builds
itself (status documents, auth status, doctor rows, profiles) are described field by field. In
Python, sasvi.cli.schemas.models.envelope_adapter("refs list").validate_json(text) validates a
document with pydantic.
--quiet is not covered by this contract: it prints bare values or bare JSON with no envelope.
--quiet prints one tab-separated line per record. A missing value is an empty cell. 0 and
False are printed as they are.
--verbose writes to stderr only, so --json output on stdout still parses. Each request line
carries the method, the path, the service and the attempt number, and each response line the
status and the duration. The query string, the headers and the bodies are left out, so no token
or password reaches the terminal. Set SASVI_LOG_HTTP_RESPONSE_BODY=true to add response bodies,
which the SDK prints with credential fields redacted.
The CLI honors color conventions:
NO_COLOR=1(https://no-color.org) disables ANSI color in all output.SASVI_COLOR=always|auto|never(case-insensitive) overrides the auto-detect behavior.alwaysforces ANSI even when stdout is not a TTY;neverdisables color regardless of context.
Token cache location:
- The CLI persists the cached token at
$XDG_CONFIG_HOME/sasvi/token.json(default~/.config/sasvi/token.json) with0600permissions; the parent directory is created with0700. - Set
SASVI_TOKEN_FILE=/absolute/path.jsonto point the cache somewhere else (useful for shared CI runners, multi-tenant test fixtures, or cases where$XDG_CONFIG_HOMEis not writable).
Exit codes are stable so you can branch on them in CI. The HTTP status decides the code, whichever service answered:
| Code | Meaning |
|---|---|
| 0 | Success. |
| 1 | Operation failed: validation, partial import, HTTP 400, 422 or 5xx, any other SDK error. |
| 2 | Bad invocation, bad configuration or no usable credential: a SASVI_* value the SDK rejects (SASVI_VERIFY_SSL=maybe, an http:// base URL without the opt-in), missing auth, HTTP 401, missing flag, unconfirmed mutation. |
| 3 | Cannot reach the configured base URL or SAS Logon (NetworkError, TLSError, AuthServiceUnavailableError: the token endpoint answered 408, 429 or 5xx, so the credential was never rejected). |
| 4 | Not found: HTTP 404, or a named resource the command looked up and missed. |
| 5 | Forbidden: HTTP 403. The credential is valid and lacks the permission. |
| 6 | Conflict: HTTP 409 or 412. The resource changed, is locked, or is in the wrong state. |
| 70 | Unexpected internal error. Re-run with --debug for the traceback. |
| 130 | You answered "n" to a confirmation prompt, pressed Ctrl-C, or the input ended at a prompt. stderr says Aborted. and nothing was sent. |
| 141 | stdout was closed before the output was written, as in sasvi --json refs list | head -1. |
A 401 prints the sasvi auth login hint. The SDK's NotFoundError and ConflictError subclasses
exit 4 and 6 even when they carry no status, for example DocumentNotFoundError and
WorkflowStateError.
Under --json the error document on stderr carries the same facts, so a caller that captured
stderr does not need the process status:
{"schema": "sasvi.error/1", "error": {"message": "Alerts get_alerts failed with HTTP 403: Forbidden", "hint": "...", "status": 403, "exit_code": 5}}
status is null when no HTTP response is behind the failure. hint is left out when there is
none.
Diagnostics
sasvi doctor
Run nine independent checks and exit non-zero on any FAIL: eight fixed checks plus a source
row, which appears whenever a client could be built and names where the auth and base URL came
from. The check list is short on purpose and stable.
The tls check sends one unauthenticated HEAD to the base URL. It goes through the same client
construction as every other command, so SASVI_VERIFY_SSL, SASVI_TIMEOUT and every other transport
setting apply to it exactly as they apply to the SDK. It is not retried, so a certificate failure
is reported at once as TLS error: ....
sasvi whoami
Call the Viya identities endpoint and print the current user payload:
sasvi whoami
{
"id": "analyst.user",
"name": "Analyst User",
"providerId": "ldap"
}
Exits 4 if the tenant does not expose /identities/users/@currentUser and 2 if it rejects the
credential, which makes it a useful probe in deployment-specific scripts.
sasvi version
Print the installed sasvi SDK version, the SAS Viya cadences it was built against, the service
API majors it was generated from, and the Python version. Under --json the envelope's data is
{"version": "0.2.1", "compatibility": {...}}, with the same fields as sasvi.compatibility(). It
makes no network call. The top-level sasvi --version flag prints only the version.
sasvi raw
Make authenticated HTTP requests to any Viya endpoint while reusing the client's auth, retry, and
TLS settings. sasvi raw ships two subcommands:
# Convenience GET
sasvi raw get /identities/users/@currentUser
# Full curl-style request (any method, body, headers, query)
sasvi raw request /identities/users/@currentUser
sasvi raw request -X POST /datahub/v1/documents/alerts \
-d '{"label": "demo alert"}' \
-H Content-Type=application/json
sasvi raw request -X DELETE /svi-datahub/referenceLists/by-name/legacy_status
sasvi raw request /svi-alert/queues --query limit=5 --query sort_by=name
sasvi raw request -i /SASLogon/oauth/clients/me # include response headers
Flag reference:
| Flag | Purpose |
|---|---|
-X / --method | HTTP method (default GET). |
-d / --data | Request body. JSON is auto-parsed; prefix @ to read a file. |
-H / --header | Extra request header key=value (repeatable). |
--query | Query parameter key=value (repeatable). No short flag. |
-i / --include | Include status code and headers in the printed output. |
--unsafe-show-secrets | Print headers and error bodies without redacting credentials. |
--query has no short form on purpose. -q is the global --quiet, so a -q limit=5 would
silence the output rather than add a query parameter.
Successful bodies are printed in full. Error responses (HTTP 400 and above) are cut to 4000
characters in the error message; pass --verbose or --debug for the full body.
Credentials in an error body and in the -i headers print as <redacted>, by the same rules the
SDK's HTTP logs use. --unsafe-show-secrets prints them as received, so the output can then hold
a token or a session cookie. sasvi.redaction.redact_text() and redact_headers()
apply the same redaction to output you print yourself.
Configuration export and import
sasvi config works with two ZIP formats:
- Full transport archive (the default): SAS's own export of the complete solution, from the
svi-transportservice. It holds entities, relationships, workflows, reference lists, pages, SAND and alert configuration, groups and memberships, and translations. - SDK bundle (
--format bundle): the SDK's SAND + alerts bundle. Use it for targeted changes that you want to dry-run with--validate-only.
inspect and import read the ZIP to decide which format it is, so you never pass --format to
them.
Export
sasvi config export vi-full.zip
# Exported full configuration (1284 entries, VI 11.1) → vi-full.zip (16085938 bytes).
sasvi config export vi-bundle.zip --format bundle # SAND + alerts
sasvi config export vi-sand.zip --format bundle --include sand # one component
A large solution exports in tens of seconds. The full export waits up to 300 seconds by default;
raise it with --timeout. Use --overwrite to replace an existing file. The command refuses to
start when the file exists, so you don't wait for an export that can't be saved. The archive
holds your whole solution configuration, so the file is created readable by your user only
(0600), and the command won't write through a symbolic link.
Inspect
Read a ZIP locally, with no network calls, to confirm what's inside before importing:
sasvi --json config inspect vi-full.zip
{
"path": "vi-full.zip",
"format": "sas-transport",
"byte_size": 16085938,
"sha256": "<64 hex characters>",
"system_version": "11.1",
"entry_count": 1284,
"services": {
"SASVisualInvestigator": 65,
"documentGeneratorAdapter": 37,
"resources": 40,
"svi-alert": 13,
"svi-datahub": 1037,
"svi-indexer": 3,
"svi-sand": 85,
"svi-scorecard": 1,
"svi-vsd-service": 2
},
"folders": {}
}
folders (left empty above for space) counts files per folder, for example
"svi-datahub/documents": 136 or "svi-datahub/workflow/workflows": 21.
For an SDK bundle, inspect prints "format": "bundle", the components, and the bundle manifest.
Import
sasvi config import changes the target tenant, so it asks for confirmation. In interactive shells
it prompts; in CI, --json or --quiet contexts it refuses to run unless you pass --yes.
A full transport archive imports in one step with no dry run. SAS documents the transport merge as an upsert: objects whose natural key matches are replaced, new ones are added, and nothing is deleted. Export the target tenant first if you may need to roll back.
sasvi config export target-backup.zip # against the target, before importing
sasvi config import vi-full.zip --yes
sasvi config import vi-full.zip --yes --timeout 1800
sasvi config import vi-full.zip --yes --no-wait # print the job URL if the server queues it
If the server queues the import as a job, the command polls it until it finishes or --timeout
(default 600 seconds) runs out. --validate-only and --wait-for-refresh are rejected for
transport archives.
SDK bundles keep their dry run:
sasvi config import vi-bundle.zip --validate-only # safe: no writes
sasvi config import vi-bundle.zip --yes --wait-for-refresh
sasvi config import vi-bundle.zip --yes --timeout 1800 # per component request (default 600)
--validate-only validates the SAND configuration without persisting it. The alerts API has no
validation mode, so the alerts component is skipped (the JSON result marks it "skipped": true).
A failed import exits 1. The command prints the partial result and lists every provider or component message, so the JSON output stays parseable:
{
"success": false,
"components": [
{ "component": "sand", "success": true, "skipped": false, "message": null },
{ "component": "alerts", "success": false, "skipped": false, "message": "..." }
]
}
Indexing
sasvi index drives search indexing through the documented endpoints: the Data Hub
asyncJobs route to start a SEARCH_INDEX_LOADER job and the SAND index lifecycle. Job
status and cancel have no published API, so no command polls a job; watch the Visual
Investigator admin Jobs page. The Python equivalent is client.admin.indexing.
The documented re-index recipe is four steps: three commands and one manual wait.
sasvi index ensure --unsearchable --yes # 1. fresh, hidden index generation per type
sasvi index start --full --yes # 2. load into it
# 3. wait for the job on the admin Jobs page
sasvi index make-searchable --yes # 4. swap it in, drop the old generation
Start
sasvi index start --full
sasvi index start --since 2026-09-01T00:00:00+00:00 --entity person
sasvi index start --entity person --relationship person_to_vehicle:person --no-associated
sasvi --json index start --full --dry-run
| Flag | Purpose |
|---|---|
--full | Re-index every type. |
--since <iso> | Index changes since this timestamp. Needs a UTC offset (a naive timestamp would be read in the server's zone). |
--entity <name> | Entity type to index; repeatable. |
--relationship <NAME:FROM_ENTITY> | Relationship to index; repeatable. |
--transaction <name> | Transaction type to index; repeatable. |
--no-associated | Index only the listed objects, not the objects associated with them. |
--name <text> | Job name shown on the admin Jobs page. |
--dry-run | Print the request without building a client. |
--yes, -y | Skip the confirmation prompt. Required in non-interactive runs. |
Without --dry-run the command confirms before submitting. --dry-run prints the request
without building a client:
{
"status": "dry-run",
"plan": {"mode": "full", "since": null, "entities": [], "relationships": [], ...},
"payload": {"version": 1, "name": "Data indexing", "parameters": {"type": "SEARCH_INDEX_LOADER"}}
}
Indices
sasvi index ensure # idempotent: every type has a searchable index
sasvi index ensure --unsearchable # new hidden generation (confirms; --yes in scripts)
sasvi index make-searchable # confirms; deletes older generations
sasvi index refresh-config --status-only # report only; no prompt
sasvi index refresh-config --yes # real refresh (confirms without --yes)
sasvi index name person # exit 4 when the type has no index
sasvi index version
┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ TYPE ┃ INDEX ┃ VERSION ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ person │ sand__person__1788696278909 │ 1 │
└────────┴─────────────────────────────┴─────────┘
Reference lists
List, show, items
sasvi refs list
sasvi refs show alert_category
sasvi refs items alert_category
refs list --limit <n> caps the number of lists returned (default 100) and sizes the page it
fetches by it. sasvi --json refs list emits an array of records, each with the SDK's to_dict()
snapshot. Feed it into jq for filtering:
sasvi --json refs list | jq -r '.data[] | select(.archived == false) | .name'
Create
Create a normal reference list from explicit values:
sasvi refs create risk_level \
--from-values Low --from-values Medium --from-values High \
--label "Risk level" \
--yes
…or from a CSV file. A 1-column CSV is treated as a list of values; a 2-column CSV is treated as
code,label pairs. The CLI auto-detects:
# risk_level.csv (1 column)
value
Low
Medium
High
# risk_level.csv (2 columns)
code,label
LOW,Low
MED,Medium
HIGH,High
sasvi refs create risk_level --from-csv risk_level.csv --yes
| Flag | Purpose |
|---|---|
--from-values <v> | Item display values; repeatable. Codes come from --code-strategy. |
--from-csv <path> | CSV file: one column of values, or code,label pairs. |
--label <text> | Reference-list label. |
--description <text> | Reference-list description. |
--code-strategy <s> | upper_slug (default), label, lower or numeric. For --from-values. |
--max-code-length <n> | Longest code the strategy may generate (default 50). |
--alphabetical-sort / --no-alphabetical-sort | Whether the tenant shows the items sorted by label (default on). |
--archived | Create the list archived (hidden). |
--dry-run | Print the planned payload and send nothing. |
--yes, -y | Skip the confirmation prompt. Required in non-interactive runs. |
The delimiter is detected (comma, semicolon or tab, so a localized Excel export works), a
label,code header is honoured, and a row with an empty code or label cell is refused with its
row number before anything is sent. --code-strategy (for --from-values) accepts label,
lower, numeric or upper_slug; --by on refs validate accepts code or label; and
--include on config export --format bundle accepts sand or alerts. Any other value is a
usage error (exit 2) before a prompt or a request.
--dry-run resolves the input and prints the planned payload without calling the API, which makes
it a useful CI safety net:
sasvi refs create risk_level --from-csv risk_level.csv --dry-run
Validate
Check that values exist in a configured reference list. Useful right before an ingest:
sasvi refs validate risk_level HIGH LOW UNKNOWN
Exit codes: 0 if every value is present, 1 if any are missing or duplicated. JSON output details which values failed:
{
"valid": false,
"checked_count": 3,
"missing": [{ "value": "UNKNOWN" }],
"duplicates": []
}
Pass --ignore-case for case-insensitive matching, or --by label to match on labels instead of
codes.
Export
Save a single reference list as a JSON file for diffing or migration scripts:
sasvi refs export risk_level risk_level.json
An existing file is refused; pass --overwrite to replace it, as with sasvi config export.
--from-csv refuses a file above 16 MiB before reading it.
GeoJSON shapes
sasvi shape manages the stored shapes that geo searches filter by. upload reads a GeoJSON file
and stores each area in it as one shape.
sasvi shape upload districts.geojson --group Districts --dry-run
sasvi shape upload districts.geojson --group Districts --yes
sasvi shape list --group Districts
The file can be a FeatureCollection, a single Feature, or a bare geometry.
- A FeatureCollection gives one shape per feature. Each shape takes its name from the feature's
nameproperty. Pick another property with--name-property. - A single Feature or a bare geometry gives one shape. Its name is
--name, then the feature's naming property, then the file name without its extension.
| Flag | Purpose |
|---|---|
--name | Shape name. Only for a file that holds one area. |
--name-property | Feature property that holds each shape's name (default name). |
--group | Group label stored on every shape. |
--solution | Solution scope. The server uses default when you leave it out. |
--dry-run | Print the shapes the file would create and send nothing. |
--yes, -y | Skip the confirmation prompt. Required in non-interactive runs. |
The whole file is checked before the first request. A feature with no geometry, an unknown geometry type, no name, or a name another feature already uses stops the upload with exit code 2, and the message lists every such feature. Files above 64 MiB are refused.
The upload is not atomic. Shapes are created one at a time, and a shape the server rejects does not
stop the rest. The command then exits 1 and names each shape that failed. sasvi --json shape upload
prints created and failed lists on stdout so a script can retry only the failures.
The upload always creates. Running it twice stores every area twice, so check with
sasvi shape list first, or delete the earlier shapes with client.admin.shapes.delete.
shape list filters with --group <text> and --name-contains <text> (substring matches) and
caps the result with --limit <n> (default 100).
Entity metadata
Discover the real field and relationship names instead of guessing:
sasvi entity list
sasvi entity list --include-unauthorized # also the types the current user cannot read
sasvi entity show supplier
sasvi entity fields supplier
sasvi entity fields supplier --writable-only
entity list sends one request in every output mode; --json prints the local part of each
record (identity, storage flags, conditions and fields). entity show adds the child entity
types and the configured location and time events, which come from the search configuration;
when that lookup fails the record is still printed with search_metadata_error set and a
warning on stderr.
sasvi entity fields supplier prints a table with each field's data type, required flag, writable
flag, and (if relevant) the reference list that constrains it:
NAME LABEL TYPE REQUIRED WRITABLE REF LIST
party_name_stnd Standard Name string True True
alert_category Alert Category string False True alert_category
Relationships
Find which relationship types connect two entity types:
sasvi relationship between supplier organisation
QUALIFIED NAME LABEL FROM TO
sup_to_org Member of supplier organisation
Search
Run a simple full-text search restricted to one entity type:
sasvi search supplier "MJ Consulting"
sasvi search supplier "MJ Consulting" --limit 50
By default the query is treated as literal text. Lucene metacharacters like *, ?, :, and
AND / OR are escaped, so untrusted input is safe to pass through. For Lucene power-user syntax
(wildcards, field-scoped searches, boolean operators), pass --lucene:
sasvi search supplier "*" --lucene
sasvi search supplier "party_name:Acme*" --lucene
To expand the tenant's synonym list or match sound-alike terms, ask SAND for a search mode.
--mode takes standard, synonym or phonetic and can be repeated; --synonyms and
--phonetic are shorthands for --mode synonym and --mode phonetic. They work on both the
plain and the --lucene path, and standard is always sent first:
sasvi search person zqxbeta --synonyms
sasvi search person smyth --mode phonetic
sasvi search person "bio:smyth" --lucene --phonetic
These modes find extra matches only when the tenant is set up for them; see Using synonyms in search.
JSON output gives you each hit's document_id, entity_type_name, label, and fields:
sasvi --json search supplier "MJ Consulting" | jq '.data[] | {document_id, label}'
For more advanced queries (filters, geo, facets, graph patterns), reach for the Python SDK. The CLI deliberately keeps the search command simple.
Documents
Fetch a single document by entity type and id:
sasvi doc get supplier 600E1234-...
The compact snapshot includes document_type, document_id, label, and a flat fields map,
plus the lock state from a second request: is_checked_out_by_me and checkout_status
(checked_out_by_me or not_checked_out_by_me). When that lock probe fails (for example the
lock service answers 403), the document is still printed, checkout_status is unknown, and
checkout_error carries the reason; human mode also prints a warning on stderr.
Pipe --json output into jq to drill in:
sasvi --json doc get supplier 600E1234-... | jq '.data.fields.party_name_stnd'
A missing document exits 4, distinct from a network failure (exit 3) and from an SDK error (exit 1), so a CI script can react precisely.
Release a stale lock
A write that was killed part way can leave its document locked. sasvi doc unlock clears a lock
that your own user holds:
sasvi doc unlock supplier 600E1234-... --yes
# released: true
The command first asks the service whether you hold the lock. When you do not, it sends no
release and prints released: false. --force skips that check and sends the release anyway.
Without --yes the command prompts, and in --json, --quiet or a non-interactive shell it
exits 2 before it sends anything. A missing document exits 4, and a release the service refuses
exits with the code for its HTTP status. See
stale locks for what is known about lock ownership and
expiry.
Workflows
sasvi workflow sits on client.workflows. Definitions and processes are read with list and
get; start, suspend, resume and cancel change process state. suspend and cancel
confirm before running; pass --yes in scripts.
sasvi workflow definitions list
sasvi workflow definitions get investigation_workflow --by-name
sasvi workflow definitions revisions investigation_workflow
sasvi workflow processes list --view all
sasvi workflow processes get proc-1
sasvi workflow processes start --name investigation_workflow --document investigation/doc-1 --var priority=high
sasvi workflow processes suspend proc-1 proc-2 --yes
sasvi workflow processes resume proc-1 proc-2
sasvi workflow processes cancel proc-1 --yes
sasvi workflow tasks list
sasvi workflow tasks claim task-1 task-2 --assignee alice
sasvi workflow tasks release task-1 --admin
┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ WORKFLOW ┃ ENTITY ┃ DOCUMENT ┃ STATE ┃ SUSPENDED ┃ STARTED AT ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ proc-1 │ investigation_workflow │ investigation │ doc-1 │ RUNNING │ False │ 2026-09-12T10:00:00Z │
└────────┴────────────────────────┴───────────────┴──────────┴─────────┴───────────┴──────────────────────┘
| Command | Flags |
|---|---|
definitions list | --limit <n> page size; --all fetches every page. |
definitions get <id> | --by-name looks the argument up as a name instead of an id. |
definitions revisions <name> | --limit <n>. |
processes list | --view active|all|completed (default active); --limit <n>. |
processes start | --name or --id (one of them), --document TYPE/ID, --var KEY=VALUE repeatable. |
processes suspend|cancel <ids> | --yes, -y. |
tasks list | --limit <n>; --include-unworkable adds tasks the current user cannot work on. |
tasks claim <ids> | --assignee <user id>. |
tasks release <ids> | --admin releases any claimant (confirms; --yes). |
--all means "fetch every page" wherever it appears in the CLI.
Several ids go through the batch endpoints (suspend_many, resume_many, cancel_many,
claim_many, release_many), which the SDK splits into chunks of 100. A missing definition,
process or task exits 4; a malformed --document (must be TYPE/ID) or --var (must be
KEY=VALUE) exits 2 before any request.
sasvi workflow tasks has three subcommands: list, claim and release. There is no
sasvi workflow tasks complete. Completing a task means choosing an action and usually writing
document fields with it, which is more than a flag can express, so it stays in Python on the
bound WorkflowTask. The claim-then-complete recipe
shows that half.
Alerts
sasvi alert is read-only and sits on client.alerts. history and versions read the alert
service's own audit trail (alert.audit), which is separate from the Data Hub document trail;
scorecard explains the score; events lists alerting events.
sasvi alert list --queue q-1 --min-score 50
sasvi alert list --status NEW --max-score 90 --assigned-to alice --limit 50
sasvi alert get alert-1
sasvi alert history alert-1 --type CHECKOUT
sasvi alert history alert-1 --types # action types available for this alert
sasvi alert versions alert-1
sasvi alert scorecard alert-1 --labels
sasvi alert events --alert alert-1 --deep
sasvi alert events --entity person/p-1
┏━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ SK ┃ TYPE ┃ ACTION ┃ USER ┃ CREATED AT ┃ VERSION ┃
┡━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ 11 │ CHECKOUT │ Checked out │ videmo │ 2026-09-12T10:00:00Z │ 1 │
└────┴──────────┴─────────────┴────────┴──────────────────────┴─────────┘
| Command | Flags |
|---|---|
list | --queue <id>, --status <id>, --min-score <n>, --max-score <n>, --assigned-to <user id>, --limit <n>. |
history <id> | --type <action type>, --limit <n>, --all (every page), --types (list the action types instead). |
scorecard <id> | --labels adds scenario-fired-event labels. |
events | --alert <id>, --entity TYPE/ID, --deep (scenario-fired events), --limit <n>. |
Dispositions and other alert mutations stay in the Python SDK (alert.disposition(...)).
Raw HTTP
For diagnostics, support workflows, and custom extension endpoints, drop down to a raw GET:
sasvi raw get /identities/users/@currentUser
sasvi raw get /svi-datahub/admin/cascadingData/investigation_result
The path is resolved against SASVI_BASE_URL and the request carries the same authentication as
every other command. JSON responses get pretty-printed (or emitted as machine JSON under --json);
non-JSON responses print their body verbatim. sasvi raw sends your credential to the
SASVI_BASE_URL origin only. A URL on another host, a URL with a user name or password in it, and
a scheme other than http or https are refused with exit 2 before anything is sent. On an HTTP status of 400 or above the command
includes the response body in the error and exits with the code the table above gives that status.
Redirects are not followed: a 3xx exits 1 and names the Location target, so a login redirect or a
moved service root never looks like an empty success.
CI/CD recipes
Environment smoke test
Use sasvi doctor as a one-line health gate before the rest of a pipeline runs:
sasvi --json doctor > doctor.json || exit $?
Exit code 3 (network), 2 (bad config), or 1 (other failures) all surface distinctly, so the failing stage tells you whether to alert ops or rotate a token.
Reference list validation
Block a CSV-driven ingest if any code is unknown:
mapfile -t CODES < <(awk -F, 'NR > 1 {print $1}' incoming.csv)
sasvi --json refs validate risk_level "${CODES[@]}"
The non-zero exit on missing codes fails the pipeline; the JSON output (captured as an artifact) shows exactly which codes were missing.
Safe config migration
Promote a full solution, keeping a backup of the target:
SASVI_BASE_URL=https://target.viya.example.com sasvi config export target-backup.zip
sasvi config inspect vi-full.zip
SASVI_BASE_URL=https://target.viya.example.com sasvi config import vi-full.zip --yes
For a SAND-only change, the bundle format adds a dry run before the real import:
sasvi config import bundle.zip --validate-only
sasvi config import bundle.zip --yes --wait-for-refresh
--validate-only exercises the same SAND validation the server applies during a real import, so it
catches schema mismatches without persisting anything. --yes is mandatory in CI because the
prompt isn't shown when stdin isn't a TTY.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Authentication is not configured. (exit 2) | No auth env vars and no cached login. | Run sasvi auth login or set SASVI_BASE_URL + one auth combination. |
Cannot reach the configured Viya base URL (exit 3) | DNS, firewall, TLS. | Confirm SASVI_BASE_URL. For a tenant behind a private CA, set SASVI_VERIFY_SSL=/path/ca.pem (a PEM bundle file or a certificate directory); it replaces the default trust store for sasvi only. Only for a throwaway dev tenant, set SASVI_VERIFY_SSL=false. |
SAS Logon token endpoint is unavailable (HTTP 503) (exit 3) | SAS Logon is restarting or overloaded. | Retry once it is back. The credential was not rejected; do not rotate it. |
Environment variable SASVI_VERIFY_SSL must be a boolean ... (exit 2) | A SASVI_* value the SDK rejects. For SASVI_VERIFY_SSL: neither a boolean word nor an existing CA bundle path. | sasvi auth status shows where each variable came from; fix the value or the path. |
... failed with HTTP 401 (exit 2) | The token expired or was revoked. | Run sasvi auth login, or refresh SASVI_ACCESS_TOKEN. |
... failed with HTTP 403 (exit 5) | The identity lacks the permission. | Check the identity with sasvi whoami and ask an administrator. |
Reference list 'X' not found. (exit 4) | Typo or wrong tenant. | List candidates with sasvi refs list. |
This import will mutate the tenant configuration. (exit 2) | Mutating command in non-interactive context. | Re-run with --yes. |
--json and --quiet cannot be combined. (exit 2) | Conflicting global flags. | Pick one. |
| Unexpected traceback (exit 70) | Bug or genuinely novel error. | Re-run with --verbose and capture the HTTP trace before reporting. |
Every error in --json mode is a single-line sasvi.error/1 document on stderr whose error
object holds message, status, and (where useful) hint and exit_code, so log shippers can
parse it directly.
Where the CLI stops
The CLI is intentionally narrow. Reach for the Python SDK when you need:
- Document and alert mutations (create, update, comment, disposition).
- Workspace and insight workflows, and workflow-task completion (claim and release are CLI commands).
- The full search DSL (filters, facets, geo, graph patterns, path queries).
- Bulk operations that need transactional logic across many records.
There is no sasvi jobs group: indexing job status and cancel have no published endpoint, and the
CLI only wraps documented SDK methods.
See the How-to guides for the Python equivalents. Every CLI command sits on top of a documented SDK method.
Next references
- Authentication providers used by
sasvi auth login: Authentication guide. - The same env vars that drive
SVIClient.from_env(): Configuration guide.