# CLI

Manage Rentalot records from the terminal with the [Rentalot CLI](https://github.com/Rentalot-ai/rentalot-cli), a Go client that wraps the [Rentalot v1 API](/docs/api-reference). The CLI is useful for authenticated reads today. Its registered write commands are not yet a canonical write path for the current property and contact schemas.

## Install

**Go install** (recommended):

```bash
go install github.com/Rentalot-ai/rentalot-cli/cmd/rentalot@latest
```

**From source**:

```bash
git clone https://github.com/Rentalot-ai/rentalot-cli.git
cd rentalot-cli
make build    # Binary at bin/rentalot
```

## Setup

Choose the server origin before creating the API key or configuring the CLI. Use the same origin for account sign-in, Settings/key issuance, CLI requests, and web CRM readback:

- Paid: `https://rentalot.ai`
- Free Trial: `https://rentalot.ai` by default while the account trial is active. An optional local development server can use `http://localhost:3000` with the same gate and account deadline.

Create and verify a Rentalot account in the web app at the chosen origin. Then create an API key in **Settings > API Keys** at `<RENTALOT_BASE_URL>/dash/settings?tab=api-keys` and save the raw key immediately. It is shown only once. For a local Free Trial, use `http://localhost:3000/dash/settings?tab=api-keys` while `RENTALOT_BASE_URL=http://localhost:3000`.

The CLI stores `api_key` and `base_url` in `~/.config/rentalot/config.yaml`:

```bash
# Choose one server origin and use it everywhere below.
export RENTALOT_BASE_URL=https://rentalot.ai
# For a Free Trial, use instead:
# export RENTALOT_BASE_URL=http://localhost:3000
rentalot config set api_key ra_your_key
rentalot config set base_url "$RENTALOT_BASE_URL"
```

The client base URL is the **server origin**, not `/api/v1`. The CLI appends the API route itself. Keep `base_url` and `RENTALOT_BASE_URL` set to the same origin.

Environment variables override the config file:

```bash
export RENTALOT_API_KEY=ra_your_key
export RENTALOT_BASE_URL=https://rentalot.ai
# For a Free Trial, use instead:
# export RENTALOT_BASE_URL=http://localhost:3000
```

Do not mix a trial key with a different server origin. Use the production origin by default, or use the optional local origin consistently for sign-in, key issuance, CLI requests, and CRM readback.

Check the resolved, redacted configuration with:

```bash
rentalot config show
```

## Current support boundary

| CLI operation | Current status |
|---|---|
| `properties list`, `properties get` | Supported authenticated reads. Account ownership and API tier rules still apply. |
| `contacts list`, `contacts get` | Supported authenticated reads. |
| `properties create`, `properties update` | **Contract drift.** Current commands send legacy `name`, `type`, and `rent` fields and omit required canonical fields such as `monthlyRent`, `bedrooms`, and `bathrooms`. Do not use these commands for the first write job. |
| `contacts create`, `contacts update` | **Contract drift.** Current commands send `type`, while the canonical API field is `role`. A contact create also needs a name and an email or phone. Do not use these commands for the first write job. |
| Delete commands | Registered and routed to the API. The API semantics are soft-delete, not permanent erasure. Confirm the response and tier before using them. |
| Showings, conversations, and workflows | Commands exist, but current request and response parity is partial. Check the matching endpoint in the [API reference](/docs/api-reference) and test against a private record before automating writes. |

The CLI follows the API key's authority: Free Trial is bounded private, image-free property/contact CRUD while the account trial is active; Starter is read-only; Pro and Scale are paid full-authority tiers subject to endpoint limits. The CLI does not create accounts or API keys.

## Optional first CRM job

For a reliable first job, use **MCP or direct canonical API requests for writes**, then use the CLI to read the same records. This keeps the CLI useful without hiding its current property/contact payload drift.

1. Sign up, verify the email, and sign in through the web app at the same origin configured in `base_url` or `RENTALOT_BASE_URL`.
2. Open **Settings > API Keys** at `<RENTALOT_BASE_URL>/dash/settings?tab=api-keys` and create an API key. For a local Free Trial, this is `http://localhost:3000/dash/settings?tab=api-keys`.
3. Configure the CLI with the correct origin and the matching account key.
4. Create a private property with the canonical API fields `address`, `monthlyRent`, `bedrooms`, `bathrooms`, and `isPublic: false` through MCP or the direct API. Create a contact with an email or phone. Use the production origin by default, or an optional local development origin for an active Free Trial.
5. Save the returned IDs, then read them with the CLI:

```bash
rentalot properties get "$PROPERTY_ID"
rentalot contacts get "$CONTACT_ID"
```

6. Update only canonical safe fields through MCP or direct API, and use the CLI again to confirm the same IDs. For example, the direct API can update a property title or monthly rent and a contact's channel preference; do not translate those updates into the CLI's legacy `name`, `rent`, or `type` flags.
8. Open `<RENTALOT_BASE_URL>/dash/properties/$PROPERTY_ID` and `<RENTALOT_BASE_URL>/dash/contacts/$CONTACT_ID` while signed in to the same account at the same configured origin. For a local Free Trial, these are `http://localhost:3000/dash/properties/$PROPERTY_ID` and `http://localhost:3000/dash/contacts/$CONTACT_ID`. Confirm the dashboard shows the same records.
9. Revoke the key at `<RENTALOT_BASE_URL>/dash/settings?tab=api-keys`. Requests made afterward must return `401 Unauthorized`.

This job does not publish a property, upload images, send messages, or run workflows. A `DELETE` check is separate and means soft-delete in the API.

## Usage

```bash
rentalot --help
rentalot properties --help
rentalot contacts --help
```

Safe read examples:

```bash
rentalot properties list --page 1 --limit 20
rentalot properties get "$PROPERTY_ID"
rentalot contacts list --page 1 --limit 20
rentalot contacts get "$CONTACT_ID"
```

Every request uses the configured Bearer key and remains scoped to that key's Rentalot account. A missing, invalid, expired, or revoked key returns `401`. Starter write attempts are rejected by the API, and trial requests outside the released trial gate or trial resource surface are rejected. A `422` usually means the request shape is not canonical, while `429` means a tier or trial quota was consumed or exceeded.

## Go Library

The CLI can also be used as a Go library for building custom integrations:

```go
import "github.com/Rentalot-ai/rentalot-cli/pkg/rentalotcli"
```

The library uses the same `api_key`/`base_url` config fields and `RENTALOT_API_KEY`/`RENTALOT_BASE_URL` environment overrides.

## Shell Completion

```bash
# Bash
source <(rentalot completion bash)

# Zsh
source <(rentalot completion zsh)

# Fish
rentalot completion fish > ~/.config/fish/completions/rentalot.fish
```

## Agent Skill

Install the bundled [Agent Skill](https://agentskills.io) so your coding agent knows the current commands and options:

```bash
npx skills add Rentalot-ai/rentalot-cli
```

See the [GitHub README](https://github.com/Rentalot-ai/rentalot-cli) for manual installation details. The application acceptance checks for this setup use canonical route-shaped API requests with free mocks; they do not execute an installed CLI binary or claim transport parity before the sibling CLI sync work lands.
