Authentication
NextEVI supports multiple authentication methods for different use cases. Choose the method that best fits your application architecture and security requirements.Authentication Methods
API Key
Recommended for server-side applicationsSimple and secure for backend services and development
JWT Token
Recommended for client applicationsSecure user sessions with fine-grained permissions
API Key Authentication
Getting Your API Key
- Sign up at NextEVI Dashboard
- Create a new project
- Generate an API key from the project settings
- Copy your API key (starts with
oak_)
Using API Keys
API keys are passed as query parameters in the WebSocket URL:API Key Security
Best Practices:- Store API keys in environment variables
- Use different keys for development and production
- Rotate keys regularly
- Monitor usage in the NextEVI dashboard
JWT Token Authentication
When to Use JWT
JWT tokens are ideal for:- Client-side applications (React, mobile apps)
- User-specific sessions
- Multi-tenant applications
- Fine-grained permission control
Getting JWT Tokens
JWT tokens are obtained from your backend authentication system. Contact NextEVI support to set up JWT authentication for your account.Using JWT Tokens
JWT tokens can be passed via Authorization header or query parameter:- Query Parameter (Browser Compatible)
JWT Token Structure
NextEVI JWT tokens contain the following claims:Environment Setup
Development Environment
Create a.env file for local development:
Production Environment
Set environment variables securely in your production environment:Configuration Management
Project and Config IDs
- Project ID: Identifies your NextEVI project and billing account
- Config ID: Specifies voice model, language, and feature settings
- Navigate to your project
- Go to “Voice Configurations”
- Copy the Config ID for your desired setup
- Project ID is shown in the project settings
Dynamic Configuration
For multi-tenant applications, you can use different configs per user:Error Handling
Authentication Errors
Common authentication error codes:AUTH_REQUIRED (4001)
AUTH_REQUIRED (4001)
Cause: No authentication providedSolution: Include either
api_key query parameter or Authorization headerAUTH_FAILED (4001)
AUTH_FAILED (4001)
Cause: Invalid API key or expired JWT tokenSolution: Verify your credentials and check token expiration
CONFIG_NOT_FOUND (4004)
CONFIG_NOT_FOUND (4004)
Cause: Invalid config_id providedSolution: Verify your config_id in the NextEVI dashboard
PROJECT_ACCESS_DENIED (4003)
PROJECT_ACCESS_DENIED (4003)
Cause: API key or JWT doesn’t have access to specified projectSolution: Check project permissions in dashboard or regenerate credentials
Connection Retry Logic
Implement robust error handling with exponential backoff:Security Best Practices
API Key Security
- ✅ Store in environment variables, never in code
- ✅ Use different keys for dev/staging/production
- ✅ Rotate keys regularly (quarterly recommended)
- ✅ Monitor usage and set up alerts
- ❌ Never commit keys to version control
- ❌ Never expose keys in client-side JavaScript
JWT Token Security
- ✅ Use short expiration times (15-60 minutes)
- ✅ Implement proper token refresh flow
- ✅ Validate tokens server-side before use
- ✅ Use secure HTTP-only cookies when possible
- ❌ Never store tokens in localStorage
- ❌ Don’t include sensitive data in tokens
Connection Security
- ✅ Always use WSS (secure WebSocket)
- ✅ Implement connection timeout limits
- ✅ Validate all configuration parameters
- ✅ Log authentication events for monitoring
- ❌ Don’t retry forever on auth failures
- ❌ Never log credentials in error messages
Next Steps
WebSocket Connection
Learn how to establish WebSocket connections
React SDK Setup
Get started with the React SDK
