{"name":"CMonitor API","version":"1.4.0","description":"API for proxy monitoring, tester fleet diagnostics, network tools (ping, tcp, geo/ASN inspection), subscriptions, and alert dispatch.","docs_url":"/docs","mcp_url":"/mcp","openapi_url":"/api/openapi.json","auth":{"session":{"type":"cookie","cookie_name":"tw.sid","login_endpoint":"POST /api/auth/login","logout_endpoint":"POST /api/auth/logout","status_endpoint":"GET /api/auth/me","description":"Standard session cookie obtained via credentials authentication. Required for dashboard UI, Net Tools, Quick Check, and configuration changes."},"basic":{"type":"http-basic","header":"Authorization: Basic base64(username:password)","description":"Normal CMonitor username and password over HTTP Basic auth. Accepted only by GET /metrics and GET /status-check/:id so Prometheus and uptime monitors can authenticate without a browser session. Repeated failures from one address are throttled."},"agent_token":{"type":"bearer","header":"Authorization: Bearer <AGENT_TOKEN>","description":"Pre-shared bearer token configured via TW_AGENT_TOKEN. Used for automated probe collection and tester synchronization."},"api_key":{"type":"bearer | header","header":"Authorization: Bearer <cmon_...>","alt_header":"X-API-Key: <cmon_...>","description":"Scoped API key associated with your account. Supports read_only, read_test, and full permission levels. Bypasses browser login steps."}},"endpoints":{"net_tools":[{"method":"POST","path":"/api/vless/net-tools/ping","auth":"session","description":"Run exactly 4 ICMP ping probes from selected (or all enabled) tester nodes. Returns packet loss %, min/avg/max latency, per-probe times, resolved IP, and 24h-cached ISP/location/ASN/BGP prefix metadata.","body":{"target":"string (hostname or IPv4/IPv6)","targets":"array of 1-20 targets; provide target or targets","tester_ids":"array of integers (1-8, optional: defaults to all enabled nodes)","stream":"boolean (optional, enables SSE streaming)"}},{"method":"POST","path":"/api/vless/net-tools/tcp","auth":"session","description":"Test TCP port connectivity and handshake latency from selected (or all enabled) tester nodes. Returns latency ms, resolved IP, and target metadata.","body":{"target":"string (hostname, IP, or host:port)","targets":"array of 1-20 targets; each may include :port","port":"integer (1-65535, optional if included in target)","tester_ids":"array of integers (1-8, optional)","stream":"boolean (optional, enables SSE streaming)"}},{"method":"GET","path":"/api/vless/net-tools/nodes","auth":"session","description":"List tester nodes with their ID, public name, and 24h-cached network metadata (country, city, ISP, ASN, BGP prefix). Public IP is visible to admins."},{"method":"GET","path":"/api/vless/ip-search","auth":"session","description":"Search account saved configurations by exact IN (endpoint) or OUT (exit) IP. Normalizes IPv4 and IPv6 addresses.","query":{"ip":"string (required)","user_id":"integer (admin only, optional)"}}],"integrations":[{"method":"GET","path":"/api/vless/uptime","auth":"session","description":"UptimeRobot-style uptime bars for every saved config, one row per monitoring node. Each bar is [probes, successful, avg latency ms] or null when there is no data. 24h uses 15-minute bars from raw probes; 7d (2 h bars), 30d and 90d (daily bars) use hourly aggregates kept for 120 days.","query":{"range":"24h | 7d | 30d | 90d (default 24h)","ids":"comma-separated config ids (optional)","user_id":"integer (admin only)"}},{"method":"GET","path":"/api/vless/:id/events","auth":"session","description":"Outage log for one config across its nodes: runs of 3 or more failed probes with start, end (null while ongoing), duration, reason, failed probe count and node. Raw history is kept for 7 days.","query":{"days":"integer 1-7 (default 7)","limit":"integer (default 100, max 300)"}},{"method":"GET","path":"/api/download-usage","auth":"session","description":"The signed-in account's monthly download allowance for download checks: used_bytes, quota_bytes, remaining_bytes, unlimited, exhausted, plus six months of history. Default allowance is 5 GB per active slot (10 slots = 50 GB a month); administrators can change the per-slot rate or set a fixed monthly total per user. 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."},{"method":"GET","path":"/metrics","auth":"basic","description":"Prometheus text exposition for the account: cmonitor_config_up, cmonitor_config_latency_ms, cmonitor_node_config_up / _latency_ms / _loss_ratio (per tester node, 5-minute loss), cmonitor_config_enabled. Series with no probe in the last 3 minutes are omitted instead of reported healthy. Optional Pushgateway export: set CMONITOR_PUSH_URL (and CMONITOR_PUSH_INTERVAL, CMONITOR_INSTANCE).","query":{"user_id":"integer (admin only)"}},{"method":"GET","path":"/status-check/:id","auth":"basic","description":"Uptime-monitor endpoint for one saved config: 200 \"OK\" when reachable, 503 \"Failed\" or \"No data\" otherwise, 404 for unknown ids. Works with Uptime Kuma, BetterStack, UptimeRobot.","query":{"node":"string (optional tester name: check one node)","min_nodes":"integer (optional, nodes that must be reachable, default 1)"}},{"method":"GET","path":"/status/:slug/badge/:id.svg","auth":"none (public pages only)","description":"Embeddable SVG status badge for one node of a public status page. On a custom domain use /badge/:id.svg.","query":{"theme":"dark | light","variant":"default | flat | pill | dot","size":"sm | md | lg","rounded":"none | sm | md | lg | full","showName":"true | false","showLatency":"true | false","width":"pixels","height":"pixels"}},{"method":"GET","path":"/status/:slug/check/:id","auth":"none (public pages only)","description":"Public per-node check URL: 200 when online or high-latency, 503 when offline or without data. On a custom domain use /check/:id."}],"quick_check":[{"method":"POST","path":"/api/vless/quick-check","auth":"session | apiKey (read_test+)","description":"Ephemeral single proxy probe across 1-8 tester nodes (vless, vmess, trojan, ss, hysteria2/hy2, wg:// WireGuard, socks5, http(s) proxies, xrayjson). Results are returned immediately and never persisted. Optional speed_test measures download and upload throughput with configurable time cutoffs and data sizes (rate limited to 6 RPM per API key).","body":{"url":"string (required)","tester_ids":"array of integers (1-8, optional)","core":"string (\"auto\" | \"xray\" | \"v2ray\", default \"auto\")","check_method":"string (\"http\" default | \"download\")","speed_test":"object (optional: {download: boolean, upload: boolean, bytes: integer, download_bytes: integer, upload_bytes: integer, max_seconds: number 1-15}). Cannot be combined with check_method=download."}},{"method":"POST","path":"/api/vless/quick-check/subscription","auth":"session | apiKey (read_test+)","description":"Ephemeral batch testing of entire subscription feed across chosen nodes with live SSE progress streaming. Omit URLs from results for privacy. Supports optional speed_test with custom cutoffs and sizes (capped at 10 configs and 10 MB per direction; rate limited to 6 RPM per API key).","body":{"url":"string (subscription URL) or sub_id (integer)","tester_ids":"array of integers (1-8, optional)","max_configs":"integer (1-100, default 30; capped at 10 when speed_test is set)","concurrency":"integer (1-8, default 4)","core":"string (\"auto\" | \"xray\" | \"v2ray\")","check_method":"\"http\" default | \"download\"","speed_test":"object (optional: {download: boolean, upload: boolean, bytes: integer, download_bytes: integer, upload_bytes: integer, max_seconds: number 1-15}). Cannot be combined with check_method=download.","fetch_format":"\"auto\" | \"json\" (Xray JSON feeds: every balancer node is tested)","fetch_user_agent":"string (optional)","fetch_headers":"object of extra request headers (optional)","resolve_domains":"boolean (one config per resolved IP)"}}],"v2ray_nodes":[{"method":"GET","path":"/api/vless","auth":"session | bearer","description":"List monitored proxy configurations with 1-hour rolling quality metrics (uptime %, average latency ms, packet loss rate) and latest probe outcome.","query":{"chart":"0 or 1 (include 1h chart points)","user_id":"integer (admin only)"}},{"method":"POST","path":"/api/vless","auth":"session","description":"Create and monitor a new proxy configuration.","body":{"url":"string (vless, vmess, trojan, ss, hysteria2, wg, socks5, http(s), xrayjson URL; required)","name":"string (optional label)","group_id":"integer (optional)","tester_id":"integer (optional, primary node)","tester_ids":"array of 1-2 node ids (primary first; the primary also drives alerts). Default: the nodes marked \"monitor new configs by default\"","check_method":"\"http\" (default) | \"download\" (about once a minute, confirms the tunnel moves data)"}},{"method":"PUT","path":"/api/vless/:id","auth":"session","description":"Update a monitored configuration (name, group, tester assignment, or enabled state)."},{"method":"DELETE","path":"/api/vless/:id","auth":"session","description":"Delete a monitored configuration and purge its history."},{"method":"GET","path":"/api/vless/:id/chart","auth":"session | bearer","description":"Bucketed time-series probe history (latency, loss, success points) for 1 to 168 hours.","query":{"hours":"integer (1-168, default 24)","pts":"integer (number of aggregate points, default 180)","tester_id":"integer (optional: only this node's history)"}},{"method":"POST","path":"/api/vless/:id/test","auth":"session","description":"Trigger an immediate on-demand probe of this node on its assigned tester node."}],"subscriptions":[{"method":"GET","path":"/api/subscriptions","auth":"session","description":"List configured subscription feeds for the current account."},{"method":"POST","path":"/api/subscriptions","auth":"session","description":"Add a new subscription feed with automatic refresh interval.","body":{"name":"string","url":"string (HTTP/HTTPS URL)","update_interval_hours":"integer","group_id":"integer (optional)","fetch_format":"\"auto\" | \"json\"","fetch_user_agent":"string (optional)","fetch_headers":"object, e.g. {\"X-Token\":\"abc\"} (optional)","resolve_domains":"boolean: when a domain resolves to several IPs, monitor each IP separately"}},{"method":"PUT","path":"/api/subscriptions/:id","auth":"session","description":"Update subscription settings."},{"method":"DELETE","path":"/api/subscriptions/:id","auth":"session","description":"Delete subscription and optionally purge imported nodes."},{"method":"POST","path":"/api/subscriptions/:id/refresh","auth":"session","description":"Manually trigger an immediate update and parsing of a subscription feed."},{"method":"GET","path":"/api/subscriptions/:id/configs","auth":"session","description":"List configurations imported by this subscription feed."}],"testers":[{"method":"GET","path":"/api/vless-testers","auth":"session | bearer","description":"List tester nodes, heartbeat latency, active configuration count, and result freshness."},{"method":"GET","path":"/api/vless-testers/:id/chart","auth":"session | bearer","description":"Heartbeat response time history for a tester node."}],"groups":[{"method":"GET","path":"/api/groups","auth":"session","description":"List node groups with configuration counts and public status page configuration."},{"method":"POST","path":"/api/groups","auth":"session","description":"Create a new node group.","body":{"name":"string (required)"}},{"method":"PUT","path":"/api/groups/:id","auth":"session","description":"Update group name or toggle public status page."},{"method":"DELETE","path":"/api/groups/:id","auth":"session","description":"Delete group."}],"public_status":[{"method":"GET","path":"/api/public/status/:slug","auth":"none","description":"Public, unauthenticated group status feed. Raw proxy credentials and node IPs are safely redacted."}],"telegram_alerts":[{"method":"GET","path":"/api/telegram/settings","auth":"session","description":"Get Telegram bot configuration and linked chat status."},{"method":"POST","path":"/api/telegram/rules","auth":"session","description":"Create an independent Telegram alert rule for monitored nodes.","body":{"name":"string","window_seconds":"integer","fail_percent":"integer","cooldown_seconds":"integer","config_ids":"array of integers"}}],"api_keys":[{"method":"GET","path":"/api/api-keys","auth":"session | api_key (read_only+)","description":"List account API keys with level, allowed groups, last used, error count, and status. Plaintext secret keys are never returned."},{"method":"POST","path":"/api/api-keys","auth":"session | api_key (full)","description":"Create a new scoped API key for automated tools. The full plaintext key is returned only once upon creation.","body":{"name":"string (required)","level":"\"read_only\" | \"read_test\" | \"full\"","allowed_groups":"array of group IDs (optional)","rate_limit_rpm":"integer (optional, default 60)","expires_at":"unix timestamp (optional)"}},{"method":"PUT","path":"/api/api-keys/:id","auth":"session | api_key (full)","description":"Update an API key name, level, allowed groups, rate limit, expiry, or toggle enabled status."},{"method":"DELETE","path":"/api/api-keys/:id","auth":"session | api_key (full)","description":"Permanently revoke and delete an API key. Deleted keys are rejected immediately."},{"method":"GET","path":"/api/api-keys/:id/usage","auth":"session | api_key","description":"Get request volume chart data and recent call logs (time, endpoint, status, IP) for one key."},{"method":"POST","path":"/api/api-keys/:id/test","auth":"session | api_key","description":"Test what the key can see: verifies status, permissions, accessible groups, configs, and rate limits."}],"webhooks":[{"method":"GET","path":"/api/webhooks","auth":"session | api_key (read_only+)","description":"List registered alert webhooks in the account."},{"method":"POST","path":"/api/webhooks","auth":"session | api_key (full)","description":"Register a webhook URL called when a config changes state (e.g. failed N times in a row, then recovered).","body":{"name":"string","url":"string","consecutive_failures":"integer (N failures in a row, default 3)","group_id":"integer (optional)","config_id":"integer (optional)","secret":"string (optional HMAC-SHA256 signature)"}},{"method":"PUT","path":"/api/webhooks/:id","auth":"session | api_key (full)","description":"Update webhook name, URL, consecutive failure threshold, or enabled status."},{"method":"DELETE","path":"/api/webhooks/:id","auth":"session | api_key (full)","description":"Permanently remove a registered webhook."},{"method":"POST","path":"/api/webhooks/:id/test","auth":"session | api_key (read_test+)","description":"Send an immediate test notification event to a registered webhook URL to verify delivery."}],"health_and_changes":[{"method":"GET","path":"/api/groups/summary","auth":"session | api_key (read_only+)","description":"Summary of how many monitored configurations are good, bad, or unknown per group."},{"method":"GET","path":"/api/vless/changes","auth":"session | api_key (read_only+)","description":"List recent configuration status transitions (\"went from good to bad\" / \"recovered\") with timestamps and failure reasons.","query":{"limit":"integer (default 50)","since":"unix timestamp (optional)"}}]}}