Skip to main content

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

  1. Sign up at NextEVI Dashboard
  2. Create a new project
  3. Generate an API key from the project settings
  4. Copy your API key (starts with oak_)

Using API Keys

API keys are passed as query parameters in the WebSocket URL:

API Key Security

Never expose API keys in client-side codeAPI keys provide full access to your account and should only be used in secure server environments.
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:

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
Both are obtained from the NextEVI Dashboard:
  1. Navigate to your project
  2. Go to “Voice Configurations”
  3. Copy the Config ID for your desired setup
  4. 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:
Cause: No authentication providedSolution: Include either api_key query parameter or Authorization header
Cause: Invalid API key or expired JWT tokenSolution: Verify your credentials and check token expiration
Cause: Invalid config_id providedSolution: Verify your config_id in the NextEVI dashboard
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