Skip to Content
Vidhi Developers
Guide

Auth & Scopes

Bearer token formats, server-side RLS resolution, permission scopes, and instant key revocation.

Open Markdown

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

Authorization: Bearer vdh_live_<32_hex>

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

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

ScopeGrants Access To
corpus:readGET /courts, all /cases/* endpoints, all /citations/* endpoints, all /statutes/* endpoints, and /regulatory/*
ai:runCore Tier B reasoning engines: /verify/brief, /audit/order, /audit/counter-precedent, /research/memo, /notices/analyze, /contracts/triage, /compliance/redact-firewall
translate:readGET /api/v1/in/translation/languages
translate:writePOST /api/v1/in/translation/text
mcp:connectRequired in addition to underlying corpus:read / ai:run scopes when calling https://vidhi-mcp.shamik.app/mcp

On this page