Authentication Methods
Bearer Token Authentication
The primary authentication method is Bearer token authentication using theAuthorization header.
API Keys
Generate an API key from the Phoenix UI and include it in theAuthorization header:
API keys are long-lived credentials that provide programmatic access to the Phoenix API. Store them securely and never commit them to version control.
Access Tokens
For user-based authentication, Phoenix supports OAuth2-style access tokens with short expiration times. Access tokens can be obtained through the authentication flow and refreshed using refresh tokens.Admin Secret (System Access)
Phoenix supports a system admin secret configured via thePHOENIX_ADMIN_SECRET environment variable. This provides administrative access to all API endpoints:
Cookie-Based Authentication
For web applications, Phoenix supports cookie-based authentication using thephoenix-access-token cookie. This is primarily used by the Phoenix UI.
Authentication Examples
Python
Using therequests library:
Node.js
Usingfetch:
cURL
User Roles
Phoenix supports role-based access control with the following roles:- ADMIN: Full access to all resources and operations
- VIEWER: Read-only access to resources
Generating API Keys
Security Best Practices
Use Environment Variables
Use Environment Variables
Store API keys in environment variables, never hardcode them:
Rotate Keys Regularly
Rotate Keys Regularly
Generate new API keys periodically and revoke old ones to minimize security risks.
Use HTTPS in Production
Use HTTPS in Production
Always use HTTPS when accessing the Phoenix API in production to encrypt credentials in transit.
Limit Key Scope
Limit Key Scope
Generate separate API keys for different applications or services to limit the impact of a compromised key.
Unauthenticated Access
If authentication is not enabled in your Phoenix deployment, API requests can be made without authentication headers. However, this is not recommended for production deployments. Check if authentication is enabled by inspecting theauthentication_enabled flag in the server configuration.