Workflow templates (n8n, Zapier, Make)
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
These templates automate routine fleet work without an AI agent in the loop. Each one calls
the MZPanel REST API with an API token: on-box actions go through
POST /v1/servers/{id}/jobs?wait=60 (the job runs and its result comes back in the same
call, see Jobs), and reactions to what happens in the fleet read the
event feed GET /v1/events (every plan) or receive a signed developer webhook
(Pro and Max).
Set up once in n8n
Section titled “Set up once in n8n”- Mint a token at Advanced → Developer (
/developer). The level each template needs is in the table below; give it a server allowlist when the workflow touches one server only. - In n8n, create a credential of type Header Auth named MZPanel API token: Name
Authorization, ValueBearer mzmcp_…. - Workflows → Import from file (or paste the URL), pick the credential when n8n asks, then fill the Settings node of the workflow (server id, domain, Slack webhook URL, …).
- Activate the workflow. The polling templates keep their cursor in n8n’s workflow static data, which n8n only saves for active workflows: a manual test run starts from scratch every time. The first active run only records the newest event as a baseline, so nothing that happened before you switched it on is acted on.
| Template | Trigger | MZPanel calls | Token |
|---|---|---|---|
| Site down → restart service → Slack | every minute | GET /v1/events?types=site.down&after=<cursor>, POST /v1/servers/{serverId}/jobs?wait=60 {type: "service.action", action: "restart", name: "nginx"} | Operate |
| Nightly backup check | daily 07:00 | GET /v1/events?types=backup.completed,backup.failed&limit=100 | Read only |
| Purge cache after a deploy | webhook your CI calls | POST /v1/servers/{serverId}/jobs?wait=60 {type: "wp.cache", domain, action: "purge"} | Operate |
| New WooCommerce order → Google Sheet | every 5 minutes | GET /v1/servers/{id}/wc/orders?scope=site&domain=<shop>&per_page=50 | Read only |
| Resource-cap alert → owner | developer webhook | none (MZPanel pushes resource.cap) | none in n8n; the webhook is created with webhooks:admin |
Site down → restart a service → Slack
Section titled “Site down → restart a service → Slack”site.down fires when an uptime monitor pointing at one of your sites goes
down; the event carries serverId and the domain as subject. The workflow restarts the
service named in Settings (nginx by default; php8.3-fpm, mariadb, redis-server and
the other names of service.action work too) on that server, waits up to 60 s for the job and
posts the outcome (completed (exit 0), or the HTTP error) to a Slack incoming webhook. A
restart that does not fix the site is a sign to look at logs: see the
troubleshooting playbook.
Nightly backup check
Section titled “Nightly backup check”Counts the backup.completed and backup.failed events of the last 24 hours and stays quiet
when every run succeeded. It posts to Slack when a run failed (with the server and the job id
to open in the dashboard) or when no backup ran at all, which usually means a paused backup
job or an offline server.
Purge cache after a deploy
Section titled “Purge cache after a deploy”A webhook for your CI: after a deploy, call it with the header X-Deploy-Secret (the value in
Settings) and the body {"serverId": "<server uuid>", "domain": "example.com"}. It purges
that WordPress site’s page cache with wp.cache and answers the finished job to the caller,
so the CI step fails when the purge does:
curl -fsS -X POST https://n8n.example.com/webhook/mzpanel-deploy-done \ -H "X-Deploy-Secret: $DEPLOY_SECRET" -H 'Content-Type: application/json' \ -d '{"serverId":"'"$MZ_SERVER_ID"'","domain":"example.com"}'New WooCommerce order → Google Sheet
Section titled “New WooCommerce order → Google Sheet”Reads the newest 50 orders of one store every 5 minutes from the fast direct-database read
(wc_orders over MCP) and appends only the new ones (order number, date, status, total,
currency, customer, email, payment method, item count) to the sheet named in the Google Sheets
node. Create the sheet with those column headers first.
Resource-cap alert → owner
Section titled “Resource-cap alert → owner”Uses a developer webhook (Pro and Max): create an endpoint at Advanced → Developer →
Webhooks (or dev_webhooks_create) for the event resource.cap, pointing at the n8n
webhook URL, and paste its secret into Settings. The Code node verifies
X-MZ-Signature-V2: sha256=<hex HMAC-SHA256(secret, X-MZ-Timestamp + "." + raw body)> in
constant time and rejects timestamps more than 5 minutes off, then emails the owner which site
hit which cap. The n8n instance needs NODE_FUNCTION_ALLOW_BUILTIN=crypto for the check.
On Free and Plus, poll GET /v1/events?types=resource.cap instead (copy the polling nodes of
the first template).
Zapier
Section titled “Zapier”- Trigger on events: Webhooks by Zapier → Retrieve Poll, URL
https://api.mzpanel.com/v1/events?types=site.down,backup.failed&limit=20, headerAuthorization: Bearer mzmcp_…, keyevents. Zapier dedupes onid. - Run an action: Webhooks by Zapier → Custom Request,
POSThttps://api.mzpanel.com/v1/servers/<server id>/jobs?wait=60, same header, data{"type": "service.action", "action": "restart", "name": "nginx"}. The answer hasstatus,exitCodeand the log tail inoutput.lines. - Signed webhooks (Pro): Webhooks by Zapier → Catch Raw Hook gives the raw body; check the signature in a Code by Zapier step with the formula above before acting on it.
- Trigger on events: a scheduled HTTP → Make a request (
GET /v1/events?after=<cursor>, headerAuthorization: Bearer mzmcp_…, parse response), an Iterator overevents, and a Data store record that keepsnextCursorfor the next run. - Run an action: HTTP → Make a request,
POST /v1/servers/<id>/jobs?wait=60, body type raw JSON, the job body as above. Add an Idempotency-Key header when a scenario may retry, so a retry within 24 hours replays the first answer instead of running the job again. - Or import the OpenAPI document to get typed modules.
Errors you may see
Section titled “Errors you may see”| Answer | Meaning | Fix |
|---|---|---|
403 access_level | The token’s level is below the job’s | Mint an Operate token for templates that restart or purge |
202 with waited | The job is still running after the wait | Poll GET /v1/jobs/{job_id} |
409 server_offline / 202 queued | The server’s agent is offline | Queued jobs run when it reconnects; check GET /v1/servers |
429 rate_limited / wait_limit | Too many calls or too many waiting jobs for this token | Lower the schedule frequency; one token holds at most 5 waiting jobs |
400 bad_request “Invalid cursor” | The stored cursor is not an event id | Clear the workflow’s static data (deactivate and reactivate) |