Session cookies
When you sign in through the web app, Better Auth sets a session cookie (better-auth.session_token). This cookie is sent automatically with requests from the browser.
API keys
For programmatic access and MCP integrations, use an API key. Keys are prefixed withkm_ and passed as a Bearer token:
Generating a key
- Go to Settings > API keys in the Kommit dashboard
- Click Generate key
- Copy the key — it’s shown once and cannot be retrieved later
Middleware flow
Every authenticated request goes through two middleware steps:requireAuth— validates the session or API key. Returns401 Unauthorizedif missing or invalid.resolveTenant— maps the authenticated user to an organization. Returns403 Forbiddenif the user has no org membership.