Overview
The Cap API supports multiple authentication methods depending on your use case:- Session cookies - For web application
- Bearer tokens - For desktop app and API integrations
- Authorization headers - For custom domains and commercial licenses
Authentication Methods
Session Cookies (NextAuth)
The web application uses NextAuth.js for session management.Login Flow
- User navigates to login page
- Enters email address
- Receives magic link via email
- Clicks link to authenticate
- Session cookie is set automatically
Session Configuration
Sessions are configured inpackages/database/auth/auth-options.ts.
Default session duration: 30 days
Bearer Tokens
For programmatic access, use Bearer tokens in the Authorization header.Request Format
Desktop App Authentication
The desktop app stores authentication tokens securely:- macOS: Keychain
- Windows: Credential Manager
- Linux: Secret Service API
Authorization Headers
Some endpoints use custom authorization headers:Custom Domain Verification
License Activation
Protected Endpoints
Desktop Routes
All desktop routes require authentication:Video Endpoints
Video management endpoints require authentication:DELETE /video/deleteGET /video/analyticsGET /video/transcribe/status
Notification Endpoints
Notification endpoints require authentication:GET /notifications
Error Responses
401 Unauthorized
Returned when authentication is missing or invalid:403 Forbidden
Returned when the user lacks permissions:Obtaining Authentication Tokens
For Desktop App
The desktop app handles authentication automatically:- User clicks “Sign In”
- Opens browser to login page
- Completes authentication
- Token is sent back to desktop app
- Token stored securely in system keychain
For API Integrations
Currently, Cap does not provide public API tokens for third-party integrations. This feature is planned for future releases.Session Management
Check Session Status
For web sessions, NextAuth provides:Client-Side Session
Security Best Practices
Token Storage
Desktop Apps
Desktop Apps
Use platform-specific secure storage:
- macOS: Keychain Services
- Windows: Credential Manager
- Linux: libsecret/gnome-keyring
Web Apps
Web Apps
Use secure cookies:
- HttpOnly flag
- Secure flag (HTTPS only)
- SameSite=Lax or Strict
Server-Side
Server-Side
Store in environment variables:
- Never hardcode tokens
- Use
.envfiles (excluded from git) - Rotate tokens regularly
Commercial License Authentication
Activate License
packages/web-api-contract/src/index.ts:122-136 for full schema.
Testing Authentication
Test Authenticated Endpoint
Authentication Flow Diagram
Next Steps
Videos API
Learn about video endpoints
Notifications API
Learn about notification endpoints