Skip to main content

Authentication

All API requests to the MLM Platform require authentication using a tenant API key.

API Key Format

API keys are passed in the x-tenant-api-key HTTP header:

Key Types

Never use LIVE keys in development or testing environments.

Creating API Keys

  1. Navigate to Settings > API Keys in the Admin Dashboard
  2. Click Create API Key
  3. Select the environment (LIVE or SANDBOX)
  4. Add an optional description
  5. Click Create
API keys are shown only once at creation. Store them securely.

Security Best Practices

Never Expose Keys Client-Side

API keys should only be used in server-side code:

Use Environment Variables

Store API keys in environment variables:

Rotate Keys Regularly

  1. Create a new API key
  2. Update your application to use the new key
  3. Verify the new key works
  4. Revoke the old key

Monitor Key Usage

Review API key usage in the Admin Dashboard:
  • Request counts
  • Error rates
  • Last used timestamp

Environment Detection

Every API response includes an X-Environment header:
or
Use this to verify you’re hitting the correct environment:
The environment is derived from the API key used for the request. You may include an X-Environment request header for debugging/explicitness, but the server will still derive the environment from the key. Always treat the response header X-Environment as authoritative.

Error Responses

Missing API Key

Invalid API Key

Revoked / Disabled API Key

Revoked/disabled keys are treated the same as invalid keys during validation.

Rate Limiting

API keys are subject to rate limiting: When rate limited, you’ll receive a 429 Too Many Requests response:
Handle rate limits gracefully:

External Auth Providers (OIDC Federation)

For applications with existing user authentication, you can configure external auth providers to enable federated authentication. This allows users authenticated by your identity provider to access MLM Platform features without creating separate credentials.

When to Use External Auth Providers

  • You have an existing user base with established authentication
  • You want single sign-on (SSO) between your app and the MLM Platform
  • You need to integrate MLM features into your existing application

How It Works

  1. User authenticates with your identity provider (IdP)
  2. Your app receives a JWT from your IdP
  3. Your app exchanges the JWT for MLM Platform tokens via /api/v1/auth/exchange
  4. User can now access MLM Platform APIs with the exchanged tokens

Setting Up an External Auth Provider

External auth providers are configured per tenant. You can set them up:
  1. Via the Admin UI - Navigate to Developers > External Auth Providers
  2. Via the API - Use POST /api/v1/admin/auth/providers

Required Configuration

Creating Your JWKS File

A JSON Web Key Set (JWKS) is a JSON file containing the public keys used to verify JWT signatures. The MLM Platform fetches this file to validate tokens from your identity provider.

Option 1: Use Your Identity Provider’s JWKS

Most identity providers (Auth0, Okta, Azure AD, Firebase, etc.) automatically expose a JWKS endpoint:

Option 2: Generate Your Own JWKS

If you’re signing JWTs yourself, you’ll need to generate a key pair and create a JWKS file. Using Node.js (jose library):
Using OpenSSL:

JWKS File Structure

Your JWKS file should look like this:

Hosting Your JWKS

  1. Host the JWKS file at a publicly accessible HTTPS URL
  2. Ensure the URL returns Content-Type: application/json
  3. The endpoint must be accessible without authentication
  4. Consider caching headers for performance (keys don’t change often)
Never include private keys in your JWKS file. Only public keys should be exposed.

Token Exchange Example

Auto-Create Users

When auto_create_users is enabled (default), users are automatically created in the MLM Platform on their first token exchange. The user’s email, name, and external ID are extracted from the JWT claims, so make sure these are correctly included in the JWT.
For detailed configuration options and troubleshooting, see the External Auth Providers Guide.