# Exit codes

> The exit codes Shoplazza CLI returns — API, validation, authentication, network, and internal errors — and how to branch on them inside a shell script.

Shoplazza CLI uses structured exit codes to indicate the type of failure.

| Code | Type | Description |
|------|------|-------------|
| `0` | Success | Command completed successfully |
| `1` | API error | The Shoplazza API returned an error (4xx other than 403, or 5xx) |
| `2` | Validation error | Invalid input, unknown command or flag, missing required flags, malformed data, or no profile configured yet |
| `3` | Authentication error | Missing or expired credentials, insufficient scopes (HTTP 403) |
| `4` | Network error | Connection failure, timeout, DNS resolution error |
| `5` | Internal error | Unexpected CLI error (bug) |
| `130` | Canceled | You declined a confirmation or aborted a prompt with Ctrl-C at an interactive terminal; nothing is printed |

## Usage in scripts

```shell
shoplazza products list
case $? in
  0) echo "Success" ;;
  1) echo "API error — check response body" ;;
  2) echo "Validation error — check your flags" ;;
  3) echo "Auth error — run: shoplazza auth login" ;;
  4) echo "Network error — check your connection" ;;
  5) echo "Internal error — please report a bug" ;;
esac
```
