Overview
Manifest supports three authentication methods, implemented through a guard chain that runs on every request:- Session Authentication - Cookie-based sessions via Better Auth (for web dashboard)
- API Key Authentication - X-API-Key header for programmatic access
- Bearer Token Authentication - Agent API keys for OTLP ingestion and LLM proxy
SessionGuard- Validates Better Auth session cookiesApiKeyGuard- Falls through if no session, checks X-API-Key headerOtlpAuthGuard- Used only for/otlp/*and/v1/chat/completionsendpoints
Session Authentication
Session authentication uses Better Auth with cookie-based sessions. This is the primary method for the web dashboard.How It Works
Session Endpoints
GET /api/auth/get-session
Returns the current session and user information
POST /api/auth/sign-in/email
Sign in with email and password
POST /api/auth/sign-up/email
Register a new account with email and password
POST /api/auth/sign-out
Sign out and invalidate the session
GET /api/auth/sign-in/{provider}
Initiate OAuth flow (google, github, discord)
Session Response
Example Request
cURL
Fetch (Browser)
API Key Authentication
API key authentication provides programmatic access to analytics and management endpoints using theX-API-Key header.
Types of API Keys
Manifest supports two types of API keys:Database API Keys
Multi-tenant keys stored in the
api_keys table. Each key is associated with a user_id for data isolation. Keys are hashed using scrypt KDF and compared with timing-safe equality.Environment API Key
Single shared key from the
API_KEY environment variable. Used for simple single-tenant setups. Falls back after database lookup fails.How It Works
Creating API Keys
API keys are created through the dashboard or by setting theAPI_KEY environment variable.
Example Request
cURL
Fetch
Python
Security Features
API keys are compared using
timingSafeEqual() to prevent timing attacks. Buffers are padded to the same length before comparison.Database API keys are hashed using scrypt KDF with the following parameters:
- Cost factor (N): 16384
- Block size (r): 8
- Parallelization (p): 1
- Key length: 32 bytes
- Salt: Derived from the key itself
Bearer Token Authentication
Bearer token authentication is used exclusively for OTLP ingestion and the LLM routing proxy. Tokens are agent-specific API keys with themnfst_ prefix.
Agent API Keys
Agent API keys are generated when creating an agent and stored in theagent_api_keys table.
mnfst_ followed by a cryptographically secure random stringKeys are hashed using scrypt KDF. The plaintext key is only shown once during creation.
Each key is scoped to a specific tenant, agent, and user for strict data isolation.
Valid keys are cached in-memory for 5 minutes (300 seconds) to reduce database load.
How It Works
Database Lookup
If not cached, queries
agent_api_keys table with key hash, includes joins to agents and tenants tablesIngestion Context
Successful authentication populates the ingestion context:Example Request
OTLP Traces
LLM Proxy
Node.js
Managing Agent Keys
GET /api/v1/agents/:name/key
Retrieve the current agent API key (returns prefix only, not full key)
POST /api/v1/agents/:name/rotate-key
Rotate the agent API key. Returns the new plaintext key (only time it’s shown).
Local Mode Authentication
In local mode (MANIFEST_MODE=local), authentication is simplified for single-user development:
Better Auth is disabled. The
LocalAuthGuard trusts all requests from loopback IPs (127.0.0.1, ::1, ::ffff:127.0.0.1) and injects a static local user.The
OtlpAuthGuard bypasses Bearer token validation for loopback connections. Accepts any token (including dev-mode dummy tokens like Bearer dev-no-auth).Local Session Endpoint
Request
Response
Public Endpoints
Some endpoints skip authentication using the@Public() decorator:
GET /api/v1/health
Health check endpoint
GET /api/v1/github/stars
GitHub star count (public badge endpoint)
ALL /api/auth/*
Better Auth endpoints (login, register, OAuth callbacks)
Error Responses
Missing Authentication
X-API-Key Required
Bearer Token Required
Invalid Credentials
Invalid API Key
Expired Key
Forbidden Access
Local Mode (Non-Loopback)
Security Best Practices
Secure Storage
Never commit API keys or agent tokens to version control. Use environment variables or secure secret management.
Key Rotation
Rotate agent API keys regularly, especially after team member changes or suspected exposure.
Least Privilege
In multi-tenant setups, create separate API keys per service or application for easier revocation and auditing.
Environment Variables
Authentication-related environment variables:Secret for Better Auth session signing. Must be at least 32 characters. Generate with:
openssl rand -hex 32Base URL for Better Auth callbacks. Defaults to
http://localhost:{PORT}Shared API key for programmatic access (fallback if database key not found)
Set to
local to enable local mode authentication (loopback bypass)Google OAuth client ID (optional, enables Google sign-in)
Google OAuth client secret (required if client ID is set)
GitHub OAuth client ID (optional, enables GitHub sign-in)
GitHub OAuth client secret (required if client ID is set)
Discord OAuth client ID (optional, enables Discord sign-in)
Discord OAuth client secret (required if client ID is set)
Next Steps
API Overview
Return to API introduction and base concepts
Agent Management
Create and manage agents with API keys
OTLP Ingestion
Send telemetry data using agent API keys
LLM Routing
Use the LLM proxy with Bearer authentication