Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@loftyai/lofty-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
lofty-cli
CLI for the Lofty CRM API. Made with api2cli.dev.
Install
npx api2cli install <user>/lofty-cliThis clones the repo, builds the CLI, links it to your PATH, and installs the AgentSkill to your coding agents.
Install AgentSkill only
npx skills add <user>/lofty-cliThe AgentSkill is located at skills/lofty-cli/SKILL.md in the repository. It describes all available resources, commands, and authentication options for use with AI coding agents.
Authentication
lofty-cli supports three authentication modes:
Mode 1: OAuth2 Client Credentials (Recommended)
This mode uses vendor credentials + user's customer key to automatically obtain and cache an access_token.
How to get these credentials: Log in to the Lofty CRM, go to Settings > Integrations > API to find your Client ID, Client Secret, and Customer Key.
Step 1: Configure vendor credentials (environment variables)
export LOFTY_CLIENT_ID="your_client_id"
export LOFTY_CLIENT_SECRET="your_client_secret"These are issued to your vendor/integration by Lofty.
Step 2: Configure user's customer key
Option A — Environment variable:
export LOFTY_CUSTOMER_KEY="eyJhbGciOiJIUzI1NiJ9..."Option B — Save to local file:
lofty-cli auth set "eyJhbGciOiJIUzI1NiJ9..."The customer key is stored at
~/.config/tokens/lofty-cli.txtwithchmod 600.
Step 3: Verify
# Check authentication status
lofty-cli auth status
# Manually obtain an access_token
lofty-cli auth login
# Test with a real API call
lofty-cli auth testHow it works
- CLI calls
POST {BASE_URL}/oauth/tokenwithclient_id,client_secret,customer_key,grant_type=client_credentials,scope=openapi - The returned
access_tokenis cached locally at~/.config/tokens/lofty-oauth-cache.json - Cached token is reused until it expires (auto-refreshes 5 minutes before expiry)
- All API requests use
Authorization: Bearer <access_token>
Mode 2: OAuth PKCE — Browser Authorization (Interactive)
This mode uses OAuth 2.0 Authorization Code Flow with PKCE (S256). The CLI opens a browser window for the user to log in and authorize. No client_secret is needed — the CLI is a public client secured by PKCE.
Step 1: Authorize via browser
lofty-cli auth login-browserWhat happens:
- If a browser can be opened, it opens automatically with the authorization page
- If not (e.g., SSH session), a URL is printed for manual copy-paste
- You log in and click "Authorize" in the browser
- The CLI receives the authorization code (via polling or manual paste)
- The code is exchanged for
access_token+refresh_tokenusing PKCE
Step 2: Verify
lofty-cli auth status # Shows PKCE token status
lofty-cli auth test # Test with a real API callHow it works
- CLI generates a random
code_verifierand computescode_challenge = BASE64URL(SHA256(code_verifier)) - Browser opens
{AUTH_BASE}/page/vendor-auth.html?clientId=...&code_challenge=...&code_challenge_method=S256 - User logs in and authorizes
- CLI gets the authorization
code(via server polling or user paste) - CLI exchanges
code+code_verifieratPOST {AUTH_BASE}/api/user-web/oauth/token - The returned tokens are stored at
~/.config/tokens/lofty-pkce-token.json(chmod 600) - Cached token is reused until it expires
- All API requests use
Authorization: Bearer <access_token>
Mode 3: Direct API Key (Legacy)
If vendor credentials (LOFTY_CLIENT_ID / LOFTY_CLIENT_SECRET) are not configured, the CLI falls back to using the customer key directly as the Authorization header value.
# Set customer key
lofty-cli auth set "your-api-key"
# Or via environment variable
export LOFTY_CUSTOMER_KEY="your-api-key"Environment Variables
| Variable | Required | Description |
|---|---|---|
LOFTY_CLIENT_ID |
For OAuth mode | Vendor client ID issued by Lofty |
LOFTY_CLIENT_SECRET |
For OAuth mode | Vendor client secret issued by Lofty |
LOFTY_CUSTOMER_KEY |
Yes (or use auth set) |
User's customer key / API key |
LOFTY_OAUTH_REDIRECT_URI |
No | Override PKCE redirect URI |
LOFTY_AUTH_BASE_URL |
No | Override auth page base URL |
LOFTY_BASE_URL |
No | Override API base URL (default: https://api.lofty.com) |
Usage
# View all available resources
lofty-cli --help
# Examples
lofty-cli leads list
lofty-cli leads get --id "lead_id"
lofty-cli leads create --body '{"first_name":"John","last_name":"Doe"}'
lofty-cli transaction list
lofty-cli communication list
lofty-cli tasks listResources
| Resource | Description |
|---|---|
leads |
Lead management (list, get, create, update, delete, etc.) |
transaction |
Transaction/deal management |
communication |
Email, SMS, and communication logs |
tasks |
Task management |
notes |
Note management |
calls |
Call records |
alerts |
Alert/notification management |
members |
Team member management |
listings |
Property listing management |
webhooks |
Webhook management |
lead-routing |
Lead routing/assignment rules |
team-features |
Team feature toggles |
agent-org |
Agent organization management |
agent-user |
Agent user management |
log-type |
Log type definitions |
system-logs |
System audit logs |
opportunity |
Opportunity management |
vendor |
Vendor management |
Run lofty-cli <resource> --help for detailed commands and options.
Auth Commands
| Command | Description |
|---|---|
lofty-cli auth set <key> |
Save customer key to local file |
lofty-cli auth show |
Display current customer key (masked) |
lofty-cli auth show --raw |
Display full customer key |
lofty-cli auth remove |
Delete customer key and OAuth cache |
lofty-cli auth login |
Manually obtain OAuth access_token |
lofty-cli auth login-browser |
Authorize via browser (OAuth PKCE) |
lofty-cli auth status |
Show authentication status overview |
lofty-cli auth test |
Verify auth by making a test API call |
Global Flags
All commands support:
| Flag | Description |
|---|---|
--json |
Output as JSON |
--format <type> |
Output format: text, json, csv, yaml |
--verbose |
Enable verbose/debug logging |
--no-color |
Disable colored output |
--no-header |
Omit table headers |