Overview
The Sessions API provides visibility into active gateway sessions where agents are connected and processing work. Sessions track token usage, model selection, activity timestamps, and connection status. Mission Control aggregates session data from:- OpenClaw Gateway: Primary source for active agent sessions
- Claude Code: Local Claude development sessions
- Token Usage Database: Historical session data
Authentication
All session endpoints require authentication via:- Session Cookie:
mc-session(set after login) - API Key:
x-api-keyheader
List Gateway Sessions
GET /api/sessions
Retrieve all active gateway sessions with token usage and status information.
Query Parameters
Filter sessions by agent name
Maximum number of sessions to return
Response Fields
Array of session objects
Gateway Session Fields (when source = “gateway”)
When sessions are retrieved from the OpenClaw Gateway, they include:- Live token usage and context window information
- Real-time activity status
- Channel information (Discord, Slack, etc.)
- Session type (chat, cron, etc.)
Local Session Fields (when source = “local”)
When sessions are retrieved from local Claude Code database:Number of user messages in session
Number of assistant responses
Number of tool invocations
Estimated cost in USD
Most recent user prompt text
Example Request
Example Response (Gateway Sessions)
Example Response (Local Claude Sessions)
Session DeduplicationOpenClaw tracks cron runs under the same session ID as parent sessions. Mission Control automatically deduplicates by
sessionId, keeping the most recently updated entry when duplicates exist.Error Responses
401 Unauthorized
Authentication required or invalid credentials
Control Session
POST /api/sessions/{id}/control
Control a session with pause, resume, or kill actions.
Path Parameters
Session ID (key)
Request Body
Control action to perform
Response
Whether the control action was successful
Example Request
Example Response
Error Responses
400 Bad Request
Invalid action or missing required fields
401 Unauthorized
Authentication required
403 Forbidden
Insufficient permissions (requires operator role)
404 Not Found
Session does not exist or has expired
Session Data Sources
Understanding Session Data
Mission Control aggregates session data from multiple sources.
Priority Order
-
OpenClaw Gateway Sessions (Primary)
- Live sessions from connected agents
- Real-time token usage and status
- Most up-to-date information
-
Claude Code Local Sessions (Fallback)
- Local development sessions
- Historical data from SQLite database
- Used when no gateway sessions available
-
Token Usage Database (Final Fallback)
- Derived from recorded token usage
- Used when no active sessions exist
Session Types
- Gateway Sessions
- Local Sessions
Gateway Sessions are live connections between agents and the OpenClaw gateway.Characteristics:
- Real-time status updates
- Active token counting
- Channel information (Discord, Slack, etc.)
- Support for control actions (pause/resume/kill)
chat- Interactive chat sessionscron- Scheduled task executionswebhook- Webhook-triggered sessions
Token Usage Formatting
Understanding Token Display
How token counts are formatted in session responses.
Format: used/context (percentage%)
Example: 12k/35k (34%)
- 12k: Tokens used in this session
- 35k: Total context window size
- 34%: Percentage of context consumed
Token Abbreviations
- Numbers ≥ 1,000,000:
1.5m(millions) - Numbers ≥ 1,000:
15k(thousands) - Numbers < 1,000:
850(exact count)
Age Formatting
Session Age Display
How session age is calculated and displayed.
- Minutes:
15m(less than 1 hour) - Hours:
2h(less than 24 hours) - Days:
3d(24 hours or more)
Monitoring Best Practices
Session Monitoring Tips
Recommendations for effective session monitoring.
Active Monitoring
- Check session age regularly - Sessions older than 24h may be stale
- Monitor token usage - High percentages indicate context window pressure
- Track inactive sessions -
active: falsesessions may need cleanup - Review failed sessions - Check for error patterns
Control Actions
Performance Considerations
- Gateway sessions update in real-time
- Local sessions refresh on database sync (typically every 5 minutes)
- Token usage data is deduplicated to prevent duplicates from cron runs