# Official LaserData CLI

`laser` is the official LaserData CLI. It follows the [Console](https://laserdata.cloud): an organization, its workspaces, their deployments, and the data inside each deployment, from streams and topics to agents, agent sessions, memory, queries, consumer filters, key-value namespaces, and forks. The static binary supports macOS arm64 and Linux x86\_64 or arm64.

It runs two ways, with the same configuration and credentials:

* `laser <command>` runs one command and exits. Output is a table on a terminal and JSON when piped. A failure exits with a non-zero code and writes the error to stderr, so commands compose in scripts, CI, and agents.
* `laser tui` opens the Console in the terminal, with the workspace sidebar, pages with tabs, a command palette, and mouse and keyboard control. Every view runs a command you could type. See [TUI Dashboard](/cli/tui).

The CLI signs in with an [API key](/security/api-keys), rather than a user session. Give that key the [roles and permissions](/organization/roles-permissions) its work needs. Use [laser-sdk](/laser-sdk) from Rust, Python, or TypeScript when an application publishes, consumes, or runs agents.

## When Agents Should Use laser

Use `laser` when an agent needs a command, JSON output, and a process exit status. It suits workspace and deployment lists, health checks, reading streams, sessions, and memory, reviewed configuration changes, and repeatable CI tasks.

Use the [REST API](/api) for many calls, custom retry or concurrency behavior, or direct model function calls. Use [laser-sdk](/laser-sdk) for publishing, consuming, semantic memory, and agent runtime features.

For automation, set `LD_API_KEY` for the key and `LD_WORKSPACE` and `LD_DEPLOYMENT` for the scope, select `--output json` or `-o json`, and inspect the exit code. No saved context or organization id is needed. `--api-key` also accepts the key for one invocation. A different key clears the saved context's inherited scope for that invocation. Avoid interactive commands such as `laser tui`. [Sign In](#sign-in) shows the runner setup.

Start with read-only commands. Obtain explicit approval before creating, changing, or deleting resources. The API contract is available at [`laserdata.com/openapi.json`](https://laserdata.com/openapi.json).

## Install

```bash
curl -fsSL https://cli.laserdata.cloud/install.sh | sh
```

The installer detects the operating system and architecture. It downloads the matching archive from the [release repository](https://github.com/laserdata/laser-cli-releases) and makes sure that its SHA-256 checksum matches. It installs `laser` in `$HOME/.local/bin`, or `$LD_PREFIX` when set. Run it again to upgrade.

### Installer Flags

Pass installer flags with `sh -s --`:

| Flag | Effect |
| --- | --- |
| `--to <dir>` | Install directory, `$HOME/.local/bin` by default. Alternative to `LD_PREFIX`. |
| `--version <vX.Y.Z>` | Pin a release tag, `latest` by default. Alternative to `LD_VERSION`. |
| `--with-cc-skills` | Also install or update the Claude Code skill pack from `cli.laserdata.cloud/claude.sh`. See [Claude Code Skills](/cli/claude-skills). |
| `--help` | Show usage. |

### Environment Variables

| Variable | Effect |
| --- | --- |
| `LD_VERSION` | Pin a release tag. |
| `LD_PREFIX` | Override the install directory. |

### Common Recipes

```bash
# Pin version 0.2.0.
curl -fsSL https://cli.laserdata.cloud/install.sh | sh -s -- --version v0.2.0

# System-wide install directory.
curl -fsSL https://cli.laserdata.cloud/install.sh | sh -s -- --to /usr/local/bin

# Install the Claude Code skills in the same step.
curl -fsSL https://cli.laserdata.cloud/install.sh | sh -s -- --with-cc-skills
```

Running the installer again replaces the binary in place, and the skill pack too when `--with-cc-skills` is passed, so it fits CI and dotfiles.

### Upgrade and Verify

```bash
laser update
laser version
```

`laser update` downloads the latest release and replaces the binary in one step. `laser version` prints the installed version.

## Sign In

```bash
laser auth login
laser auth status
```

`auth login` prompts for the API key with masked input and validates it. A key belongs to one organization, and login binds it. The CLI discovers the organization from the authenticated key, so no organization id is required. An explicit `--org` still has to match the key's access. A key scoped to one workspace also selects that workspace. The key is stored in the OS keyring, which is Keychain on macOS and Secret Service on Linux. Only the key's name is written to disk.

`auth status` shows the signed-in context, organization, key, workspace, and deployment scope. `laser org key whoami` shows the key's role and permissions.

`laser tui` needs no login first. Without a key it opens on a welcome screen that takes the key and signs in the same way. See [First run](/cli/tui#first-run).

Login saves the key in a context, `default` unless you name one with `--context`, and every signed-in command reads the active context. A runner needs no context: with none active, `LD_API_KEY` or `--api-key` signs in for that one command against the LaserData API:

```bash
export LD_API_KEY=ld_pat_...
export LD_WORKSPACE=main
export LD_DEPLOYMENT=orders
laser stream list -o json
```

When you do sign in on a machine without an OS keyring, for example Linux without a Secret Service provider, set `LD_ALLOW_INLINE_KEY=1` before login to store the key in the config file instead. Prefer a keyring where one exists. With a saved context, `LD_API_KEY` or `--api-key` replaces the context's key for one invocation.

`laser auth logout` clears the key of the active context, or of every context with `--all`. `laser auth purge` deletes every context, key, and config file.

## Scope

Every command acts in one organization and one workspace. Data commands act on one deployment, or on All deployments where the Console offers a workspace-wide list.

| Scope | Resolved from, in order |
| --- | --- |
| Organization | `--org`, `LD_ORG`, the context, authenticated key discovery |
| Workspace | `--workspace` or `-w` (id or name), `LD_WORKSPACE`, the context, the only workspace of the organization |
| Deployment | `--deployment` or `-d` (id or name), `LD_DEPLOYMENT`, the context, the only deployment of the workspace |

`workspace use` and `deployment use` save the scope in the context, so later commands use it. The flags and variables override it for one invocation.

```bash
laser workspace use main
laser deployment use orders
laser stream list
laser topic list -d payments
laser deployment use --all
```

`deployment use --all` clears the deployment scope, and workspace lists span every deployment again. Switching the workspace clears a deployment scope outside it. The CLI never asks for an environment. It reads the environment of each deployment from the organization structure.

## Workspace Lists Span Zones

A workspace's deployments can run in several LaserData zones. Workspace-wide lists such as `deployment list`, `stream list`, `topic list`, `agent list`, `session list`, `filter list`, `projection list`, and `fork list` read every zone that serves the workspace and merge the rows, the way the Console does. They read the metadata each zone keeps in sync, so they need no connection to the deployments themselves. With a deployment in scope they narrow to it, and `--live` reads the deployment directly instead.

When a zone does not answer, the list still prints and stderr reports the gap:

```text
1 of 2 zones did not answer. The list and the total are incomplete.
```

The JSON output carries `items`, `page`, `results`, `total_results`, and `total_pages`, plus a `zones` array with one entry per zone and its `status`: `answered`, `failed`, `unsupported`, or `forbidden`. `total_results` is `null` while any zone is missing.

## Reaching Deployment Data

The CLI refuses HTTP redirects on authenticated requests so the API key cannot be forwarded to a redirect target.

Live data commands reach the deployment through the LaserData data access proxy of its zone, authenticated with your API key. They cover streams, topics, consumer groups, messages, queries, consumer filters, key-value namespaces, sessions, memory, graphs, and the rest of the deployment's data. [Data access](/api/deployments#update-data-access) is on by default, and LaserData adds the [access rule](/networking/access-rules#data-access-rule) it needs.

When data access is off, or the proxy refuses, the CLI connects straight to the deployment's endpoint with the deployment's credentials: the root login when the key also holds `deployment:manage`, otherwise the `ld-admin` login, which has data rights and no user or role management. That path needs an [access rule](/networking/access-rules) for your IP address.

| Flag | Effect |
| --- | --- |
| `--direct` | Skip the proxy and connect straight to the deployment |
| `--username`, `--password` | Sign in to the deployment as this user, which also connects directly |

Each API key has a request rate limit at each zone. The CLI waits and resends a request that a zone refused for that reason. Turn data access on or off with `laser deployment settings data-access on` or `off`.

## Contexts

A context holds an API key reference, an organization, a workspace, and a deployment scope. Use contexts to switch between organizations or keys without signing in again:

```bash
laser context create prod --activate
laser context list
laser context use prod
laser context current
laser context show prod
laser context rename prod prod-eu
laser context delete prod-eu
```

`ctx` is an alias for `context`, and `context switch` is an alias for `context use`. Select a context for one command with `--context NAME` or `LD_CONTEXT=NAME`.

## Output Formats

Choose a format with `-o` or `--output`:

| Format | Default for | Notes |
| --- | --- | --- |
| `table` | Terminal | Aligned table. Colored unless `NO_COLOR` is set or `--no-color` is passed. |
| `json` | Pipe | Machine-readable, with the API's field names. |
| `yaml` | - | YAML. |
| `name` | - | IDs and names only. Useful in `xargs` pipelines. |

JSON keeps the API's field names, so a workspace appears as `workspace_id` and an organization as `tenant_id` there. Text that comes from a deployment or the API is cleaned of terminal control characters before it is printed.

List commands take `--page` and `--results`. A page holds 25 rows by default and at most 100.

## Global Flags

| Flag | Env | Purpose |
| --- | --- | --- |
| `--org <id>` | `LD_ORG` | Organization for this invocation. |
| `-w, --workspace <id or name>` | `LD_WORKSPACE` | Workspace for this invocation. |
| `-d, --deployment <id or name>` | `LD_DEPLOYMENT` | Deployment for this invocation. |
| `--context <name>` | `LD_CONTEXT` | Use a named context for this invocation. |
| `--api-key <key>` | `LD_API_KEY` | Replace the context's API key for this invocation. |
| `-o, --output <format>` | - | `table`, `json`, `yaml`, or `name`. |
| `--no-color` | `NO_COLOR` | Disable colored output. |
| `-q, --quiet` | - | Suppress non-essential output. |
| `--debug` | - | Enable debug logging to stderr. |
| `--silent` | - | Print nothing on success. Errors still reach stderr and the exit code is kept. |
| `--config <path>` | - | Use an alternate config file. |
| `--yes` | - | Skip confirmation prompts for destructive commands. |
| `--idempotency-key <key>` | `LD_IDEMPOTENCY_KEY` | Send this key with creates and updates. See [Retries](#retries). |
| `--generate <shell>` | - | Print a completion script for `bash`, `zsh`, `fish`, `powershell`, or `elvish` and exit. |

Without `--yes`, a destructive command asks you to type the resource's name, id, or email. Deleting a protected workspace, environment, or deployment also needs the code that the delete request emails, passed with `--code`.

## Exit Codes

| Code | Meaning |
| --- | --- |
| `0` | Success |
| `1` | Invalid input, configuration, or scope |
| `2` | The API refused the request, or the command line did not parse |
| `3` | Network or file error |
| `4` | A remote operation failed, was refused, or did not finish in time |
| `70` | Internal error, such as a reply the CLI could not read |
| `130` | Interrupted |

### Retries

Reads retry transient failures. Creates and updates with `--idempotency-key` also retry because the server returns the first answer to a repeated key and body for 10 minutes. The CLI resends requests refused by the API key rate limit, including writes. Other writes do not retry timeouts or server errors. Check the resource before you run a failed write again.

## Local State

State uses XDG directories on Linux and the platform equivalents on macOS:

| Path | Content |
| --- | --- |
| `$XDG_CONFIG_HOME/laser/config.toml` | Named contexts with their organization, workspace, and deployment scope. Mode `0600`. API keys live in the OS keyring, and only their names are stored here. |
| `$XDG_STATE_HOME/laser/active` | The name of the active context. |
| `$XDG_DATA_HOME/laser/logs/laser-YYYY-MM-DD.log` | Daily debug log. Written for every invocation, including `--silent` runs and dashboard sessions. |

Set file log verbosity with `LD_LOG_FILE` and stderr verbosity with `LD_LOG`. Both accept `tracing` directives, such as `LD_LOG_FILE=trace`.

## What the CLI Cannot Do

Some actions need a signed-in browser session rather than an API key. Use the [Console](https://laserdata.cloud) for Allow my IP, adding a card, linking a marketplace purchase, creating or deleting an organization, and account settings. To admit your address from the CLI, add it with `laser deployment connect access-rule add`.

## Quick Start

```bash
curl -fsSL https://cli.laserdata.cloud/install.sh | sh
laser auth login
laser workspace use main
laser deployment list
laser deployment use orders
laser stream list
laser session list --status active
laser tui
```

<a id="whats-next" />

## Related pages

- [Command Reference](/cli/commands)
- [TUI Dashboard](/cli/tui)
- [Claude Code Skills](/cli/claude-skills)
- [API Keys](/security/api-keys)

Source: https://docs.laserdata.com/cli
