Skip to main content

Authentication

TalkifAI Studio uses Better Auth for authentication.

Supported Methods

Email Normalization

To prevent duplicate accounts, all emails are normalized on registration:

Multi-Tenant Isolation

TalkifAI is a multi-tenant SaaS. Every data operation is scoped to an organization.

Isolation Model

Critical rules:
  1. Every DB query must filter by organizationId
  2. Session context includes activeOrganizationId
  3. API keys are scoped to a single organization
  4. Cross-tenant data leaks are prevented at the query level

Role-Based Access Control


Credential Encryption

All sensitive credentials are encrypted with Fernet symmetric encryption before database storage.

What’s encrypted

Fernet Encryption

Never rotate the FERNET_KEY after it’s been set. If the key changes, all stored encrypted credentials become unreadable. If you must rotate, you must re-encrypt all stored credentials first.

API Security

API Key Authentication

  • Keys are stored as hashed values in the database (not plain text)
  • Keys use sk_live_ prefix for production, sk_test_ for sandbox
  • Invalid or revoked keys immediately return 401 Unauthorized

Rate Limiting

All API endpoints are rate-limited:

CORS

The Studio API has strict CORS configuration:
  • Only requests from studio.talkifai.dev are allowed by default
  • Marketing site API has additional API key + origin validation (dual authentication)

LiveKit Token Security

When generating LiveKit tokens for voice sessions:

Security Checklist for Developers

When building integrations with TalkifAI:
  • Store API keys in environment variables, never in code
  • Use HTTPS for all webhook endpoints
  • Verify webhook signatures before processing events
  • Rotate API keys every 90 days
  • Use the test environment (sk_test_) for development
  • Never log API keys, SIP passwords, or credentials
  • Monitor API key activity for unusual patterns