# Quickstart

## 1. Create a workspace (no signup)

Enter your domain on the home page and click "Start tracking". The system creates a persistent anonymous workspace, a secure session and your first site, and shows the recovery key **only once**. Save it in a password manager; it cannot be recovered if lost.

Programmatic creation (suitable for scripts running in a trusted environment):

```bash
curl -sS -X POST https://openstatx.com/api/v1/workspaces \
  -H 'content-type: application/json' \
  -d '{"domain":"example.com","client":"programmatic"}'
```

The `recovery_key` in the response must be handed to a human for safekeeping and must not end up in a chat transcript. The `bootstrap_token` is a restricted token valid for 1 hour; it can only add sites, fetch the install snippet and create read-only credentials.

## 2. Install the snippet

```html
<script defer src="https://openstatx.com/tracker.js" data-site="PUBLIC_SITE_ID"></script>
```

- Default basic privacy mode: no persistent visitor identifier and no cookies. UV is an estimate: the server hashes IP+UA with a random daily salt; raw IP/UA are never stored, the salt rotates daily and is deleted after 2 days. People sharing a network and browser merge, and multi-day UV runs high. Sessions, returning visits and the visitor list require consented mode.
- Single-page apps are tracked automatically via pushState / replaceState / popstate; hash routing can be enabled in site settings.
- Sites migrating from a legacy analytics snippet can enable the `_czc` compatibility layer in settings (see [_czc compatibility](/docs/czc)).

## 3. View reports

The dashboard's "Site overview" shows the browser ledger (PV, UV, sessions, bounce rate) and the HTTP ledger (requests, AI, automation). Every page offers "View API" / "Copy AI query".

## 4. Read via the API

Create a read-only credential under "Workspace → API credentials" (only `summary:read` by default), then:

```bash
curl -sS https://openstatx.com/api/v1/sites -H "authorization: Bearer $OPENSTATX_TOKEN"
curl -sS "https://openstatx.com/api/v1/sites/$SITE_ID/overview?preset=last_7_days" -H "authorization: Bearer $OPENSTATX_TOKEN"
```

All credentials in these examples are read from environment variables (`OPENSTATX_TOKEN`). Never hand your workspace recovery key to an AI or put it in a script.

## 5. Connect AI (MCP)

Add `https://openstatx.com/mcp` as a Remote MCP server. Clients that support custom request headers can use `Authorization: Bearer stk_...` directly; generic clients use OAuth authorization code + PKCE and choose permissions and sites on the consent page. See [MCP integration](/docs/mcp).
