> ## 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.

# How to automate landbase-cli in scripts and CI

> Write shell scripts and CI pipeline steps that use landbase-cli reliably — handling exit codes, passing credentials, and running non-interactively.

# How to automate landbase-cli in scripts and CI

This guide shows you how to use landbase-cli in shell scripts and CI pipelines — handling exit codes, passing credentials without interaction, and building robust automations.

***

## Pass credentials without a browser

In scripts and CI, you cannot open a browser for OAuth. Use an API key instead:

```bash theme={null}
export LANDBASE_API_KEY=lbk_your_api_key_here
landbase-cli auth status
```

Or pass it inline for a single command:

```bash theme={null}
LANDBASE_API_KEY=lbk_your_key landbase-cli datasets list
```

In CI (GitHub Actions, GitLab CI, etc.), store the key as a secret and inject it as an environment variable:

```yaml theme={null}
# GitHub Actions example
- name: Run Landbase pipeline
  env:
    LANDBASE_API_KEY: ${{ secrets.LANDBASE_API_KEY }}
  run: |
    landbase-cli datasets list
```

***

## Handle exit codes

landbase-cli uses standard exit codes for machine-readable error handling:

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

case $EXIT_CODE in
  0) echo "Success" ;;
  1) echo "User error — check your flags" ;;
  2) echo "API error — check the error JSON on stderr" ;;
  3) echo "Auth error — check LANDBASE_API_KEY" ;;
  4) echo "Network/timeout — retry or increase --timeout" ;;
esac
```

See [exit codes reference](/docs/reference/exit-codes) for the full definition of each code.

***

## Capture errors from stderr

Errors are written to stderr as JSON. Capture them separately from stdout:

```bash theme={null}
OUTPUT=$(landbase-cli "find B2B SaaS in NYC" 2>/tmp/lb-error.json)
if [ $? -ne 0 ]; then
  ERROR_CODE=$(cat /tmp/lb-error.json | jq -r .error.code)
  echo "Failed with code: $ERROR_CODE"
fi
```

***

## Retry on transient errors

Network errors (exit code 4) are often transient. Add a retry loop:

```bash theme={null}
MAX_RETRIES=3
for i in $(seq 1 $MAX_RETRIES); do
  landbase-cli "find fintech companies" --download=results.jsonl && break
  EXIT=$?
  if [ $EXIT -eq 4 ] && [ $i -lt $MAX_RETRIES ]; then
    echo "Network error, retrying ($i/$MAX_RETRIES)..."
    sleep $((i * 5))
  else
    exit $EXIT
  fi
done
```

***

## Disable the update check

In CI, suppress the daily version-available nag:

```bash theme={null}
export LANDBASE_NO_UPDATE_CHECK=1
```

Or pass `--no-update-check` to individual commands.

***

## Disable telemetry

To opt out of anonymous usage telemetry:

```bash theme={null}
export LANDBASE_NO_TELEMETRY=1
```

***

## Full CI pipeline example

```yaml theme={null}
# .github/workflows/prospect-refresh.yml
name: Refresh prospect list

on:
  schedule:
    - cron: '0 6 * * 1'  # Every Monday at 6am
  workflow_dispatch:

jobs:
  refresh:
    runs-on: ubuntu-latest
    steps:
      - name: Install landbase-cli
        run: |
          curl -fsSL https://install.landbase.com | bash
          echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Run prospect search
        env:
          LANDBASE_API_KEY: ${{ secrets.LANDBASE_API_KEY }}
          LANDBASE_NO_UPDATE_CHECK: "1"
          LANDBASE_NO_TELEMETRY: "1"
        run: |
          landbase-cli "find B2B SaaS companies in NYC with 50-500 employees" \
            --download=prospects.csv

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: prospects-${{ github.run_id }}
          path: prospects.csv
```

***

## Related

* [exit codes reference](/docs/reference/exit-codes) — full exit code definitions
* [error codes reference](/docs/reference/error-codes) — error code values for branching logic
* [environment variables reference](/docs/reference/env-vars) — all LANDBASE\_\* env vars
