Environment Configuration
The WispHub API uses environment variables for configuration, managed through Pydantic Settings. This approach provides type safety, validation, and flexible configuration sources.Configuration File
All configuration is centralized inapp/core/config.py:
app/core/config.py
Environment Variables
Required Variables
These variables must be set for the API to function:WISPHUB_NET_KEY
WISPHUB_NET_KEY
Type: Security: Never commit this to version control. Keep it in
strPurpose: API key for authenticating with WispHub NetExample:.env which should be in .gitignore.Obtaining: Contact your WispHub administrator to generate an API key with appropriate permissions.WISPHUB_NET_HOST
WISPHUB_NET_HOST
Type: Format: Must include protocol (
str (URL)Purpose: Base URL of your WispHub Net instanceExample:https:// or http://) and should not have trailing slash.Common values:https://api.wisphub.net(official WispHub)https://yourcompany.wisphub.net(custom domain)http://localhost:8080(local WispHub instance for testing)
Required Variables — JWT Authentication
These variables are required for the JWT authentication system:JWT_SECRET_KEY
JWT_SECRET_KEY
Type: Generate a secure key:Security: This is the most sensitive value. Exposure allows forging JWT tokens and bypassing authentication.
strPurpose: Secret key used to sign and verify JWT tokens. Must be a cryptographically random string.Example:JWT_ALGORITHM
JWT_ALGORITHM
Type: Supported:
strPurpose: Algorithm used to sign JWT tokens.Default: HS256Example:HS256 (HMAC-SHA256). This is the standard for symmetric JWT signing.JWT_ACCESS_TOKEN_EXPIRE_MINUTES
JWT_ACCESS_TOKEN_EXPIRE_MINUTES
Type: Tuning:
intPurpose: How long JWT tokens remain valid, in minutes.Default: 60 (1 hour)Example:- Shorter expiry = better security, more frequent token refreshes
- Longer expiry = better UX for long-running processes (e.g. bots)
API_USERNAME
API_USERNAME
Type:
strPurpose: Username for the single API user. Used in POST /api/v1/auth/token.Example:API_PASSWORD_HASH
API_PASSWORD_HASH
Type: Generate a hash:Security: Never commit or log this value. Even though it’s a hash, it should be treated as a secret.
str (bcrypt hash)Purpose: Bcrypt hash of the API user’s password. The plain-text password is never stored.Example:Optional Variables (Business Rules)
These variables have sensible defaults but can be customized:MAX_ACTIVE_TICKETS_PER_ZONE
MAX_ACTIVE_TICKETS_PER_ZONE
Type: Impact: When this limit is reached, new ticket creation requests for that zone will be rejected with a
intPurpose: Maximum number of active support tickets allowed per zone to prevent technician saturationDefault: 3Example:ZONE_LIMIT_REACHED response.Tuning: Adjust based on:- Number of technicians per zone
- Average ticket resolution time
- Acceptable customer wait times
ACTIVE_TICKET_STATES
ACTIVE_TICKET_STATES
Type: Format: Comma-separated integers in parenthesesCommon WispHub Status IDs:
Tuple[int, ...]Purpose: Ticket status IDs considered “active” for zone limit calculationsDefault: (1,) (status ID 1, typically “Open”)Example:1: Open2: In Progress3: Pending4: Resolved5: Closed
DEFAULT_TICKET_STATUS
DEFAULT_TICKET_STATUS
Type: Usage: When creating tickets via
intPurpose: Default status ID assigned to newly created ticketsDefault: 1 (typically “Open”)Example:POST /api/v1/tickets, this status is automatically assigned.MAX_TICKET_RESOLUTION_DAYS
MAX_TICKET_RESOLUTION_DAYS
Type: Usage: Used to calculate estimated resolution dates when creating tickets. Excludes weekends in the calculation.
intPurpose: Expected number of business days for ticket resolutionDefault: 3Example:.env File Example
Create a.env file in the project root:
.env
Environment-Specific Configuration
Development Environment
.env.development
Production Environment
.env.production
Computed Properties
TheSettings class provides computed URL properties based on WISPHUB_NET_HOST:
WISPHUB_NET_HOST.
Configuration Validation
Pydantic automatically validates configuration on startup:Type Checking
Required Field Checking
Using Settings in Code
Import and use the globalsettings instance:
Docker Configuration
Using —env-file
Using -e flags
Docker Compose
docker-compose.yml
Environment variables defined in the
environment section override those from env_file.Kubernetes Configuration
For Kubernetes deployments, use ConfigMaps and Secrets:Secret (for sensitive data)
wisphub-secret.yaml
ConfigMap (for non-sensitive data)
wisphub-config.yaml
Deployment
deployment.yaml
Troubleshooting
Issue: “Field required” error
Cause: Missing required environment variable Solution: Ensure.env file exists and contains all required variables:
Issue: “Input should be a valid integer”
Cause: Type mismatch (e.g., string instead of integer) Solution: Remove quotes from numeric values:Issue: Configuration not loading in Docker
Cause:.env file not mounted or environment not passed
Solution: Verify environment is being passed:
Issue: Case sensitivity problems
Cause: Environment variable names must match exactly (case-sensitive) Solution: Use uppercase for all variables:Security Best Practices
Use .env.example
Create a template without sensitive values:Commit this to version control as a reference.
.env.example
