REST API quickstart
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
The REST API is the same management surface as MCP, reachable with
plain HTTP. Use it from scripts, CI, or LLM tools that can only make HTTP calls (a
ChatGPT action, a function-calling loop). It is on every plan. On Free, writes are a
30-day trial, then read-only (402 automation_trial_ended); Plus and up have full
automation.
- Base URL:
https://api.mzpanel.com - Auth:
Authorization: Bearer mzmcp_…(mint the token at Advanced → Developer,/developer; see Tokens, levels & scopes) - Bodies: JSON,
Content-Type: application/json
Two doors, one token
Section titled “Two doors, one token”- The full management API: the dashboard’s own
/v1/*routes, called with your Bearer token. A bridge checks the token’s level, opt-in scope, server allowlist and plan, then runs the exact handler the dashboard uses. The list of callable operations isGET /v1/api/operations. Any route not in that list answers403 not_exposed. - Convenience endpoints under
/v1/api/*: a few synchronous shortcuts that return the result inline:whoami,servers,servers/{id}(+/sites,/services,/php,/databases,/updates,/cron,/dockerfrom the cache),/metrics,/logs?source=,/ssl,POST /services/{name}/{action},POST /ssl/renew,POST /sites/{domain}/cache/purgeandPOST /updates/apply.
Both doors are described in one OpenAPI 3.1 document, GET /v1/openapi.json (whole API,
or ?tag=dns for one area). To load it into Postman, n8n, Make or Pipedream, see
Import the API.
Prefer door 1 for anything beyond a quick read: it covers everything (about 350 operations, including every on-box job kind).
Discover
Section titled “Discover”export MZ=https://api.mzpanel.comexport TOKEN=mzmcp_YOUR_TOKEN
# Token identity: access_level, org_id, server_scope ("all" or ids), rolecurl -s $MZ/v1/api/whoami -H "Authorization: Bearer $TOKEN"
# Every operation + job kind + danger scope, annotated for this tokencurl -s $MZ/v1/api/operations -H "Authorization: Bearer $TOKEN" > operations.json
# The JSON Schema of one job kind's bodycurl -s $MZ/v1/api/job-kinds/site.create -H "Authorization: Bearer $TOKEN"In operations.json, each entry of operations[] has id, mcp_tool, method,
path, summary, level, scope, min_tier, body and allowed_for_this_token.
Each entry of job_kinds[] has type, level, scope, min_tier, rbac_group and
fields. Paths are written as /v1/servers/{id}/… or /v1/servers/:id/…; both mean a
path parameter.
Read the fleet
Section titled “Read the fleet”curl -s $MZ/v1/servers -H "Authorization: Bearer $TOKEN" # serverscurl -s $MZ/v1/servers/sites/all -H "Authorization: Bearer $TOKEN" # every site, every typecurl -s $MZ/v1/servers/stacks/all -H "Authorization: Bearer $TOKEN" # compose stackscurl -s $MZ/v1/servers/docker/all -H "Authorization: Bearer $TOKEN" # Docker appsSID=<server uuid>curl -s $MZ/v1/servers/$SID/inventory/services -H "Authorization: Bearer $TOKEN"/v1/servers/{id}/inventory/{kind} returns {items, meta, synced_at, is_online} from
the agent-pushed cache. The kinds are sites php php_detail ssl databases db_users db_engine pg_engine mongo_engine cron users ssh_keys stacks docker images volumes networks mail services daemons security extensions wp_content site_usage plans dns storage updates facts routes. POST …/inventory/{kind}/refresh asks the agent to
re-collect a kind; read it again a few seconds later and compare synced_at.
Run an on-box action (a job)
Section titled “Run an on-box action (a job)”# Create a static site (siteType decides the stack; WordPress is just one value)curl -s -X POST $MZ/v1/servers/$SID/jobs \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"type":"site.create","domain":"docs.example.com","siteType":"static"}'# → 202 {"job_id":"…","status":"running","stream_url":"/v1/jobs/…/stream"}
JOB=<job_id>curl -s $MZ/v1/jobs/$JOB -H "Authorization: Bearer $TOKEN"# → {"job":{"id","type","status","exitCode","errorMessage","dispatchedAt","completedAt","durationMs"}}
# Live output (server-sent events: `log` frames, then one `done` frame)curl -N -s $MZ/v1/jobs/$JOB/stream -H "Authorization: Bearer $TOKEN"Job-kind fields sit at the top level next to "type". Statuses, the offline
queue and retry rules are covered in Jobs.
Strict bodies
Section titled “Strict bodies”Bearer requests are validated strictly. The dashboard silently drops unknown keys, but an API client gets them rejected, so a misspelt field is never a silent no-op:
{ "error": { "code": "bad_request", "message": "Unrecognized key \"site_type\" (did you mean \"siteType\"?) for job type \"site.create\". GET /v1/api/job-kinds/site.create shows its schema.", "details": { "unrecognized_keys": ["site_type"], "accepted_keys": ["type", "domain", "siteType", "…"] } }}Non-job routes report unknown keys in the X-Mz-Unrecognized-Keys response header and
fail with 400. Fix the key; don’t just drop it. Keys are exactly as documented in each
operation’s body (mostly camelCase; a few older routes use snake_case, such as
destination_ids on backup jobs).
Errors
Section titled “Errors”Every error uses one envelope. Switch on error.code, never on message:
{ "error": { "code": "scope_required", "message": "…", "details": { "required_scope": "sites:delete" } } }The /v1/api/* shortcuts may add error.status. Ignore any field you don’t recognize.
| HTTP | code | Meaning | What the agent should do |
|---|---|---|---|
| 401 | unauthorized | Token missing, invalid, expired or revoked, or its owner was deleted | Stop. Ask the user for a valid token. |
| 403 | not_exposed | The route or job kind is never available to tokens (billing, 2FA, terminal, docker.exec, …) | Don’t look for a workaround. Tell the user to do it in the dashboard. |
| 403 | access_level | The token’s level is too low (details.required_level) | Ask the user for an operate or full token. |
| 403 | scope_required | The operation needs an opt-in scope (details.required_scope) | Ask the user to mint a token that carries that scope. Scopes can’t be added later. |
| 403 | fleet_wide | The operation touches servers beyond the request, and the token has a server allowlist | Use a token without an allowlist. |
| 403 | token_ip_denied | The token has an Allowed IPs list and this request came from another address (the message names it) | Don’t retry from there. Tell the user to add that public IP on the Developer page, or run from an allowed machine. |
| 403 | tier_required | The workspace plan is too low (details.required_tier on the bridge) | Report the plan needed. Don’t retry. |
| 403 | forbidden / site_permission | The token owner’s team role, or the site owner’s share settings, don’t allow it | Report it. The org owner changes roles at /team. |
| 404 | not_found | Wrong id, or outside the token’s server/mailbox allowlist (deliberately 404, not 403) | Re-list ids with servers_list. Check server_scope in whoami. |
| 400 | bad_request | Invalid body: unknown keys, wrong types, failed validation (details lists them) | Fix the body using the schema. |
| 402 | server_limit | Adding a server would exceed the plan’s VPS quota (details.limit, details.used) | Report it. The user upgrades or buys a vps-slot add-on. |
| 402 | app_limit | Creating a new Docker app or stack would exceed the plan’s Docker apps & stacks quota (details.used, details.limit, details.tier) | Report it. The user deletes an app or stack, or upgrades. Redeploying an existing name is never blocked. |
| 402 | automation_trial_ended | A write on the Free plan after its 30-day automation trial (details.required_tier: "plus", details.trial_ended_at); reads still work | Don’t retry. Tell the user to upgrade to Plus or make the change in the dashboard. |
| 400 | bad_upload / domain_required | apps_deploy: the uploadId is unknown, used or not uploaded yet; or a new app has no domain and no instant URL | Upload again with apps_source_upload + its curl; or pass domain. |
| 409 | agent_update_required | The server’s agent is too old for this call (details.current, details.required) | Run agent_update on the server, then retry. |
| 503 | direct_upload_unavailable | Direct uploads to this server aren’t available | Deploy from Git (source: {git: {url}}) instead. |
| 409 | server_offline | The agent is disconnected, and this kind is never queued (it carries secrets or env values) | Wait for the server to come online. Check servers_list, then retry once. |
| 429 | rate_limited | Over the per-token budget | Sleep for the Retry-After seconds, then continue. |
| 502 | git_token_failed and other *_failed codes | A third-party call (Git provider, DNS provider, ACME) failed | Read message, fix the upstream cause, then retry. |
Rate limits
Section titled “Rate limits”Limits are per token per minute and set by the workspace plan: Free 60, Plus 120, Pro
300, Max 600. MCP and REST share one budget. A 429 carries Retry-After (seconds).
Poll jobs every 2–5 seconds rather than in a tight loop.
What tokens cannot reach
Section titled “What tokens cannot reach”Billing, payments and wallet; account identity, emails, sessions and 2FA; the staff
console; interactive terminal sessions; install-over-SSH and agentless SSH credentials;
minting other tokens; the in-panel Assistant chat; and the routes that mint browser
logins into WordPress, phpMyAdmin, pgAdmin or webmail. These answer not_exposed. The
full list, with the reasons, is in Safe operating rules.
Related
Section titled “Related”- Control plane API: route groups and the agent WebSocket.
- Import the API into n8n, Make, Pipedream or Postman
- Jobs: dispatch, poll, stream
- Tokens, levels & scopes