← Dashboard
CMonitor API Docs v1.3.0
πŸ€– MCP Guide JSON Catalog OpenAPI Admin

CMonitor REST API & Fleet Reference

CMonitor exposes a high-performance HTTP API for active proxy probing, tester fleet network diagnostics (ICMP ping, TCP port verification, cached ASN/BGP/ISP inspection), ephemeral subscription checks, and independent alert automation.

Authentication

CMonitor supports three authentication mechanisms for interactive browsers, local AI assistants, automated scripts, and collector nodes:

1. Scoped API Key (Scripts & AI Tools)

Send Authorization: Bearer cmon_... or X-API-Key: cmon_.... Designed for automated repair tools and MCP clients. Scoped strictly to your account with read_only, read_test, or full permissions, optional group restrictions, and rate limiting. No session login required.

2. Session Cookie (Web Dashboard)

Obtained by calling POST /api/auth/login with JSON credentials. Returns an HTTP-only tw.sid session cookie. Used by the interactive dashboard UI.

3. Agent Bearer Token

Supplied via Authorization: Bearer <TW_AGENT_TOKEN> header. Used for automated probe synchronization between collector nodes and the panel.

API Key Example (curl)
curl -H "Authorization: Bearer cmon_your_api_key_here" \
  https://cmonitor.realkia.com/api/vless
Session Login Example (curl)
curl -c cookies.txt -X POST https://cmonitor.realkia.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"your_username","password":"your_password"}'

Server-Sent Events (SSE) Streaming

Diagnostic tools like Net Tools (Ping, TCP) and Subscription Quick Check support progressive Server-Sent Events. Clients can pass stream=true or send Accept: text/event-stream. Individual tester results are streamed as they finish so clients never have to wait for the slowest node to view faster ones.

Stream format: Events are emitted as data: {"type":"result","result":{...}} per tester node, terminated by data: {"type":"done","results":[...]}.

⚑ Net Tools (Network Diagnostics)

Live network diagnostics executed directly from your distributed tester fleet. No configurations are saved and no monitoring history is retained.

POST /api/vless/net-tools/ping Session Auth Required
Executes exactly four ICMP ping probes from selected (or all enabled) tester nodes. Returns packet loss %, min/avg/max round-trip latency, individual probe timings, resolved IP, and 24h-cached ISP/location/ASN/BGP prefix metadata.

Request Body

FieldTypeRequirementDescription
target string required Destination hostname (e.g. example.com) or IPv4/IPv6 address. Protocol prefixes are automatically stripped.
tester_ids array<int> optional Array of 1 to 8 enabled tester node IDs. If omitted, automatically probes from all enabled tester nodes.
stream boolean optional Set to true (or send Accept: text/event-stream) for progressive SSE output.
Example: Four-Probe Ping from all enabled nodes
curl -b cookies.txt -X POST https://cmonitor.realkia.com/api/vless/net-tools/ping \
  -H "Content-Type: application/json" \
  -d '{"target":"1.1.1.1"}'
JSON Response Example
{
  "ok": true,
  "results": [
    {
      "tester_id": 1,
      "tester_name": "Master local (DE)",
      "ok": true,
      "round_trip_ms": 42,
      "result": {
        "ok": true,
        "resolved_ip": "1.1.1.1",
        "sent": 4,
        "received": 4,
        "loss_percent": 0.0,
        "min_ms": 1.2,
        "avg_ms": 1.35,
        "max_ms": 1.5,
        "probes": [1.2, 1.4, 1.3, 1.5],
        "target_info": {
          "country": "US",
          "city": "San Francisco",
          "isp": "Cloudflare, Inc.",
          "asn": 13335,
          "prefix": "1.1.1.0/24"
        }
      }
    }
  ]
}
POST /api/vless/net-tools/tcp Session Auth Required
Checks TCP port connectivity and handshake latency from selected tester nodes. Supports specifying the port either via the port property or inside target as host:port (e.g. example.com:443 or [2606:4700:4700::1111]:443).

Request Body

FieldTypeRequirementDescription
target string required Target hostname, IP, or host:port string.
port integer optional* Destination port (1-65535). Required only if not included in target.
tester_ids array<int> optional Array of 1 to 8 enabled tester node IDs. Defaults to all enabled nodes if omitted.
Example: TCP Port Check
curl -b cookies.txt -X POST https://cmonitor.realkia.com/api/vless/net-tools/tcp \
  -H "Content-Type: application/json" \
  -d '{"target":"cmonitor.realkia.com:443"}'
JSON Response Example
{
  "ok": true,
  "results": [
    {
      "tester_id": 1,
      "tester_name": "Master local",
      "ok": true,
      "round_trip_ms": 18,
      "result": {
        "ok": true,
        "resolved_ip": "89.58.29.206",
        "latency_ms": 12.4,
        "target_info": {
          "country": "DE",
          "city": "Frankfurt",
          "isp": "Hetzner Online GmbH",
          "asn": 24940,
          "prefix": "89.58.0.0/17"
        }
      }
    }
  ]
}
GET /api/vless/net-tools/nodes Session Auth Required
Returns all active tester nodes with their ID, public name, and 24-hour cached geo/network metadata (city, country, ISP, ASN, BGP prefix). Node IP addresses follow account privacy permissions (visible to administrators).
Example Request
curl -b cookies.txt https://cmonitor.realkia.com/api/vless/net-tools/nodes

⚑ Quick Check (Ephemeral Probes)

On-demand proxy verification that tests single configuration links or entire subscription feeds across chosen tester nodes without writing to the database or affecting monitoring history.

POST /api/vless/quick-check Session or API Key (read_test+)
Tests a single proxy configuration link (vless://, vmess://, trojan://, ss://, hysteria2://, wg:// WireGuard, socks5://, http(s):// proxies) across 1 to 8 selected tester nodes. Pass "speed_test": {"download": true, "upload": true, "bytes": 10485760, "max_seconds": 3} to measure tunnel throughput with customizable timeout cutoffs (e.g. 2s, 3s, 5s) and download/upload sizes (rate limited to 6 RPM per API key; cannot combine with check_method: "download").
Request Example
curl -H "Authorization: Bearer cmon_YOUR_KEY" -X POST https://cmonitor.realkia.com/api/vless/quick-check \
  -H "Content-Type: application/json" \
  -d '{"url":"vless://UUID@domain:443?type=tcp&security=tls#Example","tester_ids":[1,3],"core":"auto","speed_test":{"download":true,"upload":true,"bytes":10485760}}'
POST /api/vless/quick-check/subscription Session or API Key (read_test+)
Streams ephemeral test results for an entire subscription URL or saved subscription ID across selected nodes. Raw configuration URLs and subscription tokens are omitted from output. Supports optional speed_test (capped at 10 configs per run and 10 MB per direction; rate limited to 6 RPM per API key).

🌐 Monitored Configurations (V2Ray / VLESS)

Continuous proxy monitoring endpoints with 1-hour rolling metrics, uptime ratios, bucketed time-series charts, and immediate refresh controls.

GET /api/vless Session or Bearer Auth
Lists monitored proxy configurations for the current account scope. Includes 1-hour rolling uptime percentage, average latency in ms, packet loss rate, and the most recent probe outcome.
Example Request
curl -b cookies.txt "https://cmonitor.realkia.com/api/vless?chart=0"
GET /api/vless/:id/chart Session or Bearer Auth
Retrieves bucketed time-series metrics (latency, loss, success) for a monitored node. Supports query parameters hours (1 to 168) and pts (default 180).
POST /api/vless/:id/test Session Auth Required
Requests the assigned tester node to run an immediate on-demand probe of this node, instantly updating monitoring records without editing configuration parameters.

πŸ“¦ Subscriptions & Fleet Management

GET /api/subscriptions Session Auth
Lists all subscription feeds configured in the current account. Trigger manual synchronizations with POST /api/subscriptions/:id/refresh.
GET /api/vless-testers Session or Bearer Auth
Returns the current health status, round-trip heartbeat latency, assigned configuration counts, and probe freshness for each tester node in the fleet.
GET /api/groups Session Auth
Lists node groups with configuration counts and public status page configuration. Public status feeds are available at GET /api/public/status/:slug without authentication.
POST /api/telegram/rules Session Auth
Creates an independent alert rule with custom failure window, loss percentage threshold, sustained outage verification, and automatic recovery notifications.

πŸ”‘ API Keys & Automation

Scoped API access for external repair scripts, monitoring daemons, and AI assistants. Keys are tied to your account, hashed with SHA-256 (only a one-way fingerprint is stored), and can be disabled or deleted immediately.

GET /api/api-keys Session | API Key
Lists your API keys with name, prefix hint (e.g. cmon_a1b2...7f2c), level, allowed groups, status, last used date, and 7-day error count. Plaintext secrets are never returned.
POST /api/api-keys Session | API Key (full)
Create a new API key. The full plaintext key is returned only once in the creation response. Choose from three levels: read_only, read_test, or full. Optionally limit access to specific group IDs, set a request-per-minute cap, or set an expiry date.
curl -X POST https://cmonitor.realkia.com/api/api-keys \
  -H "Authorization: Bearer cmon_your_existing_key" \
  -H "Content-Type: application/json" \
  -d '{"name":"Auto Fixer","level":"read_test","rate_limit_rpm":60}'
GET /api/api-keys/:id/usage Session | API Key
Returns request volume chart data (hourly buckets for the last 24h) and the 50 most recent call records (timestamp, method, endpoint, status code, IP address, error message).
POST /api/api-keys/:id/test Session | API Key
Tests a key's current status and returns what resources and actions it can see: accessible group count, config count, tester node count, and permission capabilities.

πŸ”” Webhooks & Change Alerts

Monitor configuration health state transitions and receive automated HTTP webhook callbacks when nodes go down (after failing N times consecutively) and when they recover.

GET /api/groups/summary Session | API Key (read_only+)
Returns a consolidated health overview showing how many monitored configurations are good, bad, or unknown across all groups or filtered by key group permissions.
{
  "total": 35, "good": 32, "bad": 2, "unknown": 1,
  "groups": [
    { "id": 1, "name": "Default", "total": 20, "good": 19, "bad": 1, "unknown": 0 }
  ]
}
GET /api/vless/changes Session | API Key (read_only+)
Lists recent configuration health transitions (e.g. "Config X went from good to bad at 2026-10-27 19:15:00 UTC (failed 3 times in a row: Connection refused)" and "Config X recovered (latency: 145ms)"). Query parameters: limit (1–200, default 50) and since (unix timestamp).
GET /api/webhooks Session | API Key (read_only+)
List registered webhooks with target URL, failure threshold N (consecutive probe failures before alerting), group filter, last triggered time, and delivery status. Also supports POST /api/webhooks (create), PUT /api/webhooks/:id (edit), DELETE /api/webhooks/:id (delete), and POST /api/webhooks/:id/test (send test delivery).

πŸ“ˆ Monitoring Integrations

Pull CMonitor data into Prometheus, Uptime Kuma, BetterStack or any web page. /metrics and /status-check/:id use your normal CMonitor username and password with HTTP Basic auth (repeated failures are throttled). Badges and public check URLs need no login and only expose what the public status page already shows.

GET /api/vless/uptime Session Auth Required
Uptime bars for the dashboard's Uptime view. Each saved config can be monitored from two nodes (set tester_ids on POST/PUT /api/vless; the first node also drives alerts), and every node gets its own row of bars. ?range=24h|7d|30d|90d. Bars are [probes, ok, avg_ms] or null; green is under 1% failed probes, yellow under 20%, red above. GET /api/vless/:id/events returns the outage log (runs of 3 or more failed probes, last 7 days), and GET /api/vless/:id/chart?tester_id= returns one node's quality history.
GET /api/download-usage Session Auth Required
The download check moves real data, so every account has a monthly allowance: 5 GB per active slot by default (10 slots = 50 GB a month). Administrators can change the per-slot rate or set a fixed monthly total per user, and see each customer's usage on the Users page. Usage resets on the 1st (UTC). When the allowance is used up, Quick Check download runs return 429 with "code":"DOWNLOAD_LIMIT", and monitored download configs fall back to the connectivity check until the next month. Quick Check-only (metered) nodes never run download checks.
GET /metrics Basic Auth
Prometheus exposition: cmonitor_config_up, cmonitor_config_latency_ms, cmonitor_node_config_up, cmonitor_node_config_latency_ms, cmonitor_node_config_loss_ratio (5-minute window) and cmonitor_config_enabled, labeled by config, group, protocol, subscription and node. Configs without a probe in the last 3 minutes are left out rather than reported healthy. Admins may add ?user_id=. Optional Pushgateway export: set CMONITOR_PUSH_URL on the server.
prometheus.yml
scrape_configs:
  - job_name: cmonitor
    scheme: https
    metrics_path: /metrics
    basic_auth: { username: YOUR_USER, password: YOUR_PASSWORD }
    static_configs: [{ targets: ["cmonitor.realkia.com"] }]
    scrape_interval: 30s
GET /status-check/:id Basic Auth
One URL per saved config for uptime monitors: 200 OK when reachable, 503 when failed or without fresh data, 404 for unknown ids. Optional ?node=Name checks one tester, ?min_nodes=2 requires several nodes to reach it.
Uptime Kuma monitor URL
https://USER:PASSWORD@cmonitor.realkia.com/status-check/123?min_nodes=2
GET /status/:slug/badge/:id.svg Public
Embeddable SVG badge for a node on a public status page (copy the URL from the page editor's Badge button). Options: theme=dark|light, variant=default|flat|pill|dot, size=sm|md|lg, rounded, showName, showLatency, width, height. The matching /status/:slug/check/:id returns 200/503 for monitors. On a custom domain use /badge/:id.svg and /check/:id. Public pages also accept ?hideHeader=true&hideStats=true&hideControls=true&hideFooter=true&hideBackground=true for embedding.
Markdown / HTML
![status](https://cmonitor.realkia.com/status/my-page/badge/123.svg?variant=pill)
<img src="https://cmonitor.realkia.com/status/my-page/badge/123.svg?theme=light" alt="status">

πŸ€– AI & Model Context Protocol (MCP)

CMonitor includes a built-in MCP stdio server allowing AI assistants (Claude, Windsurf, Cursor, ChatGPT) to interact with monitoring data and run network diagnostics safely.

Connecting an AI Client

Run node /opt/cmonitor/mcp/server.js (or npm run mcp) in your AI client's MCP configuration with the following environment variables:

export CMONITOR_MCP_URL=https://cmonitor.realkia.com
export CMONITOR_MCP_USERNAME=your_username
export CMONITOR_MCP_PASSWORD='your_password'

Available MCP tools include: net_ping, net_tcp, get_network_nodes, search_ip, quick_check_config, quick_check_subscription, list_v2ray_nodes, get_quality_history, and get_tester_health. For full MCP instructions visit /mcp.