# Better Stack CLI

The Better Stack CLI, `betterstack`, runs the Better Stack API from your terminal. It covers monitors, incidents, on-call, status pages, telemetry, dashboards, error tracking and the rest of the [Better Stack API](https://betterstack.com/docs/getting-started/integrations/api/).

## Install the CLI

[code-tabs]
```bash
[label macOS and Linux]
curl -fsSL https://betterstack.sh | sh
```
```powershell
[label Windows]
irm https://betterstack.sh/install.ps1 | iex
```
[/code-tabs]

## Sign in

```bash
[label Sign in with your browser]
betterstack signin
```

Once signed in, the CLI can view and change everything your role allows in the web app.

## Run your first command

Start with what's happening right now: your latest incidents.

```bash
[label List incidents]
betterstack incident list
```

Open one to see its cause, who acknowledged it and the failing check's response.

```bash
[label Get an incident]
betterstack incident get 123456789
```

Then see who's on call to handle it.

```bash
[label See who's on call]
betterstack on-call-schedule list
```

To catch the next outage earlier, add a monitor.

```bash
[label Create a monitor]
betterstack monitor create --monitor-type status --url https://example.com
```

Look at your logs next. `tail` follows a source as lines arrive.

```bash
[label Follow logs]
betterstack tail 123456 -f
```

`console` opens a SQL console over the same source.

```bash
[label Query logs with SQL]
betterstack console 123456 --start-time now-24h
```

Every list comes as a table. Add `--json` for scripts.

```bash
[label Print JSON]
betterstack incident list --json
```

Add `--help` to list every command, what it does and how to use it.

```bash
[label Get help]
betterstack --help
betterstack monitor create --help
```

## Connect your AI assistant

`betterstack mcp install` adds the [Better Stack MCP server](/docs/getting-started/integrations/mcp/) to Claude Code, Codex, OpenCode or Cursor.

## Move from the old Terraform providers

`betterstack terraform migrate` moves Terraform state from the `better-uptime` and `logtail` providers to the `betterstack` provider. Follow the steps on the [Terraform page](/docs/getting-started/integrations/terraform/).

## Authentication

Sign in to Better Stack in your browser. The sign-in is saved on your computer, in the keychain on macOS and in a file in your user folder on Linux and Windows. To use an API token instead, set the `BETTERSTACK_API_TOKEN` environment variable to a global API token from [Better Stack → API tokens → Global tokens](https://betterstack.com/settings/global-api-tokens ";_blank")

- `betterstack whoami`: Show who is signed in and the teams they can access.
- `betterstack signout`: Sign out and remove the saved sign-in.
- `betterstack signin`: Sign in to Better Stack.

## Install location and updates

It installs without asking, into `~/.local/bin` on macOS and Linux, `/usr/local/bin` for root, and `%LOCALAPPDATA%\Programs\BetterStack` on Windows. The CLI picks up new commands on its own as soon as they're published, and says once a day when a newer CLI is out. Run `betterstack update` to update it.
