# Start with the API

1. **Make an API key.** Sign in at `https://staging.countwatch.com/login` and open the dashboard. A **write** key only sends data: put it in your app's secrets as `COUNTWATCH_API_KEY`. An **admin** key manages the account: use it for scripts and CI. A key is shown once; you can name and revoke each one. Send it as `Authorization: Bearer <key>`. An agent connected over MCP needs no key: it signs in with your e-mail and works through its tools.
2. **Send a count.** A watch is one metric plus its dimensions; the first point creates it.

   ```
   curl -X POST https://staging.countwatch.com/v1/ingest \
     -H "Authorization: Bearer $COUNTWATCH_API_KEY" -H "Content-Type: application/json" \
     -H "Idempotency-Key: $(uuidgen)" \
     -d '{"points":[{"metric":"orders","dimensions":{"shop":"eu"},"add":3}]}'
   ```
3. **Choose where alerts go.** Turn on e-mail alerts in the dashboard, or add a webhook, Slack or PagerDuty (`POST /v1/destinations`, then `POST /v1/destinations/{id}/verify`). Without a public address, read them with `GET /v1/alerts?since=…`.
4. **Skip the wait.** A new watch learns your pattern for about 3 weeks (`learning: true`, `learning_until`); simple starter rules alert meanwhile. Import past counts (`POST /v1/import`) and alerts start now.

Errors follow RFC 9457 (problem details): each has a stable `code`, a fix page linked from its `type`, and a `Request-Id` to quote when you write to us. A rejected point carries `{index, code, field, detail}`.
