> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Output, pagination, errors, and automation

> Select stable machine output, fetch paginated results, and handle documented exit codes.

<Tip>
  **Live.** This area is documented as current, user-reliable behavior.
</Tip>

## Goal

Use the CLI safely in scripts without parsing progress messages or table formatting.

## Prerequisites

* An authenticated CLI profile or an explicit CI token

## Workflow

<Steps>
  <Step>
    Choose JSON, YAML, or name-only output for scripts.
  </Step>

  <Step>
    Use `--page` and `--per-page`, or fetch all pages with `--all`.
  </Step>

  <Step>
    Read data from standard output and diagnostics from standard error.
  </Step>

  <Step>
    Branch on the documented process exit code.
  </Step>
</Steps>

## Output formats

* `table` is the human-readable default.
* `json` prints an object containing `data` and optional pagination `meta`.
* `yaml` prints the same `data` and `meta` structure as YAML.
* `name` prints one name, slug, key, domain, or ID per line for resource commands.

```bash theme={null}
stackshift project list --output table
stackshift project list -o json
stackshift project list -o yaml
stackshift project list -o name
```

## Standard output and standard error

Machine-readable results are written to standard output. Progress, debug traces, prompts, build-follow status, and manifest build logs are written to standard error.

`--quiet` suppresses progress and acknowledgement text. Remote command standard error remains standard error.

```bash theme={null}
stackshift project list -o json > projects.json
stackshift deploy api --ref main -o json 2> deploy.log
```

## Pagination

Catalog-backed resource commands accept `--page`, `--per-page`, and `--all`. `--per-page` is limited to 100. `--all` is valid only for GET operations and cannot be combined with an explicit page.

```bash theme={null}
stackshift project list --page 2 --per-page 50 -o json
stackshift project list --all --per-page 100 -o json
```

## Retries and cancellation

* GET, HEAD, and OPTIONS may retry up to three attempts.
* Writes retry only when the request has an idempotency key.
* Retryable statuses are 429, 502, 503, and 504; `Retry-After` is honored.
* Log streams reconnect after retryable network and server failures using the last event ID.
* Ctrl-C cancels requests, streams, archive creation, uploads, and polling.

## Exit codes

* `0`: success.
* `1`: general failure or a remote command exit outside the supported range.
* `2`: CLI usage or flag error.
* `3`: authentication or authorization failure.
* `4`: resource not found.
* `5`: conflict or failed precondition, including stale state.
* `6`: network, timeout, or server failure.
* `7`: partial result, such as a failed diagnostic check.
* `130`: cancelled with Ctrl-C.
* For `stackshift exec`, remote exit codes from 1 through 125 are propagated.

## Secret redaction

Structured output recursively replaces recognized credential, password, private-key, connection-string, secret, and token values with `[redacted]`. Debug logging also redacts sensitive query parameters and never prints authorization headers.

## Expected result

<Check>
  Automation receives parseable output and can distinguish usage, auth, conflict, and network failures.
</Check>

## Common failures

<Warning>
  * `name` output is requested for a response that has no named resources.
  * `--all` is used on a write or a response that is not a paginated array.
  * A script parses table output instead of selecting JSON, YAML, or name output.
  * Progress is redirected from standard output even though it is written to standard error.
</Warning>

## Related guides

<CardGroup cols={2}>
  <Card title="Profiles, defaults, and global options" href="/cli/profiles-and-global-options">
    Use profiles for API and resource defaults, then override them explicitly for one command.
  </Card>

  <Card title="Resource command model and coverage" href="/cli/resource-commands">
    Use consistent list, read, write, pagination, request body, resolution, and confirmation behavior.
  </Card>

  <Card title="Raw customer API command" href="/cli/raw-api">
    Call an existing customer API path with bounded inputs, safe retries, downloads, and path restrictions.
  </Card>
</CardGroup>
