Skip to main content

Authentication

Billbora uses a hybrid authentication system designed for both server-to-server integrations and frontend applications. This guide covers all authentication methods and best practices.

Authentication Methods

API Keys

Simple authentication for server-to-server integrations

JWT Tokens

Secure authentication for frontend applications with organization context

API Keys

API keys are the simplest way to authenticate with the Billbora API, ideal for server-to-server integrations.

Getting API Keys

1

Log into Billbora

Navigate to app.billbora.com and log in.
2

Go to API Settings

Navigate to SettingsAPICredentials.
3

Generate API Key

Click Generate New API Key and copy the generated key.
Store this key securely - it won’t be shown again!

Using API Keys

Include your API key in the Authorization header with the Bearer scheme:

API Key Security

  • Store API keys in environment variables, never in code
  • Use different keys for different environments (development, staging, production)
  • Rotate keys regularly (every 90 days recommended)
  • Monitor API key usage in your dashboard
  • Revoke compromised keys immediately
  • Each organization can have multiple API keys
  • Keys can be scoped to specific permissions
  • Usage analytics are available per key
  • Keys can be temporarily disabled without deletion

JWT Authentication

JWT authentication is designed for frontend applications and provides organization context switching capabilities.

Authentication Flow

The JWT authentication flow involves multiple steps:

Step 1: Supabase Authentication

First, authenticate with Supabase to get the initial JWT token:

Step 2: Token Exchange

Exchange the Supabase token for a Billbora token with organization context:

Step 3: Using JWT Tokens

Use the Billbora JWT token for API requests:

Token Refresh

JWT tokens expire after 1 hour. Use the refresh token to get a new access token:

Organization Context

One of the key features of Billbora’s authentication system is organization context switching.

Switching Organizations

Users can belong to multiple organizations and switch between them:

Getting Available Organizations

Fetch organizations the current user has access to:

Error Handling

Handle authentication errors gracefully:
  • invalid_credentials: Wrong email/password combination
  • token_expired: JWT token has expired, refresh needed
  • invalid_token: Malformed or invalid token
  • organization_access_denied: User doesn’t have access to requested organization
  • rate_limited: Too many authentication attempts

Security Best Practices

Token Storage

  • Store tokens securely (not in localStorage for sensitive apps)
  • Use httpOnly cookies for web applications when possible
  • Clear tokens on logout
  • Implement token expiration checking

Network Security

  • Always use HTTPS in production
  • Implement proper CORS policies
  • Validate SSL certificates
  • Monitor for unusual authentication patterns

Application Security

  • Implement proper session management
  • Use secure password requirements
  • Enable two-factor authentication
  • Implement account lockout policies

Monitoring

  • Monitor authentication failures
  • Set up alerts for suspicious activity
  • Regularly audit API key usage
  • Implement request rate limiting

Complete Authentication Example

Here’s a complete example of implementing authentication in a React application:

Next Steps

Frontend Integration

Learn how to integrate authentication in your frontend application

API Reference

Complete authentication API reference

Organization Management

Learn about multi-tenant organization features

Security Guide

Advanced security practices and configurations