# Auth & Scopes
> Bearer token formats, server-side RLS resolution, permission scopes, and instant key revocation.
Source URL: /docs/guide/auth-and-scopes

Every authenticated `/api/v1/in/*` endpoint expects a standard HTTP `Authorization` header with a `vdh_live_` or `vdh_test_` token:

```http
Authorization: Bearer vdh_live_<32_hex>
```

## Security Model [#security-model]

- **Server-side SHA-256 lookup**: `DevAPIAuth` hashes the incoming Bearer token with SHA-256, checks Redis `devkey:<hash>` (`30s` TTL), and falls back to the `SECURITY DEFINER` PostgreSQL function `public.resolve_api_key_by_hash(p_hash)` so `api_keys` remains protected by `FORCE ROW LEVEL SECURITY`.
- **No tenant header spoofing**: Callers must never send `X-Firm-ID`. Any supplied `X-Firm-ID` header is ignored by `/api/v1/in/*`; tenant firm context comes solely from the resolved API key.
- **Instant revocation**: Revoking or rotating a key immediately clears `devkey:<hash>` in Redis; subsequent calls fail with HTTP `401` (`key_revoked`).
- **Public discovery**: `GET /api/v1/in/coverage` works with or without a Bearer token, and `GET /api/v1/in/pricing` is completely public.

## Permission Scopes [#permission-scopes]

Keys carry an explicit scope array. Missing scopes fail fast with HTTP `403` (`insufficient_scope`) and zero credit deduction.

| Scope | Grants Access To |
|---|---|
| `corpus:read` | `GET /courts`, all `/cases/*` endpoints, all `/citations/*` endpoints, all `/statutes/*` endpoints, and `/regulatory/*` |
| `ai:run` | Core Tier B reasoning engines: `/verify/brief`, `/audit/order`, `/audit/counter-precedent`, `/research/memo`, `/notices/analyze`, `/contracts/triage`, `/compliance/redact-firewall` |
| `translate:read` | `GET /api/v1/in/translation/languages` |
| `translate:write` | `POST /api/v1/in/translation/text` |
| `mcp:connect` | Required in addition to underlying `corpus:read` / `ai:run` scopes when calling `https://vidhi-mcp.shamik.app/mcp` |

<LegalBoundaryNote title="Test Keys vs. Live Keys" tone="amber">
<code>vdh_test_</code> keys execute against the exact same API contracts and rate-limit headers as <code>vdh_live_</code> keys, using isolated test allowances provisioned for your Cohort 1 account. Never embed either key prefix in client-side browser bundles.
</LegalBoundaryNote>