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

# Setup and diagnostics

> Configure a profile, see which host you are hitting, and diagnose a failing setup.

Setup commands are shared by v1 and v2. A profile stores one API key and one host, and `lago v2` commands reuse it: the CLI sends them to `/api/v2` on the same host.

| Command | Description |
| - | - |
| `lago init` | Configure a profile. Validates the key against the API before saving. |
| `lago whoami` | Show the active profile, organization, and resolved API host. |
| `lago doctor` | Check configuration, permissions, network, and authentication. |
| `lago version` | Show the CLI version and the embedded v1 and v2 spec versions. |
| `lago upgrade` | Print the upgrade command for how the binary was installed. |
| `lago profile add\|list\|delete` | Manage named profiles. `list` never prints API keys. |
| `lago completion <shell>` | Print a completion script for `bash`, `zsh`, `fish`, or `powershell`. |

## init

| Flag | Description |
| - | - |
| `--region us\|eu\|self-hosted` | Picks the API host. `self-hosted` requires `--api-url`. |
| `--api-url` | Base URL. A pasted `/api/v1` is normalized, an `app.` host is refused. |
| `--api-key` | The key from **Developers > API keys**. Never persisted before validation succeeds. |
| `--mode live\|test` | Safety declaration. Defaults to live. |
| `--profile` | Name of the profile to write. Default `default`. |

A wrong key writes nothing and exits 3. `--region us --api-url https://api.eu.getlago.com` is a usage error, exit 2, not a silent override.

`whoami` prints `RESOLVED_API_URL` with the `/api/v1` base the profile holds. `lago v2` requests go to the same host under `/api/v2`. Add `--dry-run` to any `lago v2` write to see the exact URL.

## whoami and doctor

`whoami` prints the organization (name, id, default currency, timezone), the profile, the mode, and `RESOLVED_API_URL`. The organization timezone matters in v2: a Rate's `effective_from` cannot be before today in that timezone. `doctor` checks configuration, permissions and authentication, and `--bundle-path` writes a sanitized archive to attach to a support ticket.

## version and upgrade

`SPEC_VERSION` is the v1 OpenAPI version the binary was generated from. `SPEC_V2_VERSION` and `SPEC_V2_SHA256` identify the pinned API v2 document behind `lago v2`. The binary does not self-update: `upgrade` prints the `brew upgrade` or `go install` command for the latest release.

```bash init theme={"dark"}
# Cloud US, test profile
lago init --api-key "$LAGO_API_KEY" --region us --mode test

# Cloud EU, named live profile
lago init --profile eu-prod --api-key "$LAGO_API_KEY" --region eu --mode live

# Self-hosted: base URL, no /api/v1 or /api/v2
lago init --api-key "$LAGO_API_KEY" --region self-hosted \
  --api-url https://lago.example.com --mode test
```

```bash whoami theme={"dark"}
lago whoami
lago whoami --output json --query 'timezone'
```

```bash v2 host check theme={"dark"}
lago v2 products list --limit 1 --dry-run --query 'url'
```

```bash doctor theme={"dark"}
lago doctor
lago doctor --bundle-path ./lago-doctor.tar.gz
```

```bash version theme={"dark"}
lago version
```

```bash profile theme={"dark"}
lago profile list
lago profile delete eu-prod --confirm eu-prod
```

```bash completion theme={"dark"}
lago completion zsh > ~/.zfunc/_lago
lago completion bash > /etc/bash_completion.d/lago
```

```text init theme={"dark"}
Connected to Lago as Example Organization.
Saved us profile "default" to ~/.config/lago/config.toml (mode: test).
```

```text whoami theme={"dark"}
NAME              Example Organization
LAGO_ID           1a901a90-1a90-1a90-1a90-1a901a901a90
DEFAULT_CURRENCY  USD
TIMEZONE          America/New_York
PROFILE           default
MODE              test
RESOLVED_API_URL  https://api.getlago.com/api/v1
```

```text v2 host check theme={"dark"}
"https://api.getlago.com/api/v2/products?limit=1"
```

```text version theme={"dark"}
GO_VERSION       go1.27.4
PLATFORM         darwin/arm64
SPEC_SHA256      16645c2475845ce3072bd0173aa306cb0587b68dec6d24cafb2fb6306a6d1b87
SPEC_V2_SHA256   579b02b81a1a372e2dc80b1892ba347ea8f18cfb828da91028d72d2ce26da530
SPEC_V2_VERSION  2.0.0-beta
SPEC_VERSION     1.57.0
VERSION          1.3.0
```


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