Namespaces are an advanced feature for specific deployment scenarios. Most users should run their own hub instance instead.
How Namespaces Work
The hub uses a single baseCLI_API_TOKEN for authentication. Clients append :<namespace> to the token to create isolated workspaces within the same hub instance.
Hub Configuration
Configure only the base token without any namespace suffix
Client Configuration
Each user appends their unique namespace to the base token
Setup
1. Configure the Hub
On the hub server, set only the base token without any namespace:2. Configure Client Tokens
For each user, append a unique namespace to the base token: Alice’s configuration:3. Web Login and Telegram
When using web login or binding Telegram accounts, always use the fullbase:namespace token format:
Use Cases
Small Team Collaboration
Small Team Collaboration
A team of 3-5 developers sharing a single VPS or cloud instance. Each developer gets their own namespace for complete isolation while sharing infrastructure costs.
Multi-Environment Testing
Multi-Environment Testing
Use different namespaces for development, staging, and testing environments on the same hub instance.
Client Projects
Client Projects
Agencies managing multiple client projects can use namespaces to separate client sessions on a single hub.
Namespace Isolation
Namespaces provide complete isolation of:- Sessions: Each namespace has its own set of AI coding sessions
- Machines: Machine registrations are namespace-scoped
- Users: Telegram bindings and web users are isolated per namespace
- Data: All session data, messages, and metadata are namespace-scoped
Sessions, machines, and users in one namespace are completely invisible to other namespaces.
Limitations and Gotchas
Machine ID Conflicts
One machine ID cannot be reused across namespaces. To run multiple namespaces on the same physical machine, you have two options:Remote Spawn Limitations
Remote spawn (via the HAPI runner) is namespace-scoped. If you need remote spawning for multiple namespaces on the same machine, run a separate runner per namespace using differentHAPI_HOME directories.
Token Format Requirements
Token Format Reference
The namespace is specified using a colon separator:secret-token-123:alicemy-team-token:devprod-token:staging-env
secret-token-123(no namespace - will use default/no isolation)secret-token-123:alice:extra(multiple colons not supported):alice(missing base token)
Security Considerations
Telegram Integration
When binding a Telegram account to a namespace:- Open the Telegram Mini App from your bot
- Click the binding prompt
- Enter the full token with namespace:
your-base-token:alice - The Telegram account is now bound to the
alicenamespace
Each Telegram account can only be bound to one namespace at a time. To switch namespaces, unbind and rebind with a different namespace token.
Monitoring and Management
Namespaces are transparent to most HAPI operations:Migration Between Namespaces
To switch a machine to a different namespace:- Stop all active sessions:
hapi runner stop - Clear credentials:
hapi auth logout - Update your token:
export CLI_API_TOKEN="your-base-token:new-namespace" - Re-authenticate:
hapi auth login - Start new sessions with the new namespace
Related Topics
Runner
Background runner for long-running sessions
Configuration
Environment variables and settings