# Get started with the Nylas CLI

Source: https://developer.nylas.com/docs/v3/getting-started/cli/

The [Nylas CLI](https://cli.nylas.com) is an open-source command-line tool that handles the entire Nylas setup -- account creation, app configuration, API key generation, and account connection -- in a single interactive command.

> **Info:** 
> Prefer a web interface? See [Get started with the Dashboard](/docs/v3/getting-started/dashboard/) instead.

## Install the CLI

1. Install using your preferred method:

   ```bash [installCli-Homebrew (macOS/Linux)]
   brew install nylas/nylas-cli/nylas
   ```

   ```bash [installCli-Shell script (macOS/Linux/WSL)]
   curl -fsSL https://cli.nylas.com/install.sh | bash
   ```

   ```powershell [installCli-PowerShell (Windows)]
   irm https://cli.nylas.com/install.ps1 | iex
   ```

2. Verify the installation:

   ```bash
   nylas --version
   ```

## Set up your application

Run the init wizard. It walks you through four steps in under a minute:

1. **Create an account** (or log into an existing one) via Google, Microsoft, or GitHub SSO
2. **Select an application** (or create a new one)
3. **Generate an API key** (named automatically for easy identification in the Dashboard)
4. **Connect an email account** from your synced accounts

```bash
nylas init
```

You can also sign up with a specific SSO provider:

```bash
nylas init --google
```

```bash
nylas init --microsoft
```

If you already have an API key from the [Dashboard](https://dashboard-v3.nylas.com), skip the wizard entirely:

```bash
nylas init --api-key <NYLAS_API_KEY>
```

For EU data residency:

```bash
nylas init --api-key <NYLAS_API_KEY> --region eu
```

> **Info:** 
> **Your credentials stay local.** `nylas init` stores your API key and OAuth tokens in your OS keyring. They never leave your machine.

Once `nylas init` completes, you're ready to make API calls. The CLI displays your grant ID (the connected account identifier) at the end of setup.

## Make your first API call

List your five most recent messages using the CLI:

```bash
nylas email list --limit 5
```

Or call the Nylas API directly with curl. Replace `<NYLAS_GRANT_ID>` and `<NYLAS_API_KEY>` with the values from the setup step.

```bash
curl --compressed --request GET \
  --url "https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>/messages?limit=5" \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json'

```

```json [cliFirstCall-Response (JSON)]

{
  "request_id": "d0c951b9-61db-4daa-ab19-cd44afeeabac",
  "data": [
    {
      "starred": false,
      "unread": true,
      "folders": ["UNREAD", "CATEGORY_PERSONAL", "INBOX"],
      "grant_id": "1",
      "date": 1706811644,
      "attachments": [
        {
          "id": "1",
          "grant_id": "1",
          "filename": "invite.ics",
          "size": 2504,
          "content_type": "text/calendar; charset=\"UTF-8\"; method=REQUEST"
        },
        {
          "id": "2",
          "grant_id": "1",
          "filename": "invite.ics",
          "size": 2504,
          "content_type": "application/ics; name=\"invite.ics\"",
          "is_inline": false,
          "content_disposition": "attachment; filename=\"invite.ics\""
        }
      ],
      "from": [
        {
          "name": "Nylas DevRel",
          "email": "nylasdev@nylas.com"
        }
      ],
      "id": "1",
      "object": "message",
      "snippet": "Send Email with Nylas APIs",
      "subject": "Learn how to Send Email with Nylas APIs",
      "thread_id": "1",
      "to": [
        {
          "name": "Nyla",
          "email": "nyla@nylas.com"
        }
      ],
      "created_at": 1706811644,
      "body": "Learn how to send emails using the Nylas APIs!"
    }
  ],
  "next_cursor": "123"
}


```

## Connect more accounts

Add another email account at any time:

```bash
nylas auth login
```

List all connected accounts:

```bash
nylas auth list
```

Switch between accounts:

```bash
nylas auth switch
```

## Useful commands

Here are some commands to try now that you're set up:

| Command | What it does |
|---|---|
| `nylas email list` | List recent messages |
| `nylas email send --to user@example.com --subject "Hello" --body "Hi"` | Send an email |
| `nylas email search --query "from:boss@work.com"` | Search messages |
| `nylas calendar events list` | List upcoming calendar events |
| `nylas calendar events create --title "Standup" --start "tomorrow 9am" --end "tomorrow 9:30am"` | Create an event |
| `nylas contacts list` | List contacts |
| `nylas webhook list` | List configured webhooks |

The CLI also includes AI-powered features:

| Command | What it does |
|---|---|
| `nylas email smart-compose --prompt "Reply saying I'll be there"` | Draft an email with AI |
| `nylas calendar schedule ai "Coffee with Alex next Tuesday"` | Schedule with natural language |
| `nylas chat` | Open the AI chat interface |

Add `--json` to any command for machine-readable output, or pipe to `jq` for filtering:

```bash
nylas email list --limit 10 --json | jq '.[].subject'
```

See the full [CLI command reference](https://cli.nylas.com/docs/commands) for 100+ commands covering email, calendar, contacts, webhooks, and more.

## What's next

- **[Email quickstart](/docs/v3/getting-started/email/)** -- send your first email with the Nylas API
- **[Calendar quickstart](/docs/v3/getting-started/calendar/)** -- create your first event
- **[Authentication](/docs/v3/auth/)** -- set up OAuth for your users
- **[API reference](/docs/reference/api/)** -- full endpoint documentation