Skip to content

CLI

The Agent Analytics CLI is the official shell-first wrapper around the documented HTTP API. Use it when your AI agent already has terminal access and you want predictable command output with lower overhead than MCP-style tool calls.

The published package is @agent-analytics/cli. For one-off use, run it through npx with a pinned version:

Terminal window
npx --yes @agent-analytics/cli@0.5.41 --help

Source repo: Agent-Analytics/agent-analytics-cli

In the rest of this page, agent-analytics means the CLI binary from @agent-analytics/cli@0.5.41 (npx --yes @agent-analytics/cli@0.5.41).

Choose the CLI when:

  • your agent already works in a shell-first environment
  • you want a thin wrapper over the hosted API instead of a connector flow
  • you want command composition and scripting instead of tool-call round trips
  • you want local auth helpers such as login, logout, whoami, and auth status

If you are deciding between access paths rather than looking for CLI usage itself, start with Skill vs MCP vs API.

Use the seeded public demo when you want an AI agent to try the real CLI/API workflow before you connect an account:

Terminal window
npx --yes @agent-analytics/cli@0.5.41 demo
npx --yes @agent-analytics/cli@0.5.41 --demo projects
npx --yes @agent-analytics/cli@0.5.41 --demo stats agentanalytics-demo --days 30
npx --yes @agent-analytics/cli@0.5.41 --demo paths agentanalytics-demo --goal signup --since 30d
npx --yes @agent-analytics/cli@0.5.41 --demo funnel agentanalytics-demo --steps "page_view,signup_started,signup"
npx --yes @agent-analytics/cli@0.5.41 --demo breakdown agentanalytics-demo --property path --event signup_started --days 30
npx --yes @agent-analytics/cli@0.5.41 --demo breakdown agentanalytics-demo --property path --event signup --days 30
npx --yes @agent-analytics/cli@0.5.41 --demo experiments get exp_demo_signup_cta

Useful prompts:

  • “Audit the signup leak, question the data, and tell me the next fix to test.”
  • “Check whether the CTA experiment winner actually fixes the biggest signup problem.”
  • “Turn the demo analytics into a developer-ready growth task with metrics and guardrails.”

--demo fetches a short-lived read-only aas_* session from POST /demo/session, then runs normal read commands against the hosted agentanalytics-demo project. It does not expose a raw aak_* API key, does not read or write your saved CLI config, and blocks mutating commands locally.

scan exists for authenticated operator workflows and scanner-informed setup previews. It is not the normal setup center for agents that can inspect the product repo. For normal setup, create or identify the project, confirm the initial product goal, install the project-owned tracker, add intentional events tied to that goal, and verify the first useful event.

When a scan is used, treat the scanned URL as a project surface, not as the project identity. Read minimum_viable_instrumentation, confirm the user goal before storing durable context, install only recommendations tied to that goal, then verify the first useful event with events.

Public browser previews analyze only the root domain. They do not create an aas_* agent session. CLI scan creation and project linking require login and a project, except for internal complimentary-account workflows.

Full analysis is a new signed-in request: scan <url> --full --project <project> --json. A quick preview cannot be claimed or upgraded into a full analysis; create a new request for the same URL after login.

Terminal window
npx --yes @agent-analytics/cli@0.5.41 login
npx --yes @agent-analytics/cli@0.5.41 create my-site --domain https://mysite.com
npx --yes @agent-analytics/cli@0.5.41 scan https://mysite.com --project my-site --json
npx --yes @agent-analytics/cli@0.5.41 events my-site --event <first_useful_event> --days 7 --limit 20

The JSON output is stable for agent skills. Agents should install only the high-priority minimum_viable_instrumentation first and verify the first useful recommended event with events.

Each recommendation includes an implementation_hint mapped to tracker.js capabilities. Page views, paths, referrers, UTMs, device/browser fields, country, session IDs, session count, days since first visit, and first-touch attribution are automatic, so agents should not add custom duplicates for those signals. Use data-aa-event for named click intent, data-aa-impression for meaningful section exposure, window.aa.track(...) for computed client state, server-side tracking for durable outcomes such as completed signup, and broad script opt-ins only when they unlock the stated decision.

The CLI is agent-session-first:

  • default: agent-analytics login opens browser approval with a local loopback callback
  • project and level: agent-analytics login --project <name> --level read|manage|admin asks the owner for one project and a level. The default level is read. Omit --project when the owner should choose, including All projects. --level accepts read, manage, or admin
  • detached handoff: agent-analytics login --detached prints an approval URL and exits so issue-based or remote runtimes can resume with a finish code. --project and --level work on this form too
  • optional polling: agent-analytics login --detached --wait keeps the process alive for local shells that can wait for browser approval

whoami prints the account, the granted project (the name, or null for All projects), and the level (read, manage, admin, or legacy).

Do not ask users to paste long-lived API keys into an agent thread. Browser approval is the normal hosted flow. Project keys (aapk_*) are created only from the dashboard, shown once, and are not a login substitute.

The CLI stores local config at $XDG_CONFIG_HOME/agent-analytics/config.json, with fallback to ~/.config/agent-analytics/config.json.

For managed agent runtimes where home-directory config may not persist, set an explicit persistent directory before login:

Terminal window
export AGENT_ANALYTICS_CONFIG_DIR="$PWD/.openclaw/agent-analytics"
npx --yes @agent-analytics/cli@0.5.41 login --detached
npx --yes @agent-analytics/cli@0.5.41 auth status

You can also pass --config-dir "$PWD/.openclaw/agent-analytics" before or after any command. Resolution order is: --config-dir, AGENT_ANALYTICS_CONFIG_DIR, $XDG_CONFIG_HOME/agent-analytics, then ~/.config/agent-analytics.

Credential lookup still respects compatibility environment overrides first, so AGENT_ANALYTICS_API_KEY continues to win until you unset it.

Free accounts can prove the workflow with core setup and basic reads. Pro unlocks deeper agent analysis: funnels, retention, sessions, pages, heatmaps, insights, live reads, experiments, query (including sum, avg, p50, p75, and p95, and one properties.<key> in group_by), read-only sql, grouped $error reads, vitals, no monthly agent/API read cap, no monthly event cap, and 365-day retention.

When a CLI command returns PRO_REQUIRED or a free-tier read cap, ask the agent to create a human payment handoff:

Terminal window
agent-analytics upgrade-link --detached

upgrade-link --detached prints an app.agentanalytics.sh link and exits. The human opens the link, the dashboard confirms the logged-in account, the payment page handles payment, and the webhook activates Pro.

Use upgrade-link --wait when the local shell should keep polling until whoami would show Pro.

For machine-readable pricing, current account status, and the human handoff, use:

Terminal window
agent-analytics upgrade-link --detached --json
agent-analytics account-usage --json

Both read the same GET /account/usage contract. payment.next_action is a human browser action, not permission to charge. Poll account-usage --json after checkout, with the returned interval and bounded wait, and retry the original task when payment.status.can_retry_pro_task is true. Pending checkout does not prove payment. Complimentary Pro is active access without subscription charges. JSON handoffs require --detached; use the existing text --wait flow for interactive waiting. The browser link uses a fixed reason and never includes the original command. Keep the full retry command in the agent session; legacy --reason and --command arguments are accepted but omitted from the handoff.

MCP clients use the read-only account_usage tool with account:read. Paid tools check current Hosted entitlement on each call, so an upgraded account can retry without reconnecting MCP.

Terminal window
agent-analytics projects
agent-analytics whoami
agent-analytics auth status
agent-analytics create my-site --domain https://mysite.com
agent-analytics stats my-site --days 7
agent-analytics insights my-site --period 7d
agent-analytics events my-site --days 7 --limit 20
agent-analytics sessions my-site
agent-analytics replays open --session sess_EXAMPLE --project my-site
agent-analytics context get my-site
agent-analytics context set my-site --json '{"goals":["Increase activated accounts"],"activation_events":["signup_completed","project_created","first_event_received"],"glossary":[{"event_name":"first_event_received","term":"AA Activation","definition":"Signup, project created, and first event received."}],"annotations":[{"occurred_at":"2026-04-25T13:00:00.000Z","title":"Changed pricing page offer"}]}'
agent-analytics annotate my-site --title "Changed pricing page offer" --at 2026-04-25T13:00:00.000Z
agent-analytics query my-site --metrics p75 --property cwv_lcp
agent-analytics query my-site --metrics event_count --group-by properties.path
aa sql my-site --sql 'SELECT event, COUNT(*) AS n FROM events GROUP BY event'
aa sql my-site -f file.sql
agent-analytics vitals my-site --days 7
agent-analytics compare my-site --goal signup --ship-date 2026-04-15 --days 7
agent-analytics compare my-site --goal signup --metric 'p75(cwv_lcp)' --metric-event page_view --better lower --ship-date 2026-11-05
agent-analytics errors my-site --since 7d --new-since 2026-11-12
agent-analytics breakdown my-site --property path --event page_view --days 7 --limit 10
agent-analytics paths my-site --goal signup --since 30d --max-steps 5
agent-analytics funnel my-site --steps "page_view,signup,purchase"
agent-analytics retention my-site --period week --cohorts 8
agent-analytics experiments list my-site
agent-analytics logout

The main command families are:

  • account and auth: login, logout, whoami, auth status, upgrade-link
  • project setup: scan, create, projects
  • reporting: stats, insights, breakdown, pages, paths, sessions-dist, events, sessions, query, compare, vitals, errors, sql
  • session replay: replays settings, replays enable, replays disable, replays list, replays get, replays open, replays delete, replays usage
  • live monitoring: live
  • schema and context: properties, properties-received, context get, context set, annotate. catalog is planned for GET /catalog. Until that command ships, use properties.
  • analysis workflows: funnel, retention, experiments
  • product feedback: feedback

Scoped agent sessions cannot generate or rotate raw account API keys; manage compatibility keys from the dashboard.

Session replay is an explicit opt-in Pro or complimentary feature. It records structured rrweb DOM and interaction data, not literal video. Enabling a project does not change tracker.js; the customer must also install the separate replay.js bootstrap.

Use the analytics-session link to move from a measured behavior to its qualitative evidence:

Terminal window
agent-analytics replays settings my-site
agent-analytics replays enable my-site --recording-start after_consent --mask '.customer-id'
agent-analytics sessions my-site
agent-analytics replays list my-site --session sess_EXAMPLE
agent-analytics replays open --session sess_EXAMPLE --project my-site

sessions marks linked recordings with ▶ replay. Opening by session chooses the newest playable segment and reports when that session has multiple replay segments. The generated sandboxed viewer URL expires after one hour; rerun the command for a fresh one. Treat it as a bearer credential during that hour and do not log, persist, or publish it.

See Session replay for installation, consent, CSP, privacy controls, playback, retention, and deletion.

projects prints each project’s name, ID, project token, and allowed origins. project, update, and delete accept either the exact project name or the project ID.

Use update to change allowed origins without leaving the CLI. The --domain value on create is the required primary surface URL/origin for setup and allowed-origin checks; it is not the project identity. For local browser QA, treat localhost and preview deployments as setup/testing surfaces: keep the production origin and add the temporary local or preview origin:

Terminal window
agent-analytics update stylio --origins 'https://stylio.app,http://lvh.me:3101'

Use context get and context set when a project has custom goals, activation events, event meanings, or date annotations that should travel with analytics results.

Project context is intentionally compact. Project-scoped analytics result endpoints return it as project_context when it is non-empty, so long notes would make every agent read noisier.

The stored shape is:

  • goals: up to 5 short business goals
  • activation_events: up to 8 event names that define activation or the main success path
  • glossary: up to 10 entries, each with event_name, term, and definition
  • annotations: up to 100 entries, each with occurred_at, title, and optional note

context set accepts an encoded JSON request body up to 512KB. Individual entries are also capped: goals at 160 characters, event names at 96 characters, glossary terms at 64 characters, glossary definitions at 240 characters, annotation titles at 120 characters, and annotation notes at 500 characters.

Use annotations for major product changes that could explain later graph movement: landing page, pricing, onboarding, feature, release, or experiment changes. Do not store git commit logs, noisy edits, temporary metric notes, PII, secrets, or long release notes. Direct context get returns all annotations; project-scoped analytics responses include annotations only for the requested analytics date range plus one day before and after.

context set and PUT /project-context replace the whole document. annotate in @agent-analytics/cli@0.5.41 appends one annotation and leaves goals, activation events, the glossary, and existing annotations in place. It posts to POST /project-context/annotations with project, occurred_at, title, and note only when you pass --note. --at sets occurred_at and defaults to the current UTC time. The same normalized occurred_at and title returns 200 with appended: false and keeps the stored note. A new annotation when 100 are already stored returns 409.

Terminal window
npx --yes @agent-analytics/cli@0.5.41 annotate my-site --title "Changed pricing page offer" --note "Moved annual plan discount above the fold." --at 2026-04-25T13:00:00.000Z

See Day-7 compare read.

Before setting or refreshing a glossary, inspect the project’s real event names:

Terminal window
agent-analytics properties my-site
agent-analytics properties-received my-site

Then store the compact context:

Terminal window
agent-analytics context set my-site --json '{"goals":["Increase activated accounts"],"activation_events":["signup_completed","project_created","first_event_received"],"glossary":[{"event_name":"first_event_received","term":"AA Activation","definition":"Signup, project created, and first event received."}],"annotations":[{"occurred_at":"2026-04-25T13:00:00.000Z","title":"Changed pricing page offer","note":"Moved annual plan discount above the fold."}]}'

Read it back with:

Terminal window
agent-analytics context get my-site

Use portfolios when several related projects should share a privacy-first customer lookup boundary and be interpreted as one growth system. In the product model, a portfolio connects related projects while each project keeps its own events, activation, retention, lifecycle, releases, experiments, and local goals. Surfaces are the places users encounter or use those projects. See Projects, surfaces, and portfolios for the canonical model.

An identity portfolio is the server-side scope for cross-project identity-aware reads and email lookup when configured within intentionally grouped portfolio projects. It does not merge every project in an account automatically, and it does not replace project-local truth.

Cross-project identity needs both setup steps:

  • add data-link-domains to each participating tracker snippet so the browser passes _aa across related surface domains
  • add those Agent Analytics projects to the same identity portfolio so hosted analytics resolves intentionally grouped projects in the same scope

If you only configure data-link-domains, links are decorated but separate projects remain isolated. If you only configure a portfolio, the server has a shared scope but the browser has no anonymous ID to carry across domains.

A good fit is a setup like one portfolio with separate projects for related growth loops:

  • agentanalytics.sh → scanner and conversion surface
  • openorchestrators.org → discovery surface
  • clawflows.com → ecosystem discovery surface

Example:

Terminal window
agent-analytics portfolios create growth-system \
--name "Growth system" \
--projects agentanalytics.sh,openorchestrators.org,clawflows.com

Manage it with:

Terminal window
agent-analytics portfolios list
agent-analytics portfolios get growth-system
agent-analytics portfolios update growth-system --projects agentanalytics.sh,openorchestrators.org,clawflows.com --move

The older portfolio-context commands only store compact account-level interpretation notes. Use portfolios for the public identity lookup and membership contract.

After a real source-to-destination click, verify the destination project:

Terminal window
agent-analytics query agentanalytics.sh \
--metrics event_count,unique_users \
--filter '[{"field":"properties.referrer","op":"contains","value":"clawflows.com"}]' \
--days 1

Most CLI workflows map directly to an HTTP endpoint. Auth convenience commands such as logout also update local CLI state and may perform best-effort session cleanup.

CLI Command API Endpoint
agent-analytics stats my-site GET /stats?project=my-site
agent-analytics all-sites --period 7d GET /account/all-sites?period=7d
agent-analytics bot-traffic my-site --period 7d GET /bot-traffic?project=my-site&period=7d
agent-analytics bot-traffic --all --period 7d GET /account/bot-traffic?period=7d
agent-analytics events my-site GET /events?project=my-site
agent-analytics sessions my-site GET /sessions?project=my-site
agent-analytics replays list my-site --session sess_123 GET /replays?project=my-site&session_id=sess_123
agent-analytics replays open rpl_123 POST /replays/rpl_123/open
agent-analytics events my-site --email alice@example.com POST /events/lookup with { project, email }
agent-analytics journey my-site --email alice@example.com POST /journey/lookup with { project, email }
agent-analytics properties my-site GET /properties?project=my-site
agent-analytics catalog my-site (planned) GET /catalog
agent-analytics context get my-site GET /project-context?project=my-site
agent-analytics context set my-site --json '{...}' PUT /project-context
agent-analytics annotate my-site --title "Changed pricing page offer" POST /project-context/annotations
agent-analytics compare my-site --goal signup --ship-date 2026-04-15 --days 7 POST /compare
agent-analytics compare grokbotpages.com --goal template_opened --exclude-denominator 'properties.title=Page not found | grokbotpages.com' POST /compare with denominator_filters: [{ field, op: "neq", value }]
agent-analytics portfolios list GET /portfolios
agent-analytics portfolios create growth --name Growth --projects app,docs POST /portfolios
agent-analytics portfolios get growth GET /portfolios/{idOrSlug}
agent-analytics portfolios update growth --projects app,docs --move PATCH /portfolios/{idOrSlug}
agent-analytics query my-site --metrics event_count POST /query
aa sql my-site --sql 'SELECT event, COUNT(*) AS n FROM events GROUP BY event' POST /sql
aa sql my-site -f file.sql POST /sql with the file contents as sql
agent-analytics query my-site --metrics p75 --property cwv_lcp POST /query with metrics: ["p75"] and property: "cwv_lcp"
agent-analytics vitals my-site --days 7 POST /vitals
agent-analytics vitals my-site --by path --limit 10 POST /vitals with group_by: "path" and limit: 10
agent-analytics query my-site --metrics event_count --count-mode raw POST /query
agent-analytics compare my-site --goal signup --metric 'p75(cwv_lcp)' --metric-event page_view --better lower POST /compare with metric, metric_event, and better
agent-analytics errors my-site --since 7d --new-since 2026-11-12 GET /errors
agent-analytics paths my-site --goal signup POST /paths
agent-analytics funnel my-site --steps "page_view,signup,purchase" POST /funnel
agent-analytics retention my-site --period week --cohorts 8 GET /retention?project=my-site&period=week&cohorts=8
agent-analytics experiments list my-site GET /experiments?project=my-site
agent-analytics experiments create my-site --name signup_cta --variants control,new_cta --goal signup POST /experiments
agent-analytics experiments get exp_abc123 GET /experiments/{id}
agent-analytics scan https://mysite.com --project my-site --json POST /cli/website-scans
agent-analytics scan https://mysite.com --full --project my-site --json POST /cli/website-scans
agent-analytics projects GET /projects
agent-analytics project my-site GET /projects/{id} after resolving name or ID
agent-analytics update my-site --origins https://mysite.com PATCH /projects/{id} after resolving name or ID
agent-analytics delete my-site DELETE /projects/{id} after resolving name or ID
agent-analytics logout Clears saved CLI auth and, when a stored agent session ID and usable token material are available, best-effort revokes that agent session.

logout clears the auth state saved by the CLI on disk and may revoke the stored agent session. It is not logout-all-devices. Browser /auth/logout is POST-only, clears only the current browser session, and does not disconnect CLI agents. To disconnect selected agent sessions explicitly, use Dashboard Settings / Agent Sessions.

compare is in @agent-analytics/cli@0.5.41. It is a free read of POST /compare. A successful call counts as one metered read. Run a 7-day read on ship day + 8 or later. Ship day is excluded from both windows. The goal is unique converters (count_mode unique_users): a user who fires it three times counts once. revert only when relative lift is at or below the revert threshold and the 90% interval lies entirely below zero. A drop inside that noise is extend / inconclusive. A window that includes today UTC is extend / incomplete_current_day.

Terminal window
npx --yes @agent-analytics/cli@0.5.41 compare <project> --goal <event> [--ship-date <YYYY-MM-DD>] [--days <N>] [--denominator <event>] [--exclude-denominator <field>=<value>] [--metric '<agg>(<property>)'] [--metric-event <event>] [--better higher|lower] [--keep-threshold <fraction>] [--revert-threshold <fraction>] [--min-denominator <N>] [--min-goal-events <N>] [--filter <json>] [--json]

--days is window_days. With --ship-date it defaults to 7, and it must be a multiple of 7 from 1 to 90. --denominator defaults to page_view. Do not filter on event. --exclude-denominator is repeatable. Each flag is one denominator_filters entry with op neq. --metric is sum(<property>), avg(<property>), p50(<property>), p75(<property>), or p95(<property>). --metric-event defaults to the goal. --better is higher or lower and defaults to higher. Set --better lower for cwv_lcp. Omit --metric for the conversion-rate read. Thresholds are fractions: 0.15 means +15%. An absolute value above 5 is rejected. --json prints the API body, including verdict, reason, lift, the 90% interval, and guardrails. When --metric is set, each window includes value, n, and skipped, per_user is true for sum, interval is null, and interval_method is none. The sum numerator ignores denominator_filters. A metric compare returns extend instead of keep or revert in v1, with reason no_interval_for_metric when lift meets a threshold. See Day-7 compare read.

Terminal window
npx --yes @agent-analytics/cli@0.5.41 compare grokbotpages.com --goal template_opened --ship-date 2026-11-04 --exclude-denominator 'properties.title=Page not found | grokbotpages.com'

For explicit windows, pass all four dates and omit --ship-date and --days:

Terminal window
npx --yes @agent-analytics/cli@0.5.41 compare <project> --goal <event> --baseline-from <YYYY-MM-DD> --baseline-to <YYYY-MM-DD> --compare-from <YYYY-MM-DD> --compare-to <YYYY-MM-DD>

See Day-7 compare read.

vitals is in @agent-analytics/cli@0.5.41. It is a Pro read of POST /vitals. One successful call counts as one metered read. Free accounts receive 403 PRO_REQUIRED, and that response is not metered. The hosted event is page_view. p75 is the headline.

Terminal window
npx --yes @agent-analytics/cli@0.5.41 vitals <project> [--days N] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--by device|path] [--limit N] [--json]

--from and --to are date_from and date_to. --by is device or path. --limit defaults to 10 and the maximum is 20. --json prints the API body. Metrics, units, thresholds, browser support, and the response shape are on Web Vitals.

The MCP tool is web_vitals, with project, days, date_from, date_to, group_by, and limit.

  • The canonical CLI syntax is agent-analytics query <project> .... Do not use --project.
  • Use journey <project> --user-id <id> or journey <project> --email <email> when you need one customer timeline. Email lookup sends the raw email over HTTPS in an authenticated POST body so the server can match a project/portfolio-scoped HMAC lookup index.
  • Raw email may be transmitted during identify or authenticated lookup, but Agent Analytics does not store it raw in event rows or profile traits. Do not send browser-side SHA-256 hashes or email_hash payloads; they are no longer part of the public CLI/API contract.
  • /events stays raw and lossless. /query uses session_then_user as the default for event_count.
  • For recent signup or ingestion debugging, check events <project> --event <actual_event_name> first; add --user-id or --email when you want the raw rows for one identity.
  • Use --count-mode raw when the question is about ingestion volume or duplicate-write debugging rather than activation-safe counts.
  • Built-in query fields are event, user_id, date, country, session_id, and timestamp.
  • Numeric metrics are sum, avg, p50, p75, and p95. Pass --property <key> (cwv_lcp, revenue). They are part of paid POST /query. Each row includes the requested metric plus n and skipped. Only JSON numbers are aggregated. Percentiles are nearest-rank: sort ascending, break ties by event id, and take rank ceil(p/100 * n). percentile_method is nearest_rank when a percentile is requested. A percentile query whose filtered set is larger than 200,000 events is 400.
  • Example: npx --yes @agent-analytics/cli@0.5.41 query my-site --metrics p75 --property cwv_lcp --filter '[{"field":"event","op":"eq","value":"page_view"}]'. Hosted stores cwv_* on page_view. Self-hosted core stores the same keys on $web_vitals. Hosted does not store $web_vitals. If n is 0, the event filter does not carry the key. The rated read is vitals. See Web Vitals.
  • Non-built-in fields such as referrer, utm_source, path, browser, and hostname must be written as properties.<key>.
  • group_by accepts event, date, user_id, session_id, country, and at most one properties.<key>. <key> is 1 to 128 characters matching [A-Za-z0-9_], the same rule as a filter. The result row uses the key exactly properties.<key>. A null or missing property groups as null. Two properties.* entries are 400 INVALID_GROUP_BY. A bad key is 400 INVALID_PROPERTY_KEY. limit stays at most 1,000. Numeric metrics work with this group column. The route stays Pro. Example: npx --yes @agent-analytics/cli@0.5.41 query my-site --metrics event_count --group-by properties.path --filter '[{"field":"event","op":"eq","value":"signup"}]'.
  • If you need low-level payload or filter debugging, move to the API Reference instead of forcing complex shell JSON into the CLI.
  • A before/after read of a shipped change is compare, not query. Compare is free on every plan. POST /query stays paid-only. The command is @agent-analytics/cli@0.5.41. See Day-7 compare.
  • Read-only SQL is aa sql <project> --sql '...' or aa sql <project> -f file.sql (agent-analytics sql is the same command). It is Pro. Use query first. Pass the statement with --sql or -f. Do not build it by concatenating untrusted shell input. See Read-only SQL.

errors is in @agent-analytics/cli@0.5.41. It is a Pro read of GET /errors. One successful call counts as one metered read. Free accounts receive PRO_REQUIRED.

Terminal window
npx --yes @agent-analytics/cli@0.5.41 errors <project> --since 7d [--until <YYYY-MM-DD>] [--new-since <YYYY-MM-DD or annotation>] [--limit <N>]

--since accepts 7d or a YYYY-MM-DD date and defaults to 7d. A since that overflows is 400 INVALID_SINCE. --until defaults to today UTC. --limit defaults to 20. Values above 100 are clamped to 100.

The command groups $error events. The fingerprint is the SHA-256 hex of the normalized message, the source filename, and the numeric line. Normalization removes URL query strings and fragments, then replaces UUIDs, hex hashes, and numbers. The filename drops its query and hash. col is not part of the key. The tracker does not send stack, and stack is not part of the key.

Each group includes fingerprint, message (one stored sample), source, line, count, users, sessions, first_seen, last_seen, and top_paths (at most 3). count, users, sessions, and top_paths use the requested window. first_seen and last_seen use every stored $error for that fingerprint. Groups with no event in the window are omitted. Every 200 includes approximate. It is true when a scan cap is hit, and the body then also includes caps, an array of distinct_triples (first_seen used at most 5,000 distinct message, source, and line triples) and window_rows (the newest 50,000 in-window rows). approximate is false when the scan finishes inside both caps, and caps is omitted. There is no cap field.

When --new-since is a YYYY-MM-DD, a group is new when its earliest event’s UTC date is on or after that date. When --new-since is an annotation title, the match order is exact title, then case-insensitive title, then note, then substring, and the group is new when its earliest event’s full UTC timestamp is at or after that annotation’s occurred_at. Zero matches, or more than one match, is 400. More than one match lists matches. The group boolean and the resolved date are present only when --new-since is set. new_since_annotation is present only for an annotation match.

Terminal window
npx --yes @agent-analytics/cli@0.5.41 errors my-site --since 7d --new-since 2026-11-12

The MCP tool is errors, with project, since, until, new_since, and limit. See $error.

One subject per request, on all plans. Erasure needs manage or admin. --confirm erase is required. When --idempotency-key is omitted, the CLI generates one and prints it. When the level is too low, the command prints a clear hint to use manage or admin. A legacy session keeps its stored scopes. erasures:write is what manage and admin expand to for this route.

Terminal window
aa erase my-site --user-id user_123 --confirm erase
aa erase my-site --session-id sess_123 --confirm erase
aa erase my-site --email visitor@example.com --confirm erase
aa erasures my-site
aa erasures get era_01HZX

See Subject erasure.