# Quickstart

## 1. A key

```
curl -s -X POST https://api.butlrs.ai/v1/keys/free -H 'content-type: application/json' \
  -d '{"email": "you@example.com", "client_nonce": "6f1c0a2e-…"}'
```

`client_nonce` is any UUID you generate and keep. The key is shown once; within 10 minutes of
issuance the same email and the same nonce return the same key again (a lost response, a
retry). After that the route answers 409 `key_exists`: use the key you were given. A few keys
per address per day.

## 2. The feed

A feed needs a scope: one `app_id`, one `developer_id`, or corpus-wide with `event_types`.

```
curl -s 'https://api.butlrs.ai/v1/changes?event_types=price_changed,version_released&limit=100' \
  -H 'authorization: Bearer btl_…'
```

Every event has `event_id` (a ULID), `event_type`, `observed_at`, the entity and `served`:
`ok` events carry a typed `payload`; `withheld` events carry no payload and a
`withheld_reason` instead (a value outside the projection's bounds). Keep `meta.next_cursor`
and pass it back as `since_cursor` to continue, across runs too; an empty first page carries
no cursor (start again later). Corpus-wide `event_types` feeds and single-app feeds are exact:
no gaps, no repeats, no reordering, whatever your polling pattern; `app_category` and
`developer_id` feeds are a view over current attributes.

## 3. The state behind an event

```
curl -s https://api.butlrs.ai/v1/apps/1234567890 -H 'authorization: Bearer btl_…'
```

The card says when the app was last observed; `meta.snapshot` says which serving export
answered.

## 4. Idempotency

Send `Idempotency-Key: <uuid>` on any call. A repeat within 24 h with the same key and the same
arguments replays the stored response, charged once. Different arguments under the same key are
rejected (`idempotency_conflict`). A response with `meta.charged_units: null`
(`settlement_unknown`) is resolved by repeating the call with the same key.

## 5. From an agent

The hosted MCP server exposes the same eight tools; see [MCP](/docs/mcp.md). From Python:

```python
import httpx
r = httpx.get("https://api.butlrs.ai/v1/changes", params={"app_id": "1234567890"},
              headers={"authorization": "Bearer btl_…"})
body = r.json()
events, cursor = body["data"]["events"], body["meta"].get("next_cursor")  # None: nothing yet
```

## Limits

Each call class has a deadline and, on the lake engine, a read ceiling; a call that would exceed
its ceiling is rejected before it runs (`plan_too_large`, the remediation says what to narrow).
Lists close a page early at 256 KiB (`meta.truncated`); continue from `meta.next_cursor`.
