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

# Installation

> Install the Maito CLI, sign in, and start running Maito commands from your terminal.

Install the CLI once, then sign in.

## Install

```sh theme={null}
npm install -g @getmaito/cli
```

## Sign In

```sh theme={null}
maito login
```

After login, run a command:

```sh theme={null}
maito posts list
```

## Requirements

The CLI requires Node.js `20.19.0` or newer.

## API-Key Auth

API keys are useful for server-side automation against supported customer API endpoints. Create API keys after signing in:

```sh theme={null}
maito login
maito api-keys create --name "ci-import" --expiration 90d --json
```

Then use the key for supported commands:

```sh theme={null}
MAITO_API_KEY=<key> maito newsletter subscribers list --json
maito newsletter issues list --api-key <key> --json
```

You can explicitly store an API key:

```sh theme={null}
maito auth use-api-key --api-key <key>
maito auth clear-api-key
```

API keys are server-side credentials. Do not put them in browser code, public repositories, or client-side environment variables. See [API Authentication](/docs/api-reference/authentication) for API-key guidance.

## Auth Precedence

When a command needs auth, the CLI checks credentials in this order:

1. `--api-key`
2. `MAITO_API_KEY`
3. saved sign-in session
4. stored API key

If an API key is used on an unsupported route, the API returns `AUTH_FORBIDDEN`. Run `maito login` for full user CLI access.

## Update

Update the CLI with:

```sh theme={null}
npm update -g @getmaito/cli
```

The CLI checks npm for a newer version at most once per day. When an update is available, it prints the update command after normal human-readable command output. JSON output is not changed.
