API Key Authentication
API keys are passed in theX-API-Key header with each request:
Authenticated Request
The
X-API-Key header is required for all authenticated endpoints. Requests without a valid API key will receive a 401 Unauthorized response.How API Keys Work
Key Structure
FlexPrice API keys are:- 64-character hexadecimal strings (32 bytes encoded as hex)
- Generated using cryptographically secure random number generation
- Stored as SHA-256 hashes in the system for security
Your FlexPrice API key. This is a 64-character hexadecimal string that authenticates your requests.
Key Validation
When you make a request:- The API extracts the key from the
X-API-Keyheader - The key is hashed using SHA-256
- The hash is looked up in the configuration
- If found and active, the request is authenticated with the associated tenant and user context
Getting Your API Key
Development Environment
For local development, a default API key is provided in the setup:Default Development Key
Creating API Keys
You can create API keys through the FlexPrice dashboard or API:Managing API Keys
List API Keys
Retrieve all API keys for your account:List Keys
Delete API Keys
Revoke an API key immediately:Delete Key
Environment Context
API keys are associated with a specific tenant and environment. After authentication, the API automatically scopes all operations to the correct environment context.You can create separate API keys for production and development environments to maintain isolation and security.
Authentication Errors
The API returns specific errors for authentication issues:Missing API Key
Status Code:401 Unauthorized
Invalid API Key
Status Code:401 Unauthorized
Inactive API Key
Status Code:403 Forbidden
Best Practices
Security
Never commit API keys
Keep API keys out of version control. Use environment variables or secrets management systems.
.env file
Rotate keys regularly
Generate new API keys periodically and revoke old ones to minimize security risks.
Use environment-specific keys
Create separate API keys for development, staging, and production environments.
Integration
Alternative Authentication Methods
Customer Portal Sessions
For customer-facing portal access, use session tokens instead of API keys:Create Session
Webhook Authentication
Public webhook endpoints don’t require API keys but use other verification methods (signatures, tenant/environment IDs in the URL).Next Steps
Error Handling
Learn about API error codes and responses
API Overview
Understand the API structure and resources