Skip to main content
Every testsprite command returns a stable exit code. Agents and CI pipelines branch on the exit code; the JSON error envelope supplies the machine-readable detail. Exit codes and error codes will not change within a major version.

Exit codes

CodeMeaning
0Success
1Generic failure — non-passed run status, or unhandled server error (INTERNAL)
2Not yet implemented
3Auth error — key missing, unparseable, revoked, or forbidden scope
4Not found — ID doesn’t exist or belongs to another tenant
5Validation error — bad field/enum, payload too large, missing required flag, or bad --output value
6Conflict or precondition — snapshot in flight, run already in flight, idempotency body mismatch, a newer codeVersion was seen, or agent install blocked (target exists and differs, no --force)
7Timeout or unsupported — polling ceiling reached (resume with testsprite test wait <run-id>), or feature not on current backend
8, 9Reserved (unused)
10Unavailable or transport failure — retriable with backoff
11Rate limited — honor the Retry-After header
12Insufficient credits — non-retriable; top up in the dashboard
130SIGINT cancellation (Ctrl-C)
143SIGTERM cancellation
The --help and --version flags always exit 0. Flag-parse errors exit 5.

Error codes

Every error response carries a machine-readable code string alongside the HTTP status and CLI exit code.
CodeHTTPExitWhenRetriable
AUTH_REQUIRED4013No auth header presentNo
AUTH_INVALID4013Key unparseable or revokedNo
AUTH_FORBIDDEN4033Missing scope or cross-tenant accessNo — text mode also prints required: / granted: scopes
NOT_FOUND4044ID doesn’t exist or belongs to another tenantNo
VALIDATION_ERROR4005Bad field, enum value, or cursorNo
PAYLOAD_TOO_LARGE4135Body over the size capNo
CONFLICT4096Snapshot in flight or run already in flightYes — once, 1 s delay
PRECONDITION_FAILED4126The test changed since you fetched it (newer codeVersion)No — re-fetch then retry
IDEMPOTENCY_BODY_MISMATCH4096Same idempotency key reused with a different bodyNo
RATE_LIMITED4291160 triggers/min/key exceededYes — honor Retry-After, cap 3 retries
INSUFFICIENT_CREDITS40212Credit balance insufficientNo
UNSUPPORTED5017Feature not on current backend versionNo
INTERNAL5001Unhandled server errorYes — once
UNAVAILABLE50310A downstream service is temporarily unavailableYes — exponential backoff, cap 4 retries

Error output

Every command emits the same JSON error envelope when something goes wrong, regardless of --output mode:
{
  "error": {
    "code": "AUTH_REQUIRED",
    "message": "Authentication is required.",
    "nextAction": "Run `testsprite auth configure`, or set TESTSPRITE_API_KEY in the environment.",
    "requestId": "req_2026_05_05_abc123",
    "details": {}
  }
}
In text mode, the CLI prints message and nextAction as human-readable lines. For AUTH_FORBIDDEN, text mode also prints the required scope list and the granted scope list so you can immediately identify what’s missing.

Test and run status

Test status

The test-level normalized status reflects the outcome of the most recent completed run. The CLI exposes 9 values.
StatusMeaningTerminal?
draftExists, but no executable code yetNo
readyHas code, never runNo
queuedRun accepted; cloud engine not startedNo
runningRun in flight (pre-exec, exec, or post-exec analysis)No
passedLatest completed run passedYes
failedLatest completed run failed (includes infra crash)Yes
blockedRun rejected before a real verdictYes
cancelledCancelled before verdictYes
unknownBackend cannot derive a statusn/a

Run status

An individual run has 6 possible statuses. Terminal statuses are the four that produce a final verdict.
StatusTerminal?
queuedNo
runningNo
passedYes
failedYes
blockedYes
cancelledYes

Step status

Each step in a run is: passed, failed, or null (not yet executed or not applicable).

Run source

The source field on a run identifies which surface triggered it.
ValueMeaning
cliAny CLI-triggered run, including test rerun
portalWeb Portal
mcpMCP Server (IDE integration)
scheduleAutomated schedule
github_actionGitHub Actions integration

Retrying safely

Retriable codes — use an idempotency key so retries are deduplicated server-side:
  • Exit 6 (CONFLICT) — retry once after 1 second. For PRECONDITION_FAILED, re-fetch codeVersion first, then retry.
  • Exit 10 (UNAVAILABLE) — retry with exponential backoff (capped at 4 retries automatically by the CLI).
  • Exit 11 (RATE_LIMITED) — wait for the Retry-After duration before retrying (cap 3 retries automatically).
Non-retriable codes — fix the root cause before retrying:
  • Exit 4 (NOT_FOUND) — verify the ID.
  • Exit 5 (VALIDATION_ERROR, PAYLOAD_TOO_LARGE) — fix the input.
  • Exit 12 (INSUFFICIENT_CREDITS) — top up your balance.
Reuse --idempotency-key on write commands when retrying manually so the backend dedupes server-side.

Safe retries

How idempotency keys make manual retries safe

Where to Go Next

Command Reference

Every command and flag in one place

Configuration

Environment variables, profiles, and the JSON output contract

CI/CD Integration

Gate pipelines on exit codes

Running Tests

Triggering runs and handling results