Docs/SDK/CLI

CLI — npx apptvty init

Register a site, trigger re-indexing, or manage administrative access without writing any code. Works for both humans (interactive) and AI agents (JSON output mode).

Usage

bash
npx apptvty [command] [flags]

No global install needed. Default command is init.

Flags

Command / FlagDescription
initDefault. Register a site and scaffold integration files.
migrateTrigger an immediate re-crawl/re-index of your site.
create-superuserCreate an administrative account for the dashboard.
--domain <value>Site domain, e.g. mysite.com. Auto-detected if omitted.
--framework <value>nextjs | express | other. Auto-detected from package.json.
--non-interactivePrint JSON to stdout. No prompts (alias: --json).
--email <value>Administrator email (for init or create-superuser).
--password <value>Administrator password (for create-superuser).
--api-url <value>Override the Apptvty API base URL (staging / self-hosted).

Interactive mode (human)

bash
$ npx apptvty init

  apptvty — AI traffic analytics

  Framework detected: nextjs
  Domain detected:    mysite.com

  Registering with Apptvty... done

  ✓ Site registered:     mysite.com
  ✓ Wallet created:      0xabc...
  ✓ Credentials written: .env.local
  ✓ Created:             middleware.ts
  ✓ Created:             app/query/route.ts

  ─────────────────────────────────────────────
  Dashboard (open in browser):
  https://app.apptvty.com/claim?token=...
  ─────────────────────────────────────────────

  Link valid for 30 days. Add your email in the dashboard
  to avoid losing access.

Non-interactive mode (agents)

Use --non-interactive (or --json) to suppress all prompts and output a single line of JSON to stdout. Ideal for coding agents and CI pipelines.

bash
npx apptvty init --domain mysite.com --framework nextjs --non-interactive

Stdout (newline-terminated JSON):

json
{
  "site_id": "site_abc123",
  "api_key": "ak_live_...",
  "company_id": "co_xyz...",
  "wallet_address": "0xabc...",
  "dashboard_url": "https://app.apptvty.com/claim?token=...",
  "trial_ends_at": "2026-03-24T12:00:00.000Z",
  "email": "dev@example.com",
  "env_file": ".env.local",
  "env_vars": {
    "APPTVTY_SITE_ID": "site_abc123",
    "APPTVTY_API_KEY": "ak_live_..."
  }
}

On error, stdout contains {"error": "<message>"} and the process exits with code 1.

Files written to disk

FrameworkEnv fileScaffold files
nextjs.env.localmiddleware.ts, app/query/route.ts
express.envnone (setup shown in terminal)
other.envnone

Existing files are never overwritten. The env file is appended — existing variables are preserved.

Auto-detection

When --framework is omitted, the CLI reads your package.json: if next is in dependencies → nextjs; if express is in dependencies → express; otherwise → other. The domain is auto-detected from the homepage field.