Skip to main content
The CLI resolves credentials and settings from three sources in priority order: environment variables, the credentials file (~/.testsprite/credentials), and built-in defaults. Per-invocation flags override everything else.

Global flags

Global flags override both environment variables and the credentials file for a single invocation. They must appear before the subcommand. Full descriptions are in the Command Reference.
FlagOverridesDefault
--output <json|text>text
--profile <name>TESTSPRITE_PROFILEdefault
--verbosefalse
--debugfalse
--dry-runfalse
--request-timeout <seconds>TESTSPRITE_REQUEST_TIMEOUT_MS120

Credentials file

The CLI stores API keys in ~/.testsprite/credentials, an INI-style file. The directory is created with mode 0700 and the file with mode 0600. Writes are atomic — a partial write never corrupts an existing key.
~/.testsprite/credentials
Sample file:
[default]
api_key = sk-...

[ci]
api_key = sk-...
Run testsprite auth configure to write a profile interactively. Use --from-env in CI to skip the prompt.

Profiles

A profile is a named section in the credentials file. Each profile holds an api_key. You can maintain as many profiles as you like — for example, one for interactive use and one with a separate API key for CI. There’s no separate “select profile” command — you apply a profile to whichever command you run. For a single command, prepend the global --profile flag (here project list is just an example command):
testsprite --profile ci project list
To use a profile for the rest of a shell session, set the environment variable so every command picks it up:
export TESTSPRITE_PROFILE=ci
testsprite project list
The active profile defaults to default if neither --profile nor TESTSPRITE_PROFILE is set.

Environment variables

Environment variables override the credentials file but are overridden by their corresponding flag.
VariablePurposeOverridden by
TESTSPRITE_API_KEYAPI key to use— (highest precedence for the key)
TESTSPRITE_PROFILEActive profile name--profile
TESTSPRITE_REQUEST_TIMEOUT_MSPer-request timeout in milliseconds--request-timeout (seconds)
In CI, set TESTSPRITE_API_KEY in your secrets store and pass --from-env to testsprite init or testsprite auth configure. The CLI never logs the key value.

Resolution precedence

The CLI resolves each setting through a fixed chain. First match wins. Profile selection:
  1. --profile flag
  2. TESTSPRITE_PROFILE environment variable
  3. Literal "default"
API key:
  1. TESTSPRITE_API_KEY environment variable
  2. api_key in the active profile from ~/.testsprite/credentials

The JSON output contract

--output json is the stable, parseable contract every command supports, and exit codes are stable independently of output mode — so agents and CI scripts branch on the exit code rather than parsing stderr. See Output & Scripting. On error, every command emits a consistent JSON envelope regardless of --output mode; for its shape and the full error-code table see Exit Codes & Errors.

Request timeouts

--request-timeout <seconds> sets the client-side timeout for each individual HTTP request (range 1–600, default 120). Set it via the environment variable as milliseconds: TESTSPRITE_REQUEST_TIMEOUT_MS=30000. This timeout governs single HTTP round-trips only. It does not affect the --timeout ceiling on test run --wait, test wait, or test rerun --wait — those polling loops run until the run reaches a terminal status or the wait timeout expires, independent of per-request timeouts. When a run completes, the JSON output includes a dashboardUrl field and text mode prints a Dashboard: line. This deep-links directly into the Web Portal run view for that test.
{
  "runId": "run_5c1d...",
  "status": "failed",
  "dashboardUrl": "https://www.testsprite.com/dashboard/tests/proj_8f0f6/test/test_3a9f21c7"
}
The dashboardUrl field is absent under --dry-run.

Where to Go Next

Authentication

Configure API keys, profiles, and non-interactive CI auth

Command Reference

Every command, flag, and output shape

Exit Codes & Errors

Every exit code and error code in one table

CI/CD Integration

Use the CLI in GitHub Actions and other pipelines