Overview
LibreChat supports two authentication methods:- JWT Authentication: Session-based authentication for web applications
- API Keys: Token-based authentication for programmatic access
JWT Authentication
JWT (JSON Web Token) authentication is the primary method for web applications.Login
Obtain a JWT token by authenticating with credentials:Request Body
User’s email address
User’s password
Response
JWT access token
User information including id, email, name, and role
Using JWT Tokens
Include the JWT token in theAuthorization header:
Refresh Token
Refresh an expired JWT token:Set to
true to retry refreshResponse
Logout
Invalidate the current session:Registration
Create a new user account:Request Body
User’s email address (must be unique)
Password (minimum 8 characters)
User’s full name
Username (optional)
Password confirmation (if required by server configuration)
Password Reset
Request Password Reset
Send a password reset email:Email address of the account to reset
Reset Password
Reset password with token from email:User ID from reset email
Reset token from email
New password
Two-Factor Authentication (2FA)
Enable 2FA
Enable two-factor authentication for your account:Response
QR code data URL for authenticator app
TOTP secret for manual entry
One-time backup codes for account recovery
Verify 2FA Code
Verify a TOTP code from authenticator app:6-digit TOTP code from authenticator app
Confirm 2FA Setup
Confirm and activate 2FA:Disable 2FA
Disable two-factor authentication:Regenerate Backup Codes
Generate new backup codes:Verify with Temp Token
Verify 2FA during login flow:Temporary token received during login
6-digit TOTP code or backup code
API Keys
API keys provide programmatic access to LibreChat for agents and integrations.Create API Key
Create a new API key for agent access:Descriptive name for the API key
ISO 8601 expiration date (optional)
Response
The API key (only shown once)
Unique identifier for this key
Name of the API key
Creation timestamp
List API Keys
Retrieve all API keys for your account:Response
Get API Key
Retrieve details of a specific API key:API key ID
Delete API Key
Revoke an API key:API key ID to delete
Using API Keys
Include the API key in theAuthorization header:
OAuth / Social Login
LibreChat supports OAuth authentication providers:Google OAuth
Initiate Google OAuth flow:Facebook OAuth
Initiate Facebook OAuth flow:Graph Token (Microsoft)
Obtain Microsoft Graph API token:Space-separated Microsoft Graph scopes
Response
Security Best Practices
- Never share your JWT tokens or API keys
- Use HTTPS in production to prevent token interception
- Rotate API keys regularly
- Enable 2FA for additional account security
- Set API key expiration dates for temporary integrations
- Store tokens securely (use httpOnly cookies for web apps)
- Validate all inputs on the client side before sending