Overview
All GlowBack API endpoints (except/healthz) require authentication via API key. The API supports multiple authentication methods for flexibility across different client types.
Setting up API keys
API keys are configured server-side via theGLOWBACK_API_KEY environment variable:
GLOWBACK_API_KEY is not set, the API runs in development mode without authentication (not recommended for production).
Authentication methods
Authorization header (Bearer token)
The recommended method for production applications:Bearer token in the format:
Bearer your-api-keyCustom header (X-API-Key)
A simpler alternative for internal tools and scripts:API key value
Query parameter (WebSocket)
Primarily for WebSocket connections where setting headers may be difficult:API key value in the query string
WebSocket authentication
WebSocket connections at/backtests/:run_id/stream support all three authentication methods:
Authentication priority
When multiple authentication methods are provided, the API checks them in this order:Authorizationheader (Bearer token)X-API-Keyheaderapi_keyquery parameter
401 Unauthorized response.
Error responses
Missing API key
If no API key is provided:401 Unauthorized
Invalid API key
If the provided API key doesn’t match any configured keys:401 Unauthorized
WebSocket authentication failure
WebSocket connections close immediately with code1008 Policy Violation if authentication fails.
Security best practices
Protect your API keys
- Never commit API keys to version control
- Use environment variables or secure secret management
- Rotate keys regularly
- Use different keys for development and production
Use HTTPS in production
Always use HTTPS in production to prevent API keys from being intercepted:Enable HSTS
The API includes Strict-Transport-Security headers to enforce HTTPS:Avoid query parameter authentication
Prefer header-based authentication to prevent keys from appearing in:- Server access logs
- Browser history
- Referrer headers
- Browser developer tools
Audit logging
All authentication attempts are logged for security auditing:request_id- Unique request identifier for correlationmethod- HTTP methodpath- Request pathclient_ip- Client IP addresskey_status-presentorabsent
Request correlation
Include anX-Request-ID header to correlate requests across logs:
Testing authentication
With authentication
Without authentication
Health check (no auth required)
Next steps
- Review Backtest endpoints to start making authenticated requests
- Check the REST API overview for general API information
- Explore the interactive API docs at
/docson your server