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

# CLI

> Install and use the Tightknit CLI to manage your community from the terminal.

<Note>
  The Tightknit CLI is currently in **alpha**. Commands and options may change between releases.
  Install with the `@alpha` tag: `npm i -g @tightknitai/tightknit@alpha`
</Note>

The Tightknit CLI gives you command-line access to the [Tightknit Admin API](/api-reference/introduction). To let AI agents like Claude help you manage your community, connect them to the hosted [MCP server](/integrations/mcp) instead.

## Installation

<Tabs>
  <Tab title="npm (global)">
    ```bash theme={null}
    npm install -g @tightknitai/tightknit@alpha
    ```
  </Tab>

  <Tab title="npx (no install)">
    ```bash theme={null}
    npx @tightknitai/tightknit@alpha --help
    ```
  </Tab>
</Tabs>

Verify the installation:

```bash theme={null}
tightknit --version
```

## Authentication

The CLI resolves your API key in the following order:

| Priority    | Source                                         | Best for                    |
| ----------- | ---------------------------------------------- | --------------------------- |
| 1 (highest) | `--api-key <key>` flag                         | One-off commands, scripting |
| 2           | `TIGHTKNIT_API_KEY` environment variable       | CI/CD pipelines             |
| 3 (lowest)  | Stored config (`tightknit config set api-key`) | Interactive CLI usage       |

<Steps>
  <Step title="Create an API key">
    Go to **[Integrations > API Keys](https://studio.tightknit.ai/-/integrations/api-keys)** in the Studio.
    Click **Create API key**, give it a descriptive name, and select the permissions your commands need.

    Copy the key (starts with `sk_`) — it is only shown once.
  </Step>

  <Step title="Configure the CLI">
    ```bash theme={null}
    tightknit config set api-key sk_your_key_here
    ```

    The key is stored at `~/.config/tightknit/config.json`.

    Alternatively, set the environment variable:

    ```bash theme={null}
    export TIGHTKNIT_API_KEY=sk_your_key_here
    ```
  </Step>

  <Step title="Verify">
    ```bash theme={null}
    tightknit feeds list
    ```

    If your key is valid, you will see a list of your community's feeds.
  </Step>
</Steps>

## Commands

Every command supports `--json` for machine-readable output and `--help` for usage details.

### Events

| Command                                 | Description                 |
| --------------------------------------- | --------------------------- |
| `tightknit events list`                 | List calendar events        |
| `tightknit events get <id>`             | Get a calendar event by ID  |
| `tightknit events create`               | Create a new calendar event |
| `tightknit events delete <id>`          | Delete a calendar event     |
| `tightknit events update-attendee <id>` | Update an event attendee    |

```bash Example: list upcoming events as JSON theme={null}
tightknit events list --time-filter upcoming --status published --json
```

```bash Example: create an event theme={null}
tightknit events create \
  --title "Community Meetup" \
  --description "Join us for our monthly meetup" \
  --start-date "2025-06-01T18:00:00Z" \
  --end-date "2025-06-01T20:00:00Z" \
  --location "Zoom"
```

### Feeds & Posts

| Command                      | Description          |
| ---------------------------- | -------------------- |
| `tightknit feeds list`       | List feeds           |
| `tightknit feeds get <id>`   | Get a feed by ID     |
| `tightknit feeds posts <id>` | List posts in a feed |
| `tightknit posts get <id>`   | Get a post by ID     |

```bash Example: list newest posts in a feed theme={null}
tightknit feeds posts fd_abc123 --sort newest --per-page 10
```

### Members

| Command                           | Description                   |
| --------------------------------- | ----------------------------- |
| `tightknit members add`           | Add a member (Enterprise)     |
| `tightknit members check <email>` | Check if an email is a member |

```bash Example: add a member theme={null}
tightknit members add --email jane@example.com --full-name "Jane Doe"
```

### Messages

| Command                   | Description          |
| ------------------------- | -------------------- |
| `tightknit messages send` | Send a Slack message |

```bash Example: send a message theme={null}
tightknit messages send --channel C0123456 --text "Hello from the CLI!"
```

### Groups

| Command                            | Description           |
| ---------------------------------- | --------------------- |
| `tightknit groups add-member <id>` | Add a user to a group |

### Awards

| Command                        | Description                 |
| ------------------------------ | --------------------------- |
| `tightknit awards assign <id>` | Assign an award to a member |

```bash Example: assign an award theme={null}
tightknit awards assign awd_abc123 --recipient-email user@example.com
```

### Search

| Command                          | Description                       |
| -------------------------------- | --------------------------------- |
| `tightknit search query <query>` | Search posts, events, and content |

```bash Example: search for posts theme={null}
tightknit search query "onboarding" --type post --per-page 5 --json
```

<Info>Search is currently in Beta.</Info>

### Config

| Command                              | Description               |
| ------------------------------------ | ------------------------- |
| `tightknit config set <key> <value>` | Set a configuration value |
| `tightknit config get <key>`         | Get a configuration value |

Valid config keys: `api-key`, `default-output` (`json` or `table`), `environment` (`production` or `staging`).

## Global Options

| Flag              | Description                                 |
| ----------------- | ------------------------------------------- |
| `--api-key <key>` | API key for this invocation (not persisted) |
| `--json`          | Output as JSON (available on all commands)  |
| `--no-color`      | Disable colored output                      |
| `--verbose`       | Enable verbose output                       |
| `-v, --version`   | Print the CLI version                       |
| `-h, --help`      | Show help for a command                     |

## Output Behavior

By default, the CLI formats output as a human-readable table. Use `--json` on any command for structured JSON, which is useful for scripting and piping:

```bash Piping JSON output theme={null}
tightknit events list --json | jq '.[] | .title'
```

You can change the default output format globally:

```bash theme={null}
tightknit config set default-output json
```

## Exit Codes

The CLI uses differentiated exit codes for scripting and CI/CD integration:

| Code | Meaning                                                            |
| ---- | ------------------------------------------------------------------ |
| `0`  | Success                                                            |
| `1`  | General or unknown error                                           |
| `2`  | Input validation error (invalid arguments, bad email format)       |
| `3`  | Authentication or authorization error (invalid or missing API key) |
| `4`  | Resource not found                                                 |

```bash Example: check exit code in a script theme={null}
tightknit members check user@example.com --json
if [ $? -eq 3 ]; then
  echo "API key is invalid or missing"
fi
```

## CI/CD

Set the `TIGHTKNIT_API_KEY` environment variable in your pipeline. The CLI skips interactive features (like update notifications) when the `CI` environment variable is set.

<CodeGroup>
  ```yaml GitHub Actions theme={null}
  - name: Check membership
    env:
      TIGHTKNIT_API_KEY: ${{ secrets.TIGHTKNIT_API_KEY }}
    run: |
      npx @tightknitai/tightknit@alpha members check user@example.com --json
  ```

  ```bash Shell script theme={null}
  export TIGHTKNIT_API_KEY=sk_your_key_here
  tightknit events list --time-filter upcoming --json > events.json
  ```
</CodeGroup>

## Shell Completions

Generate tab-completion scripts for your shell:

<CodeGroup>
  ```bash Bash theme={null}
  # Add to ~/.bashrc
  eval "$(tightknit completion bash)"
  ```

  ```bash Zsh theme={null}
  # Add to ~/.zshrc
  eval "$(tightknit completion zsh)"
  ```

  ```bash Fish theme={null}
  # Add to fish config
  tightknit completion fish | source
  ```
</CodeGroup>

## API Coverage

All endpoints from the [Tightknit Admin API](/api-reference/introduction) are supported:

| Method | Endpoint                                  | CLI Command              |
| ------ | ----------------------------------------- | ------------------------ |
| GET    | `/admin/v0/calendar_events`               | `events list`            |
| POST   | `/admin/v0/calendar_events`               | `events create`          |
| GET    | `/admin/v0/calendar_events/:id`           | `events get`             |
| DELETE | `/admin/v0/calendar_events/:id`           | `events delete`          |
| PATCH  | `/admin/v0/calendar_events/:id/attendees` | `events update-attendee` |
| POST   | `/admin/v0/awards/:id/assign`             | `awards assign`          |
| GET    | `/admin/v0/feeds`                         | `feeds list`             |
| GET    | `/admin/v0/feeds/:id`                     | `feeds get`              |
| GET    | `/admin/v0/feeds/:id/posts`               | `feeds posts`            |
| GET    | `/admin/v0/posts/:id`                     | `posts get`              |
| POST   | `/admin/v0/members`                       | `members add`            |
| POST   | `/admin/v0/members/check`                 | `members check`          |
| POST   | `/admin/v0/messages`                      | `messages send`          |
| POST   | `/admin/v0/groups/:id/members`            | `groups add-member`      |
| GET    | `/admin/v0/search`                        | `search query`           |


## Related topics

- [Salesforce](/integrations/salesforce.md)
- [Event Registration](/events/event-registration.md)
- [MCP Server](/integrations/mcp.md)
