Documentation Index
Fetch the complete documentation index at: https://docs.mlm-platform.com/llms.txt
Use this file to discover all available pages before exploring further.
Authentication
All API requests to the MLM Platform require authentication using a tenant API key.API Key Format
API keys are passed in thex-tenant-api-key HTTP header:
Key Types
| Prefix | Environment | Usage |
|---|---|---|
mlm_live_ | LIVE | Production data |
mlm_sandbox_ | SANDBOX | Testing and development |
Creating API Keys
- Navigate to Settings > API Keys in the Admin Dashboard
- Click Create API Key
- Select the environment (LIVE or SANDBOX)
- Add an optional description
- 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
- Create a new API key
- Update your application to use the new key
- Verify the new key works
- 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 anX-Environment header:
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:| Response Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Requests remaining |
X-RateLimit-Reset | Unix timestamp when limit resets |
429 Too Many Requests response:
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
- User authenticates with your identity provider (IdP)
- Your app receives a JWT from your IdP
- Your app exchanges the JWT for MLM Platform tokens via
/api/v1/auth/exchange - 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:- Via the Admin UI - Navigate to Developers > External Auth Providers
- Via the API - Use
POST /api/v1/admin/auth/providers
Required Configuration
| Field | Description | Example |
|---|---|---|
| Provider ID | Unique identifier used in API calls | my-app |
| Issuer URL | OIDC issuer URL (must be HTTPS) | https://auth.example.com |
| JWKS URI | JSON Web Key Set endpoint | https://auth.example.com/.well-known/jwks.json |
| Allowed Audiences | Valid aud claim values | ["api://my-app"] |
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:| Provider | JWKS URI Format |
|---|---|
| Auth0 | https://YOUR_DOMAIN.auth0.com/.well-known/jwks.json |
| Okta | https://YOUR_DOMAIN.okta.com/oauth2/default/v1/keys |
| Azure AD | https://login.microsoftonline.com/YOUR_TENANT/discovery/v2.0/keys |
| Firebase | https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com |
| Cognito | https://cognito-idp.REGION.amazonaws.com/USER_POOL_ID/.well-known/jwks.json |
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):JWKS File Structure
Your JWKS file should look like this:Hosting Your JWKS
- Host the JWKS file at a publicly accessible HTTPS URL
- Ensure the URL returns
Content-Type: application/json - The endpoint must be accessible without authentication
- Consider caching headers for performance (keys don’t change often)
Token Exchange Example
Auto-Create Users
Whenauto_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.