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

# Exit codes

> Complete reference for landbase-cli exit codes — what each code means and when it is returned.

# Exit codes

landbase-cli exits with a standard code on every invocation. Scripts and CI pipelines can branch on these codes to handle errors appropriately.

***

## Code table

| Code | Name                     | When it is returned                                                                                                                                                                           |
| ---- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `0`  | Success                  | The command completed successfully.                                                                                                                                                           |
| `1`  | User error               | The command cannot proceed due to invalid input: an unknown flag, a missing required argument, or a failed confirmation (e.g. `datasets delete` without `--yes`). Fix the command and re-run. |
| `2`  | API error                | The Landbase API returned an error, a resource was not found, a publish was required but not run, or a download failed. Check the error JSON on stderr for the `error.code` field.            |
| `3`  | Auth error               | No valid authentication was available (no key, no session), or the key or session was rejected by the API. Run `landbase-cli auth login` to re-authenticate.                                  |
| `4`  | Network or timeout error | The request failed due to a connectivity issue or exceeded the configured timeout. Check your network and retry, or increase `--timeout`.                                                     |

***

## Reading the error JSON

When the exit code is non-zero, landbase-cli writes a structured error to stderr:

```json theme={null}
{
  "error": {
    "code": "AUTH_FAILED",
    "message": "No valid API key or session found. Run: landbase-cli auth login",
    "meta": {}
  }
}
```

The `code` field is a stable machine-readable string. See [error codes reference](/docs/reference/error-codes) for the full list.

***

## Using exit codes in scripts

```bash theme={null}
landbase-cli "find B2B SaaS in NYC" --download=results.jsonl
EXIT=$?

if [ $EXIT -eq 0 ]; then
  echo "Success"
elif [ $EXIT -eq 3 ]; then
  echo "Authentication failed — re-authenticating"
  landbase-cli auth login
elif [ $EXIT -eq 4 ]; then
  echo "Network error — retrying in 10 seconds"
  sleep 10
  landbase-cli "find B2B SaaS in NYC" --download=results.jsonl
else
  echo "Error (code $EXIT) — check stderr"
fi
```

***

## Related

* [error codes reference](/docs/reference/error-codes) — machine-readable error code strings
* [How to automate with scripts](/docs/how-to/automate-with-scripts)
