API reference
Every /api/v1/* endpoint requires a Bearer token checked against scoped tokens in api_tokens (with legacy READ_TOKEN fallback only when zero active token rows exist), rate-limited via API_LIMIT, and logged to api_audit_log.
Scoped authentication and rate limits#
Tokens carry one of three hierarchical scopes: read, write, or admin. Missing or invalid tokens return 401, insufficient scope returns 403, and throttled callers return 429.
$READ_TOKENexample.comcurl -sS -H "Authorization: Bearer $READ_TOKEN" https://example.com/api/v1/counts?days=7Read routes (TokenScope::Read)#
Bounded list endpoints return truncated: true whenever their query cap is reached (5,000 rows on views, 50,000 rows on internal, and 500 rows on posts).
Write routes (TokenScope::Write)#
Write endpoints accept Idempotency-Key headers persisted in D1 idempotency_keys. Replays return 200 with x-idempotent-replay: true; reusing the same key on a different route returns 409.
Auth, scope, and replay status codes#
Public beacon routes#
POST /api/hit, /api/engaged, and /api/events accept unauthenticated browser beacons with CORS headers and respond 204. Static beacon script lives at GET /visit.js.