Overview
Thezeroclaw gateway command starts the HTTP/WebSocket gateway server that accepts:
- Webhook events from external services
- WebSocket connections for real-time communication
- API requests for programmatic control
Basic Usage
Command Syntax
Options
Port to listen on. Use
0 for random available port. Defaults to gateway.port in config (typically 8585).Host address to bind to. Defaults to
gateway.host in config (typically 127.0.0.1).Common values:127.0.0.1- Localhost only (secure default)0.0.0.0- All interfaces (public access)- Specific IP - Bind to specific network interface
Clear all paired tokens and generate a fresh pairing code. Use this to reset gateway authentication.
Examples
Basic Gateway
Network Configuration
Security Operations
Terminal Output
With New Pairing
Random Port
Gateway Features
HTTP Endpoints
The gateway exposes these HTTP endpoints:POST /webhook- Receive webhook eventsPOST /api/message- Send messages to agentGET /api/status- Gateway health checkGET /health- System health status
WebSocket Protocol
Connect to/ws for real-time bidirectional communication:
Security Features
- Pairing codes - Time-limited codes for client authentication
- Token-based auth - Paired tokens for ongoing sessions
- Request limits - 64KB max request body size
- Timeouts - 30s request timeout to prevent slow-loris attacks
- Rate limiting - Per-client rate limits (60s sliding window)
- Idempotency - Duplicate request detection
Configuration
Gateway settings inconfig.toml:
Integration with Channels
The gateway works with various channel integrations:- WhatsApp - Webhook endpoint for WhatsApp Business API
- GitHub - Webhook receiver for repository events
- Custom webhooks - Generic webhook receiver for any service
Security Best Practices
Recommended Setup
- Local development: Use default
127.0.0.1 - Remote access: Use SSH tunnel or VPN
- Production: Place behind reverse proxy (nginx, Caddy) with TLS
Pairing Token Management
Troubleshooting
Port Already in Use
Canβt Connect from Remote Host
Pairing Code Expired
Exit Codes
0- Success (gateway stopped gracefully)1- Startup error (port in use, permission denied)2- Configuration error130- Interrupted (Ctrl+C)
Related Commands
zeroclaw daemon- Run gateway + channels + scheduler togetherzeroclaw config- Manage gateway configurationzeroclaw channel- Configure channel integrations