# auth.md — iGregulator API authentication for agents

This document tells autonomous agents how to authenticate with the iGregulator
API and MCP server. iGregulator is an iGaming licensing-intelligence API + MCP
server. There are two credentials:

1. **Bearer API keys** — for the REST API and the MCP server. Issued to a person
   in the dashboard.
2. **OAuth 2.1 sign-in** — for MCP connectors (claude.ai, ChatGPT, Claude Code)
   on the signed-in MCP endpoint `https://mcp.igregulator.io/mcp/account`. The
   user signs in to their iGregulator account and approves the app.

The OAuth discovery documents describe the signed-in MCP endpoint only; the REST
API takes API keys.

## Audience

Agents (and the developers running them) that need machine-readable iGaming
operator-licence data: compliance/AML teams, payment providers, affiliate
networks, and investment-intelligence desks.

## Do I even need a credential?

No, to start. Public endpoints work **without credentials**, rate-limited to
**10 requests per IP per hour**. They cover licence verification, operator
search, and jurisdiction coverage. A key or a sign-in unlocks higher quotas,
per-operator detail, and regulatory-action history.

## Option 1 — API key (REST API and MCP)

1. Create an account at <https://app.igregulator.io/signup> and confirm your
   email address — sign-in waits for it. A new account has no plan: start one
   on its **Billing** page. Starter (10,000 requests/month) starts with a
   14-day free trial — a card is required, charged on day 15 unless cancelled;
   no sales contact.
2. Generate a key under **API keys**: <https://app.igregulator.io/api-keys>.
   It is shown once — copy it then.
3. Store it securely. Keys are long-lived bearer tokens; treat them as secrets.

Keys are provisioned interactively in the dashboard; there is no endpoint that
issues an API key programmatically.

Send the key as a bearer token on every request:

```
Authorization: Bearer YOUR_API_KEY
```

- **REST base URL:** `https://api.igregulator.io` (OpenAPI:
  <https://api.igregulator.io/openapi.json>)
- **MCP server:** `https://mcp.igregulator.io/mcp` (Streamable HTTP; same bearer
  key, see <https://igregulator.io/docs/mcp/>). The key is optional there: without
  one, `check_domain`, `search_operators`, `list_jurisdictions` and
  `check_coverage` work at 10 requests per IP per hour; the other tools need a
  key. `https://mcp.igregulator.io/mcp/account` accepts the same key.

## Option 2 — Sign in with OAuth (MCP connectors)

- **Connector URL:** `https://mcp.igregulator.io/mcp/account` (Streamable HTTP).
  Without a token it answers `401` with
  `WWW-Authenticate: Bearer resource_metadata="https://mcp.igregulator.io/.well-known/oauth-protected-resource/mcp/account", scope="mcp:read"`.
- **Protected Resource Metadata (RFC 9728):**
  <https://mcp.igregulator.io/.well-known/oauth-protected-resource/mcp/account>
  (also at `/.well-known/oauth-protected-resource`).
- **Authorization server:** issuer `https://app.igregulator.io/api/auth`;
  metadata (RFC 8414) at
  <https://app.igregulator.io/.well-known/oauth-authorization-server/api/auth>.
- **Client registration:** Dynamic Client Registration (RFC 7591) at
  `https://app.igregulator.io/api/auth/oauth2/register`. Redirect URIs must be
  `https`, or `http` on `localhost` / `127.0.0.1` / `[::1]` for native apps (any
  port). Public clients register `token_endpoint_auth_method: "none"`.
- **Flow:** authorization code with PKCE (`S256` only), `resource=https://mcp.igregulator.io/mcp/account`
  (RFC 8707), `scope=mcp:read`. A refresh token (`offline_access`) is granted
  with it. The authorization response carries `iss` (RFC 9207).
- **Tokens:** opaque access tokens, valid one hour; refresh tokens rotate on
  every use, and a reused one revokes the whole grant. Refresh tokens expire
  after 30 days without use.
- **What it grants:** read-only licence lookups — all ten MCP tools — on the
  user's plan, counted against their monthly quota exactly as an API key's
  calls are. Not the REST API directly, not watchlists, webhooks or export.

A person signs in and approves every connection on `app.igregulator.io`; there
is no agent self-registration endpoint. The user can revoke any connected app at
<https://app.igregulator.io/api-keys#connected-apps>; its tokens stop working on
the next request.

## Rate limits & errors

- Unauthenticated: 10 req/IP/hour. Authenticated tiers raise this — see
  <https://igregulator.io/docs/rate-limits/>.
- `401` means a missing/invalid key or token; `429` means you exceeded a limit.
  Branch on `code` + `details.reason` (<https://igregulator.io/docs/errors/>):
  the keyless hourly cap resets at `X-RateLimit-Reset` (Unix epoch seconds), the
  monthly quota at `details.reset_at`; only the per-second limit and the daily
  export limit send `Retry-After`. `402 payment_required` means the account has
  no active plan (`plan_inactive`) or its plan's end date has passed
  (`plan_ended`).

## More

- API docs: <https://igregulator.io/docs/>
- MCP server and connectors: <https://igregulator.io/docs/mcp/>
- For-AI-agents guide: <https://igregulator.io/docs/for-ai-agents/>
- Authentication guide: <https://igregulator.io/docs/authentication/>
