Configuration Priority
Configuration is loaded with the following priority (highest to lowest):- Environment variables - Set in your shell or
.envfile - Settings file -
~/.hapi/settings.json(or$HAPI_HOME/settings.json) - Default values - Built-in defaults
Environment variables always override values in the settings file. When environment variables are used, they’re automatically saved to the settings file for future use.
CLI Configuration
Configuration options for the HAPI CLI client.Required Variables
CLI_API_TOKEN
Shared secret for authenticating with the HAPI hub.- Simple:
your-secret-token - With namespace:
your-secret-token:namespace
HAPI_API_URL
Base URL of the HAPI hub.Directory Configuration
HAPI_HOME
Configuration and data directory for HAPI.settings.json- User settings (machineId, token, onboarding)runner.state.json- Runner state (PID, port, version, heartbeat)runner.state.json.lock- Runner lock filelogs/- CLI and runner log filesaccess.key- Private key (if used)
Optional Variables
HAPI_EXPERIMENTAL
Enable experimental features.true, 1, yes (case-insensitive)
HAPI_CLAUDE_PATH
Path to a specific Claude CLI executable.If not set, HAPI searches for
claude on your PATH. This is useful when you have multiple Claude installations or when Claude is not in your PATH.HAPI_HTTP_MCP_URL
Default HTTP MCP (Model Context Protocol) target URL forhapi mcp command.
Runner Configuration
HAPI_RUNNER_HEARTBEAT_INTERVAL
Interval for runner health checks in milliseconds.- Prune dead sessions
- Check for CLI version updates
- Verify PID ownership
- Update heartbeat timestamp
HAPI_RUNNER_HTTP_TIMEOUT
HTTP timeout for runner control requests in milliseconds.hapi runner stophapi runner listhapi runner stop-session- Internal control operations
Worktree Environment Variables
These variables are automatically set by the runner when spawning worktree sessions. Do not set them manually.HAPI_WORKTREE_BASE_PATH
Base repository path for worktree sessions.HAPI_WORKTREE_BRANCH
Branch name for the worktree.HAPI_WORKTREE_NAME
Worktree name (also the directory name).HAPI_WORKTREE_PATH
Full path to the worktree directory.HAPI_WORKTREE_CREATED_AT
Worktree creation timestamp in milliseconds.For more details on worktrees, see the Worktrees documentation.
Hub Configuration
Configuration options for the HAPI hub server.Required Variables
CLI_API_TOKEN
Base shared secret for CLI authentication. Clients append:<namespace> for isolation.
- Hub:
CLI_API_TOKEN="base-token" - Client:
CLI_API_TOKEN="base-token:alice"
Telegram Configuration
TELEGRAM_BOT_TOKEN
Telegram Bot API token from @BotFather.- Create a bot with @BotFather
- Set
TELEGRAM_BOT_TOKEN - Set
HAPI_PUBLIC_URL(required for Mini App) - Start the hub
- Open
/appin your bot chat
TELEGRAM_NOTIFICATION
Enable or disable Telegram notifications.- Permission requests
- Session ready notifications
- Error notifications
Network Configuration
HAPI_LISTEN_HOST
Host/IP address to bind the HTTP service.HAPI_LISTEN_PORT
Port for the HTTP service.HAPI_PUBLIC_URL
Public HTTPS URL for external access (required for Telegram Mini App).- Telegram Mini App URL
- Default CORS origins
- OAuth callbacks (if implemented)
CORS_ORIGINS
Comma-separated list of allowed CORS origins.Data Storage
HAPI_HOME
Data directory for hub configuration and state.DB_PATH
SQLite database path.- Sessions and session metadata
- Messages (paginated)
- Machines and runner state
- Users (Telegram bindings with namespaces)
- Todo items extracted from messages
Relay Configuration
HAPI_RELAY_API
Relay API domain for tunwg (WebRTC tunneling).HAPI_RELAY_AUTH
Relay authentication key.HAPI_RELAY_FORCE_TCP
Force TCP relay mode when UDP is unavailable.Push Notifications
VAPID_SUBJECT
Contact email or URL for Web Push (VAPID protocol).- Web Push notification authentication
- Contact information in push service subscriptions
Voice Configuration (ElevenLabs)
ELEVENLABS_API_KEY
ElevenLabs API key for voice assistant.ELEVENLABS_AGENT_ID
Custom ElevenLabs agent ID.Settings File Format
CLI Settings File
Location:~/.hapi/settings.json (or $HAPI_HOME/settings.json)
Hub Settings File
Location:~/.hapi/settings.json (or $HAPI_HOME/settings.json)
The settings file is automatically created and updated when environment variables are read. You can also manually edit it, but environment variables will override manual changes.
Configuration Examples
Local Development
.env
Production Hub
.env
Remote CLI (Connecting to Production)
.env
Multi-Namespace Setup
alice.env
bob.env
CI/CD Environment
.env.ci
Environment Variable Reference Table
CLI Variables
| Variable | Required | Default | Description |
|---|---|---|---|
CLI_API_TOKEN | Yes | - | Authentication token (with optional :namespace) |
HAPI_API_URL | No | http://localhost:3006 | Hub base URL |
HAPI_HOME | No | ~/.hapi | Configuration directory |
HAPI_EXPERIMENTAL | No | false | Enable experimental features |
HAPI_CLAUDE_PATH | No | (auto-detect) | Path to Claude CLI |
HAPI_HTTP_MCP_URL | No | - | Default MCP server URL |
HAPI_RUNNER_HEARTBEAT_INTERVAL | No | 60000 | Runner heartbeat interval (ms) |
HAPI_RUNNER_HTTP_TIMEOUT | No | 10000 | Runner HTTP timeout (ms) |
HAPI_WORKTREE_BASE_PATH | Auto | - | Worktree base repo path |
HAPI_WORKTREE_BRANCH | Auto | - | Worktree branch name |
HAPI_WORKTREE_NAME | Auto | - | Worktree name |
HAPI_WORKTREE_PATH | Auto | - | Worktree directory path |
HAPI_WORKTREE_CREATED_AT | Auto | - | Worktree creation timestamp |
Hub Variables
| Variable | Required | Default | Description |
|---|---|---|---|
CLI_API_TOKEN | No | (auto-generated) | Base authentication token |
TELEGRAM_BOT_TOKEN | No | - | Telegram Bot API token |
TELEGRAM_NOTIFICATION | No | true | Enable Telegram notifications |
HAPI_LISTEN_HOST | No | 127.0.0.1 | HTTP bind address |
HAPI_LISTEN_PORT | No | 3006 | HTTP port |
HAPI_PUBLIC_URL | No | - | Public HTTPS URL |
CORS_ORIGINS | No | (auto-derived) | Allowed CORS origins |
HAPI_HOME | No | ~/.hapi | Data directory |
DB_PATH | No | $HAPI_HOME/hapi.db | SQLite database path |
HAPI_RELAY_API | No | relay.hapi.run | Relay API domain |
HAPI_RELAY_AUTH | No | hapi | Relay auth key |
HAPI_RELAY_FORCE_TCP | No | false | Force TCP relay mode |
VAPID_SUBJECT | No | mailto:[email protected] | VAPID subject for Web Push |
ELEVENLABS_API_KEY | No | - | ElevenLabs API key |
ELEVENLABS_AGENT_ID | No | (auto-created) | ElevenLabs agent ID |
Troubleshooting
Configuration Not Loading
Environment variable ignored
Environment variable ignored
Check priority: Environment variables override settings file. Ensure you’re setting the variable in the correct shell session:
Settings file not updating
Settings file not updating
Permissions issue: Ensure
~/.hapi/ directory is writable:HAPI_HOME not respected
HAPI_HOME not respected
Must be set before first run: HAPI_HOME must be set before any HAPI command:
Authentication Failures
401 Unauthorized
401 Unauthorized
Namespace isolation not working
Namespace isolation not working
Incorrect token format: Ensure namespace is appended with colon:
Connection Issues
Cannot connect to hub
Cannot connect to hub
Check URL and network:
CORS errors in browser
CORS errors in browser
Check CORS_ORIGINS:
Best Practices
Use .env Files
Store configuration in
.env files and load with source .env or dotenv toolsSeparate Environments
Use different
HAPI_HOME directories for dev, staging, and productionSecure Tokens
Never commit tokens to version control. Use secret managers in production
Document Custom Configs
Document any non-default settings in your team’s runbook
Related Topics
Namespaces
Multi-user isolation for shared hubs
Runner
Background daemon configuration
Worktrees
Git worktree environment variables