Skip to main content

Overview

The zeroclaw 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
The gateway enables remote interaction with your ZeroClaw agent through various channels.

Basic Usage

Command Syntax

Options

integer
Port to listen on. Use 0 for random available port. Defaults to gateway.port in config (typically 8585).
string
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
boolean
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 events
  • POST /api/message - Send messages to agent
  • GET /api/status - Gateway health check
  • GET /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 in config.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

Never bind to 0.0.0.0 on public servers without additional security (firewall rules, reverse proxy, VPN).
  1. Local development: Use default 127.0.0.1
  2. Remote access: Use SSH tunnel or VPN
  3. 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 error
  • 130 - Interrupted (Ctrl+C)

See Also