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

# Errors and exit codes - Omni CLI

> How the Omni CLI signals success and failure to scripts, and where error detail goes.

The Omni CLI signals success or failure with two exit codes:

| Exit code | Description                                                                                                                                                       |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `0`       | The command succeeded.                                                                                                                                            |
| `1`       | The command failed: an API error, an [authentication or config-resolution error](/developers/cli/reference/environment-variables), or an unrecognized subcommand. |

You can't branch on the exit code to tell failure types apart. An unrecognized subcommand, such as a typo like `omni document list`, counts as a failure too, even though an invalid invocation can otherwise look like a successful `--help` print. Anything other than `0` means the command didn't complete successfully, which is enough to script against:

```bash theme={null}
if ! omni documents get "$id" --compact > out.json; then
  echo "fetch failed" >&2
  exit 1
fi
```

## Where the error detail goes

On failure, the CLI writes nothing to `stdout`, even a partial response, and writes exactly one error document to `stderr`. See [JSON requests and responses](/developers/cli/reference/json-requests-and-responses#errors) for its exact shape in `--format json` versus `--format human`.
