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
npx apptvty [command] [flags]No global install needed. Default command is init.
Flags
| Command / Flag | Description |
|---|---|
| init | Default. Register a site and scaffold integration files. |
| migrate | Trigger an immediate re-crawl/re-index of your site. |
| create-superuser | Create 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-interactive | Print 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)
$ 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.
npx apptvty init --domain mysite.com --framework nextjs --non-interactiveStdout (newline-terminated 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
| Framework | Env file | Scaffold files |
|---|---|---|
| nextjs | .env.local | middleware.ts, app/query/route.ts |
| express | .env | none (setup shown in terminal) |
| other | .env | none |
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.