Gateway Server
The gateway server provides remote HTTP/WebSocket access to Savfox, enabling web clients, chat platform integrations, and multi-device usage.
Starting the Gateway
Server options:
If --token is omitted, a random token is generated and printed at startup.
Authentication
All API and WebSocket requests require a bearer token:
Tokens support three scopes:
- Operator — Full access to all APIs and agent execution
- Viewer — Read-only access to status, sessions, and logs
- Chat — Send and receive chat messages only
Validate a token:
REST API Endpoints
WebSocket JSON-RPC
Connect to the WebSocket endpoint for real-time bidirectional communication:
The protocol uses JSON-RPC 2.0. Example request:
Key method groups:
- Agent —
agent,agent.identity,agent.wait - Chat —
chat.send,chat.history,chat.abort - Sessions —
sessions.list,sessions.preview,sessions.patch,sessions.reset,sessions.delete - Config —
config.get,config.set,config.apply,config.patch - Cron —
cron.list,cron.add,cron.update,cron.remove,cron.run,cron.runs - Models —
models.list - System —
connect,health,status,wake,send
Management Subcommands
Status
Logs
Models
Approvals
Devices
Channels
Manage chat bridge channel integrations:
Nodes
Manage connected nodes in a multi-node setup:
Chat Platform Bridges
The gateway can bridge conversations to external chat platforms. Configure bridges in your config.toml:
Supported platforms:
Each bridge routes messages bidirectionally between the chat platform and the Savfox agent.
Webhook Security
When security config exists, the gateway enforces request verification:
- Discord:
x-signature-ed25519+x-signature-timestamp - Slack:
x-slack-signature+x-slack-request-timestamp(5-minute replay window) - Telegram:
x-telegram-bot-api-secret-token - Generic webhook:
x-signatureorx-hub-signature-256(HMAC-SHA256)
Common failure responses:
401 invalid_signature— signature/token mismatch401 missing_signature— required signature headers are absent401 stale_signature— Slack timestamp outside the replay window
Background Services
The gateway runs several background services:
- Session pruning — Removes expired sessions every 5 minutes
- Cron scheduler — Executes scheduled tasks (checks every 60 seconds)
Cron Service
Schedule recurring tasks via the WebSocket API:
Schedule types:
at— One-shot execution at a specific timeevery— Repeat at a fixed intervalcron— Standard cron expression
Rate Limiting
The gateway includes a token-bucket rate limiter to prevent abuse. Rate limits are applied per-token and can be configured as needed.