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

# Troubleshooting

> If something does not work as expected, run the failing command with --verbose first. It prints the resolved auth method, the outgoing URL, and any error details to stderr.

If something does not work as expected, run the failing command with `--verbose` first — it prints the resolved auth method, the outgoing URL, and any error details to stderr. Most issues fall into one of the buckets below.

## Authentication

### `401 Unauthorized` from every command

Check which credential path the CLI is using:

```bash theme={null}
lofty-cli auth status --verbose
```

Common causes:

| Symptom | Likely cause | Fix |
| - | - | - |
| No credentials found | None of the four auth methods are configured | Pick one method from **[Authentication](https://developer.lofty.com/cli/authentication.md)** |
| Token expired and refresh failed | Refresh token was revoked or stale | `lofty-cli auth logout` then re-authenticate |
| `LOFTY_CUSTOMER_KEY` is set but wrong | Key copied with surrounding whitespace | Re-copy from **Settings > Integrations > API** in the Lofty CRM |
| OAuth flow fails with `invalid_client` | `LOFTY_CLIENT_ID` / `LOFTY_CLIENT_SECRET` mismatch | Reissue the credential in the [Vendor Portal](https://api.lofty.com/vendor/frontend/static/index.html#/login) |

### Browser flow opens but never completes

From version 1.0.12, `lofty-cli auth login-browser` listens on `127.0.0.1` at the first free port of 53682, 53683, and 53684. After you approve, the browser returns to that port and the login completes on its own. Check `lofty-cli --version`. Older versions do not complete the login on their own: copy the code shown in the browser and paste it into the terminal, or update with `npm install -g @loftyai/lofty-cli@latest`.

If the login does not complete:

* **The browser shows a connection error after you approve.** This happens when the browser runs on another machine, for example when you use the CLI over SSH. Copy the full address from the browser's address bar and paste it into the terminal.
* **The CLI reports that it could not open a local login listener.** Another program holds all three ports. Free one of them, or continue with the fallback: the browser shows a page with the code, and you paste that code into the terminal.
* **Anti-virus, a VPN, or a proxy blocks loopback connections.** Allow `127.0.0.1` on ports 53682–53684, or paste the callback address as above.
* **No browser is available.** Use [OAuth client credentials](https://developer.lofty.com/cli/authentication.md#oauth-client-credentials) (`lofty-cli auth login`) or set `LOFTY_ACCESS_TOKEN` directly.

## Rate limiting

A `429 Too Many Requests` response means you have exceeded the API rate budget.

The CLI does **not** retry automatically. Wrap your invocations in a backoff loop if you are running large bulk jobs:

```bash theme={null}
#!/usr/bin/env bash
set -euo pipefail

OFFSET=0
LIMIT=100

while true; do
  if ! lofty-cli leads list --offset "$OFFSET" --limit "$LIMIT" --json; then
    echo "Request failed, waiting 30s before retry..." >&2
    sleep 30
    continue
  fi
  OFFSET=$((OFFSET + LIMIT))
done
```

## Pagination cut-offs

If you only see the first page of results, you are hitting the default page size. Use `--offset` and `--limit` (where supported) or stream pages until empty:

```bash theme={null}
#!/usr/bin/env bash
set -euo pipefail

OFFSET=0
LIMIT=100

while true; do
  PAGE=$(lofty-cli leads list --offset "$OFFSET" --limit "$LIMIT" --json)
  COUNT=$(echo "$PAGE" | jq 'length')
  echo "$PAGE"
  [ "$COUNT" -lt "$LIMIT" ] && break
  OFFSET=$((OFFSET + LIMIT))
done
```

## ID precision in shell pipelines

Lofty IDs are 64-bit integers. `jq` and most shells preserve precision for `--json` output, but `bc`, `awk`, and JavaScript (when piped through `node -e`) do **not**.

When you must hand an ID to JavaScript, treat it as a string from the start:

```bash theme={null}
ID=$(lofty-cli leads list --json | jq -r '.[0].leadId')   # ID is a string
node -e "console.log('Lead:', process.argv[1])" "$ID"
```

> [!NOTE]
>
> See [JavaScript / TypeScript Integration](https://developer.lofty.com/javascript-integration.md) for full guidance on handling 64-bit IDs.

## Network and TLS

### `getaddrinfo ENOTFOUND` or `EAI_AGAIN`

DNS cannot resolve `api.lofty.com`. Confirm:

```bash theme={null}
curl -sSf https://api.lofty.com/health
```

If `curl` also fails, the issue is your network (corporate proxy, VPN, DNS).

### TLS certificate errors

If your environment intercepts TLS (corporate proxy with a custom CA), set:

```bash theme={null}
export NODE_EXTRA_CA_CERTS=/path/to/your/ca-bundle.pem
```

> [!WARNING]
>
> Do **not** disable TLS verification for production traffic.

## Debug output

`--verbose` is the universal escape hatch:

```bash theme={null}
lofty-cli leads list --verbose 2> debug.log
```

`stderr` carries debug; `stdout` stays clean for piping. Attach the log to any support request along with the failing command and CLI version (`lofty-cli --version`).

## Still stuck?

* Re-check **[Authentication](https://developer.lofty.com/cli/authentication.md)** for the credential precedence rules

* Reproduce the request directly with `curl` against the endpoint shown in `--verbose`

* Ask in the internal `#openapi` channel and include `lofty-cli --version`, the failing command, and the `--verbose` log


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.