# OffMedian Agent Authentication Specification

Origin: https://offmedian.com

## Obtaining a Personal Bearer Key

1. Sign in at https://offmedian.com/agent using Google OAuth or a 6-digit email verification code.
2. Create a personal API key (`om_live_` followed by 48 lowercase hex characters; maximum 1 active key on Free, 5 on Pro, 10 on Enterprise).
3. Copy the plaintext key immediately upon creation (stored server-side as a SHA-256 digest) and revoke unused keys anytime at `/agent`.

## Sending Credentials

- Send `Authorization: Bearer om_live_...` in HTTP request headers.
- Pass credentials strictly via the `Authorization` header; keep keys out of URL query parameters and source repositories.
- Authenticated `GET /api/v1/*` responses return `Cache-Control: private, max-age=30`, `Vary: Authorization`, and weak `ETag` supporting `If-None-Match` -> `304 Not Modified`.

## Public vs. Authenticated Endpoints

### Public (No Bearer Key Required)
- Public HTML & `Accept: text/markdown` routes (`/`, `/daily`, `/playbooks`, `/domains`, `/domains/{domain}`, `/guides`, `/guides/{slug}`, `/topics`, `/creators`, `/kol/{handle}`, `/perks`, `/opportunities`, `/badge`, `/changelog`, `/compare`, `/compare/{slug}`, `/agent`, `/about`, `/methodology`, `/privacy`, `/terms`, plus `/zh/*`)
- Discovery & schema documents: `/llms.txt`, `/llms-full.txt`, `/openapi.json`, `/skill.md`, `/auth.md`, `/.well-known/api-catalog`, `/.well-known/ai-catalog.json`, `/.well-known/mcp/server-card.json`, `/.well-known/agent-skills/index.json`
- Syndication & status: `/robots.txt`, `/sitemap.xml`, `/daily/feed.xml`, `/daily/feed.json`, `/feed.json`, `GET /mcp` (metadata), `GET /api/health`, `GET /api/v1/badge/kol/{handle}`
- Community submissions & voting: `POST /api/v1/creators/submit`, `POST /api/v1/perks`, `POST /api/v1/perks/vote`, `POST /api/v1/opportunities/vote`, `POST /api/v1/newsletter/subscribe`

### Authenticated (`Authorization: Bearer om_live_...` Required)
- `GET /api/v1/hot-posts` (supports `?following=true` with a personal `om_live_` key)
- `GET /api/v1/topics`
- `GET /api/v1/creators` (supports `?following=true` with a personal `om_live_` key)
- `GET /api/v1/creators/{handle}`
- `GET /api/v1/daily`
- `GET /api/v1/perks`
- `GET /api/v1/opportunities`
- `POST /mcp` (Streamable HTTP JSON-RPC 2.0, max request body 65,536 bytes)

### Web Session Authenticated (Signed-In Session Cookie + Same-Origin)
- Personal library endpoints: `GET /api/v1/library`, `GET /api/v1/library/state`, `POST|DELETE /api/v1/library/posts`, `POST|DELETE /api/v1/library/creators`
- Personal API key management: `GET|POST /api/auth/api-keys`, `DELETE /api/auth/api-keys/{id}`

## Rate Limits, Quotas & Error Contract

- **Free plan** (default): 1 active key; `6 req/min` on lists, digests & `POST /mcp` (`3 req/min` on creator profiles); `30 req/day` per user (up to `8` creator profiles/day, IP aggregate `60 req/day` / `15` profiles/day); `400 req/month` UTC; `24h` & `7d` windows; `limit <= 10` (`hot-posts`, `creators`) or `<= 15` (`perks`, `opportunities`); latest 3 daily issues; `verbosity=compact` only; no `cursor` pagination.
- **Pro plan**: 5 active keys; `60 req/min` (`30 req/min` on profiles); `1,000 req/day` (`200` profiles/day); `20,000 req/month` UTC; `30d` window, full payloads, and cursor pagination.
- **Enterprise plan**: 10 active keys; `120 req/min` on lists, digests & `POST /mcp` (`60 req/min` on profiles); `5,000 req/day` (`1,000` profiles/day); `100,000 req/month` UTC; `30d` window, full payloads, cursor pagination, and expanded page limits (`100` lists / `200` creators).
- **Service tokens**: `600 req/min` on lists & digests; `300 req/min` on profiles & `POST /mcp`.
- **Non-billable MCP control methods**: `initialize`, `ping`, `tools/list`, `resources/list`, `notifications/*`, static `offmedian://domains` / `offmedian://methodology`, `resolve_date_range`, and ETag `304 Not Modified` responses do not deduct daily/monthly quotas.
- Public reads, Markdown negotiation, feeds, badges & discovery documents: `120 req/min` per IP (`60 req/min` for `GET /mcp` metadata).
- Community POST submissions (`creators/submit`, `perks`, `newsletter/subscribe`): `10 req/min` per IP; voting (`perks/vote`, `opportunities/vote`): `30 req/min` per IP.
- Missing, invalid, or revoked Bearer keys return HTTP `401` RFC 7807 Problem Details; plan-gated parameters (`window=30d`, `cursor`, `verbosity=full`, >3 daily issues) return HTTP `403` (`plan_upgrade_required`); rate-limited or quota-exhausted requests return HTTP `429` with `Retry-After`, `X-OffMedian-Plan`, `X-RateLimit-*`, and `X-Quota-*` headers.
