Overview
HAPI Hub provides three types of APIs for interacting with AI coding sessions:- REST API - HTTP endpoints for managing sessions, messages, permissions, and files
- WebSocket API - Real-time bidirectional communication via Socket.IO
- Server-Sent Events (SSE) - One-way server-to-client event streaming
Base URL
By default, the hub runs on:HAPI_LISTEN_HOST and HAPI_LISTEN_PORT environment variables.
Authentication
All API requests require authentication using JWT tokens obtained via the/api/auth endpoint.
There are two authentication methods:
1. Access Token (CLI and Web)
UseCLI_API_TOKEN with an optional namespace suffix:
2. Telegram Mini App
Use TelegraminitData validated against the bot token.
Using JWT Tokens
Once you obtain a JWT token from/api/auth, include it in requests:
Rate Limits
No rate limits are currently enforced.Client Libraries
The official HAPI CLI and web app use TypeScript with:- REST: Native
fetchAPI - WebSocket: Socket.IO client
- SSE: EventSource API
@hapi/protocol package.
Error Responses
All error responses follow this format:400- Bad Request (invalid input)401- Unauthorized (invalid or missing token)403- Forbidden (access denied)404- Not Found409- Conflict (version mismatch, active session)413- Payload Too Large500- Internal Server Error503- Service Unavailable (hub not connected)
API Sections
Authentication
Get JWT tokens for API access
Sessions
Manage coding sessions
Messages
Send and retrieve messages
Permissions
Approve or deny permission requests
Machines
List machines and spawn sessions
Git & Files
Access git status and file contents
Voice
Get ElevenLabs conversation tokens
Push Notifications
Subscribe to web push notifications
Socket.IO
Real-time WebSocket communication
SSE
Server-sent event streaming