Skip to main content
Fanfare uses different authentication methods depending on the API and use case.

API Keys

Every organization has two types of API keys, which you can find and manage — alongside your organization ID — in your dashboard under Settings → Developer → API keys:

Publishable Key

  • Format: pk_live_xxxxxxxxxxxx or pk_test_xxxxxxxxxxxx
  • Usage: Client-side code (browsers, mobile apps)
  • Permissions: Read-only access to public resources, consumer session creation
  • Security: Safe to expose in client-side code

Secret Key

  • Format: sk_live_xxxxxxxxxxxx or sk_test_xxxxxxxxxxxx
  • Usage: Server-side code only
  • Permissions: Full API access including write operations
  • Security: Must be kept confidential, never expose in client-side code
  • Where to find it: Your dashboard under Settings → Developer → API keys. For security, the full secret key is shown only once — right after you rotate it. Rotating immediately invalidates the previous key, so roll it on your server when you rotate.

Authentication Methods

Consumer API - Browser (Publishable Key)

For browser-based consumer interactions, use the publishable key in the X-Publishable-Key header:

Consumer API - Authenticated Consumer

After a consumer authenticates (via OTP, external auth, etc.), use the access token:

Consumer API - Server-Side (Secret Key)

For server-to-server calls to the Consumer API, use the secret key:

Admin API (Secret Key Required)

All Admin API calls require the secret key:

Consumer Authentication Flows

Guest Session

Create an anonymous session for tracking purposes:
Response:

OTP Authentication (Email)

Request a one-time password:
Verify the OTP:

OTP Authentication (Phone)

Request an SMS code:
Verify the code:

External Authentication (Server-Side)

For integrating with your existing authentication system. See the External Authentication guide for the full contract, including identity consolidation via canonicalSubject: Step 1: Create exchange code (server-side)
Response:
Step 2: Exchange code for session (client-side)

Token Refresh

Refresh an expired access token:
Response:

Logout

Invalidate the current session:

Token Structure

Access tokens are JWTs containing:

Token Lifetimes

Security Best Practices

  1. Never expose secret keys in client-side code, version control, or logs
  2. Rotate keys regularly using the Admin dashboard
  3. Use environment variables for storing keys in server-side applications
  4. Implement token refresh to maintain sessions without re-authentication
  5. Use HTTPS for all API communications (enforced by Fanfare)

Error Responses

Invalid Credentials

Expired Token

Invalid OTP

Secret Key Required