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

# Automation, output and errors

> Use JSON Lines, stable errors and explicit inputs in agents and scripts.

CLI scripts should inspect returned state, preserve secrets and recover without repeating unintended writes.

## Agents and scripts

* Add `--json` for machine-readable output. Stdout is JSON Lines: the final line is the result or `{"error":{"code","message"}}`. Progress goes to stderr.
* Commands waiting for a person (`init`, `login`, a workspace switch that starts login, and OAuth connections) emit a `waiting_for_human` line **before** waiting. Read the stream and relay the link immediately. Other commands emit one result line.
* A zero exit code is not always a successful service check. Inspect `ok`/`health` for connection tests, `query.error` for monitor previews and `queryError` for monitor charts. Keep configuration, data arrival, evaluation and delivery as separate checks.
* Never include credentials or private telemetry in logs, source control or an agent's final report. Commands that create ingest/deployment keys print the key once; capture it directly into approved secret storage.

| Exit code | Meaning |
| - | - |
| `0` | Command completed; inspect the returned result |
| `1` | Operation failed; read the stable error code |
| `2` | Invalid arguments or required input missing |
| `3` | SSH host key needs independent verification before trust |
| `4` | Authentication or a different login scope is required |

Before retrying a write after a lost response, read back its state. For example, list monitors before retrying `create`; update a matching monitor rather than making a duplicate.

## Environment

| Variable | Purpose |
| - | - |
| `STRUCT_API_URL` | Struct API origin; defaults to `https://api.struct.ai` |
| `STRUCT_TOKEN` | Overrides saved logins, used in memory only. Remove it from the environment when you intend to use a saved login |
| `STRUCT_PROMPT_DISABLED` | Refuses interactive prompts and implicit browser approval. Explicit auth commands such as `init`, `login` and OAuth connect still print approval links and wait |

The CLI does not load repository `.env` files. Supply variables through your shell or secret manager. Without a terminal, missing input is an error rather than a prompt. Use explicit arguments and documented stdin/environment inputs. See [Authentication](https://docs.struct.ai/reference/cli-auth.md) for profile storage and recovery.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.