Bỏ qua để đến nội dung
Workflow templates (n8n, Zapier, Make) Five ready-to-import n8n workflows that drive MZPanel with an API token — site down → restart a service → Slack, nightly backup check, purge the cache after a deploy, new WooCommerce order → Google Sheet, resource-cap alert → owner — plus the same recipes for Zapier and Make over plain HTTP.

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).

  1. 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.
  2. In n8n, create a credential of type Header Auth named MZPanel API token: Name Authorization, Value Bearer mzmcp_….
  3. 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, …).
  4. 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.
TemplateTriggerMZPanel callsToken
Site down → restart service → Slackevery minuteGET /v1/events?types=site.down&after=<cursor>, POST /v1/servers/{serverId}/jobs?wait=60 {type: "service.action", action: "restart", name: "nginx"}Operate
Nightly backup checkdaily 07:00GET /v1/events?types=backup.completed,backup.failed&limit=100Read only
Purge cache after a deploywebhook your CI callsPOST /v1/servers/{serverId}/jobs?wait=60 {type: "wp.cache", domain, action: "purge"}Operate
New WooCommerce order → Google Sheetevery 5 minutesGET /v1/servers/{id}/wc/orders?scope=site&domain=<shop>&per_page=50Read only
Resource-cap alert → ownerdeveloper webhooknone (MZPanel pushes resource.cap)none in n8n; the webhook is created with webhooks:admin

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.

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.

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:

Terminal window
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"}'

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.

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).

  • Trigger on events: Webhooks by Zapier → Retrieve Poll, URL https://api.mzpanel.com/v1/events?types=site.down,backup.failed&limit=20, header Authorization: Bearer mzmcp_…, key events. Zapier dedupes on id.
  • Run an action: Webhooks by Zapier → Custom Request, POST https://api.mzpanel.com/v1/servers/<server id>/jobs?wait=60, same header, data {"type": "service.action", "action": "restart", "name": "nginx"}. The answer has status, exitCode and the log tail in output.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>, header Authorization: Bearer mzmcp_…, parse response), an Iterator over events, and a Data store record that keeps nextCursor for 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.
AnswerMeaningFix
403 access_levelThe token’s level is below the job’sMint an Operate token for templates that restart or purge
202 with waitedThe job is still running after the waitPoll GET /v1/jobs/{job_id}
409 server_offline / 202 queuedThe server’s agent is offlineQueued jobs run when it reconnects; check GET /v1/servers
429 rate_limited / wait_limitToo many calls or too many waiting jobs for this tokenLower the schedule frequency; one token holds at most 5 waiting jobs
400 bad_request “Invalid cursor”The stored cursor is not an event idClear the workflow’s static data (deactivate and reactivate)