Bỏ qua để đến nội dung
Control plane API The MZPanel control-plane surface — session vs Bearer-token auth, the full management API on /v1 (discovered at GET /v1/api/operations), the /v1/api shortcuts, route groups, the error envelope and the agent WebSocket protocol.

Control plane API

Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.

The control plane (api.mzpanel.com) serves three things: a REST API on /v1 (the dashboard uses it, and so does any automation with an API token), the MCP server (mcp.mzpanel.com), and the WebSocket the on-VPS agents dial into. This page orients you on all three. For a hands-on start, see the REST API quickstart.

CallerCredential
Dashboard → APIA session cookie (httpOnly, SameSite=Lax, Secure), set at sign-in, plus a CSRF token on mutations.
Your automation / AI → API or MCPAn API token: Authorization: Bearer mzmcp_…, minted at Advanced → Developer (/developer). It is scoped by access level, opt-in scopes, a server allowlist and an optional client IP allowlist (403 token_ip_denied from other addresses), and capped by the minting user’s role. Available on every plan. See Tokens, levels & scopes.
Agent → API (WebSocket)A long-lived agent token, obtained at registration by exchanging a one-time install token (1-hour TTL).

API tokens call the same /v1 routes the dashboard uses. A bearer bridge in front of them looks the request up in an operation table, then checks the token’s level, the opt-in scope, the server allowlist and the plan. It then runs the exact same handler as the token’s user. Requests are strict (unknown body keys are rejected with a hint) and every non-GET call is audited as api.<operation id>.

  • Discovery: GET /v1/api/operations lists every callable operation (about 350), every job kind with its risk class, and the opt-in scopes, each marked allowed_for_this_token. It is the source of truth for what’s callable.
  • Job body schemas: GET /v1/api/job-kinds/{type}.
  • Deny by default: a /v1 route that isn’t in the table answers 403 not_exposed for Bearer requests.
  • MCP projection: each operation is also an MCP tool named after its id (dns.records_create → dns_records_create).

A handful of synchronous convenience endpoints authenticate the token themselves and return results inline. They predate the full API:

Method and pathPurpose
GET /v1/api/whoamiToken name, access_level, org_id, server_scope, role
GET /v1/api/servers · GET /v1/api/servers/{id}Servers visible to the token; one server with its last metrics
GET /v1/api/servers/{id}/{sites,services,php,databases,updates,cron,docker}Cached inventory
GET /v1/api/servers/{id}/sites/{domain}Live site info
GET /v1/api/servers/{id}/metricsLast heartbeat metrics
GET /v1/api/servers/{id}/logs?source=&lines=Live log tail (nginx-error, nginx-access, php-fpm, mariadb, syslog, auth)
GET /v1/api/servers/{id}/sslLive certificate list
POST /v1/api/servers/{id}/services/{name}/{start,stop,restart}Service control
POST /v1/api/servers/{id}/ssl/renew[?domain=]Renew certificates
POST /v1/api/servers/{id}/sites/{domain}/cache/purgePurge a site cache
POST /v1/api/servers/{id}/updates/applyApply OS updates ({"scope":"security"|"all"})
GET /v1/openapi.jsonThe OpenAPI 3.1 document of the whole API (every operation, the shortcuts and every job kind); ?tag=<area> for one area. See Import the API
GroupPurposeToken-callable
/v1/serversServers, enrolment, provisioning, inventory, metrics, sites, Docker views, agent updates, file manager (/fs), backup jobsYes (most)
/v1/servers/{id}/jobs, /v1/jobsDispatch any on-box job kind, poll, streamYes
/v1/backupsDestinations, snapshots, restoreYes
/v1/dns, /v1/domainsDNS provider connections and records, wildcard, Origin and custom certs, CDN purge; domain registryYes
/v1/mailMail host settings, sending providers, Cloudflare routing, mailbox messagesYes (message ops need mail scopes)
/v1/uptime, /v1/notify, /v1/notificationsMonitors, channels, status page; alert routing; in-app inboxYes
/v1/projects, /v1/env-vars, /v1/movesProjects and environments, shared variables, app/stack moves and clonesYes
/v1/load-balancers, /v1/networkLoad balancers, private WireGuard meshYes (Pro)
/v1/git, /v1/registry-connectionsGit provider and container registry connectionsYes
/v1/templates, /v1/notes, /v1/server-tags, /v1/site-tags, /v1/install-tokensTemplates, notes, tags, pending install tokensYes
/v1/team, /v1/orgsMembers, invites, activity; workspace renameYes (member changes need team:admin)
/v1/devDeveloper webhooksYes (Pro)
/v1/wp, /v1/links, /v1/aiWordPress directory, link manager, AI runtime overviewYes
/v1/api/metrics/prometheusFleet server metrics and uptime-monitor state in the Prometheus text format (setup)Yes (any level)
/v1/billing, /v1/account, /v1/authSubscription and wallet; profile, sessions, 2FA; sign-inNo (session only)
/v1/adminStaff consoleNo
/v1/agent/*Agent registration, binary, WebSocket upgradeAgent token only
/healthLiveness (GET https://api.mzpanel.com/health)Public

Every error uses one envelope, never a stack trace:

{ "error": { "code": "scope_required", "message": "human readable", "details": { "required_scope": "sites:delete" } } }

Clients should switch on error.code (stable), not message, and ignore fields they don’t know. The /v1/api shortcuts may add error.status. The codes an agent meets most often are unauthorized, not_exposed, access_level, scope_required, fleet_wide, tier_required, forbidden, not_found, bad_request, server_limit (402), server_offline (409) and rate_limited (429, with Retry-After). Each one is explained, with the right reaction, in the REST API quickstart error table.

Rate limits are per API token per minute: Free 60, Plus 120, Pro 300, Max 600. MCP and REST share the budget.

The agent dials outbound to wss://ws.mzpanel.com/v1/agent and holds one persistent connection, so the VPS opens no inbound ports. Messages are JSON envelopes:

type Envelope = {
v: 1; // protocol version
id: string; // message UUID
ts: number; // unix ms
type: string; // hello, welcome, heartbeat, cmd, log, job_done, event, …
ref?: string; // optional reference to another message's id
payload: unknown;
};
  1. The agent connects and sends hello (agent version, hostname, OS, sealed-credential public key). The API replies welcome.
  2. The agent sends a heartbeat every 10 s with a metrics snapshot, and pushes inventory for the cached read model.
  3. The API sends cmd envelopes (a job’s argv for the native engine). The agent streams log lines and ends with job_done (exit code and duration). cmd.cancel aborts a run.
  4. The agent pushes event envelopes for out-of-band happenings (backup done, certificate renewed, service down).

The same connection carries pty.* (web terminal), fs.* / xfer.* (file manager and cross-server transfer) and binary upload/download frames. Wire types live in the shared Go module pkg/protocol.

  • CORS is locked to the dashboard. Browser calls from other origins are rejected. Server-side clients with a Bearer token are not affected.
  • Agent routes bypass the cookie. /v1/agent/* is bearer-authed with the agent token. A browser session can’t call it, and an agent token can’t call the cookie routes.
  • Cross-org and out-of-scope ids answer 404, not 403, so the API never confirms that a resource exists.