Loading ZabSys Cloud…

New Business software, email, SMS and AI built for growing companies, with support by a real team

REST API reference

Endpoints, protected by tokens, for reading how your server is doing and managing its cron jobs. Every request, response and parameter.

Quick start Get a token Metrics Cron jobs Deployment guide

Overview

The ZabMonitor REST API lets your own programs read how a server is doing and, if you allow it, manage its cron jobs. It is optional: it exists only if you answered yes to "Enable the public REST API?" when running install.sh, or turned it on later with sudo ./install.sh rest-enable. It is separate from the dashboard's own API (/api/v1, protected by the API key): a token never works there and the API key never works here.

Overview
ItemValue
Base URLhttps://<your-domain>/rest/v1 (HTTPS is required unless the agent is local-only, reached through an SSH tunnel).
FormatJSON, UTF-8. Requests with a body send Content-Type: application/json.
AuthenticationAuthorization: Bearer <token> on every call. See Authentication.
UnitsTimes are Unix seconds (UTC) unless a field says otherwise (ts in the request log is milliseconds; day/today are YYYY-MM-DD in the job's own zone). Sizes are bytes. Percentages are 0-100 with one decimal.
FreshnessMetrics are sampled every 3 seconds; responses are never cached (Cache-Control: no-store).
Rate limit240 requests per minute per client address by default (429 + Retry-After).
Lockout5 wrong tokens within 5 minutes lock that address out for 15 minutes (everything it sends gets 429, even correct tokens).
Body sizeAt most 256 KB, only on the cron write endpoints.
MethodsGET (and HEAD) everywhere; POST, PUT and DELETE only below /cron/.
BrowsersNot meant for browser pages: no CORS headers are sent. Call it from servers, scripts and tools.

Quick start

Terminal
export TOKEN='zmt_9e085d6a_...your token...'
curl -s -H "Authorization: Bearer $TOKEN" https://mon.example.com/rest/v1/status

Response: see Status summary. A 401 means the token is wrong, revoked or expired; 404 "the REST API is not enabled" means it is switched off on the server.

Getting and managing tokens

Tokens are created only on the server, as root, with install.sh. Nothing reachable over HTTP can create or change a token, so a stolen token cannot mint new ones.

Getting and managing tokens
TaskCommand
Turn the API on (asks what the first token may do, shows it once)sudo ./install.sh rest-enable
Same during installationanswer yes to Enable the public REST API?, or --rest [--rest-scopes ...] [--rest-name N] [--rest-days D] [--rest-allow IPS] with -y
Create another tokensudo ./install.sh rest-token create NAME --rest-scopes metrics:read,cron:read --rest-days 90 --rest-allow 203.0.113.0/24
List tokens (id, state, scopes, expiry, allowed addresses; never secrets)sudo ./install.sh rest-token list
Revoke a token (works immediately, no restart)sudo ./install.sh rest-token revoke ID
Turn the API off (tokens are kept but refused)sudo ./install.sh rest-disable
  • Format: zmt_<8 hex id>_<40 letters and digits>. It is shown once; the server keeps only a salted hash in /etc/zabmonitor/tokens.json (root-owned) and cannot show it again. Lost it? Revoke it and make a new one.
  • Expiry: 365 days by default (--rest-days 0 = never). Check with GET /token.
  • Address limit: --rest-allow restricts a token to listed IP addresses or ranges (IPv4 or IPv6). A valid token used from elsewhere gets 403 and counts towards the lockout.
  • Several tokens: make one per program, with only the scopes it needs, so you can revoke one without touching the others.

Authentication and scopes

Send the token in the Authorization header. It is never accepted in the URL, in a query string or in another header.

Terminal
Authorization: Bearer zmt_9e085d6a_Xk3Pq9...
Authentication and scopes
ScopeAllowsNotes
metrics:readAll endpoints under Metrics.Safe for dashboards and alerting. Exposes process names and PIDs, never command lines.
logs:readThe request log.Shows client addresses, paths and user agents of everyone who called the server.
cron:readRead jobs, runs, output, audit trail; preview schedules.Sensitive: job scripts and their output may contain secrets.
cron:writeCreate, change, delete, enable, disable and run jobs (implies cron:read).Equals running commands on the server as the allowed cron users. Give it only to programs you trust, restrict it by IP address, and prefer a low-privilege cron user.

The cron scopes only work while the Cron Jobs manager is on, and the user a job runs as must be on the administrator's allow-list, whatever the token says. The administrator can also forbid typed scripts (cron-inline off): then only script_path jobs can be created.

Errors

Errors are JSON with an error message: {"error": "invalid or missing token"}. A 403 for a missing scope adds required_scope.

Errors
StatusMeaning
400Bad input. The error text says what is wrong (bad number, invalid schedule, run_as not allowed, ...).
401Missing, malformed, wrong, revoked or expired token. The text tells which. Wrong tokens count towards the lockout.
403The token is valid but lacks the scope (required_scope is included), or it is used from an address it is not allowed from.
404Unknown endpoint or id, or the feature is not enabled (REST API off, cron manager off).
405Wrong method for that endpoint. Writing exists only under /rest/v1/cron/; PATCH is not supported (use PUT).
408 / 411Body not received in time / chunked uploads are not accepted: send Content-Length.
413Body larger than 256 KB.
415A body needs Content-Type: application/json.
429Too many requests (default 240 per minute per client address) or the address is locked out after repeated wrong tokens. Retry-After says how many seconds to wait.
503Metrics are still warming up (first seconds after a start), or the cron runner service is not running.

Examples

JSON
{
  "error": "invalid or missing token"
}   <- 401
JSON
{
  "error": "this token lacks the required scope",
  "required_scope": "logs:read"
}   <- 403 (token without logs:read)
JSON
{
  "error": "job not found"
}   <- 404
JSON
{
  "error": "invalid schedule: a schedule needs 5 fields: minute hour day-of-month month day-of-week"
}   <- 400

Service

Two housekeeping endpoints that any valid token may call.

API index

GET /rest/v1

Needs: any valid token

Lists the endpoints this token may call, so a client can discover what it is allowed to do.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1

Response 200 OK

JSON
{
  "name": "ZabMonitor REST API",
  "version": "1",
  "time": 1794044462,
  "endpoints": [
    {
      "method": "GET",
      "path": "/rest/v1",
      "scope": null
    },
    {
      "method": "GET",
      "path": "/rest/v1/token",
      "scope": null
    }
  ]
}

Response fields

API index
FieldTypeMeaning
namestringAlways ZabMonitor REST API.
versionstringAPI version, currently 1.
timeintegerServer time, Unix seconds.
endpointsarrayObjects with method, path and scope (null = any valid token). Only endpoints the token's scopes allow are listed.

Inspect your token

GET /rest/v1/token

Needs: any valid token

Shows the calling token's own details (never its secret). Use it to check scopes and the expiry date.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/token

Response 200 OK

JSON
{
  "id": "d310ffff",
  "name": "demo-full",
  "scopes": [
    "metrics:read",
    "logs:read"
  ],
  "created": 1794044461,
  "expires": null,
  "allowed_ips": []
}

Response fields

Inspect your token
FieldTypeMeaning
idstring8-character token id (also appears in the request log and the cron audit trail).
namestringName given when the token was created.
scopesarrayScopes the token holds.
createdintegerCreation time, Unix seconds.
expiresinteger|nullExpiry time, Unix seconds; null = never.
allowed_ipsarrayIP addresses/ranges the token is limited to; empty = anywhere.

Metrics

Read-only monitoring data. Values come from a sampler that refreshes every 3 seconds, so calling more often than that returns the same numbers. All endpoints need metrics:read. They answer 503 for the first few seconds after the service starts.

Status summary

GET /rest/v1/status

Needs: metrics:read

The one-call health check: overall status plus the headline numbers. Cheap enough to poll every few seconds.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/status

Response 200 OK

JSON
{
  "status": "ok",
  "time": 1794044462,
  "name": "Production Web 01",
  "hostname": "demo-server",
  "uptime": 90000,
  "cpu_percent": 23.9,
  "memory_percent": 48.1,
  "disk_max_percent": 82.0,
  "alerts": []
}

Response fields

Status summary
FieldTypeMeaning
statusstringok, warning (CPU, memory or a disk at 85% or more) or critical (95% or more, or a watched service is not active).
timeintegerWhen the numbers were sampled, Unix seconds (sampled every 3 s).
namestringDisplay name chosen at install time (hostname if none).
hostnamestringThe machine's hostname.
uptimeintegerSeconds since boot.
cpu_percentnumberTotal CPU use, 0-100.
memory_percentnumberMemory in use (excluding reclaimable cache), 0-100.
disk_max_percentnumberFullest disk, 0-100.
alertsarrayHuman-readable reasons for any warning/critical status; empty when ok.

Server information

GET /rest/v1/server

Needs: metrics:read

Identity and state of the machine.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/server

Response 200 OK

JSON
{
  "time": 1794044462,
  "status": "ok",
  "alerts": [],
  "host": {
    "name": "Production Web 01",
    "hostname": "demo-server",
    "os": "Ubuntu 24.04 LTS (simulated)",
    "kernel": "6.8.0",
    "arch": "x86_64",
    "uptime": 90000
  }
}

Response fields

Server information
FieldTypeMeaning
timeintegerSample time, Unix seconds.
statusstringSame as in status.
alertsarraySame as in status.
hostobjectname (display name), hostname, os (pretty OS name), kernel, arch, uptime (seconds).

CPU

GET /rest/v1/cpu

Needs: metrics:read

CPU use and load averages.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/cpu

Response 200 OK

JSON
{
  "time": 1794044462,
  "percent": 23.9,
  "cores": 4,
  "load": [
    0.42,
    0.37
  ]
}

Response fields

CPU
FieldTypeMeaning
timeintegerSample time.
percentnumberTotal CPU use across all cores since the previous sample, 0-100.
coresintegerNumber of logical CPUs.
loadarrayLoad average over 1, 5 and 15 minutes.

Memory and swap

GET /rest/v1/memory

Needs: metrics:read

All sizes are in bytes.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/memory

Response 200 OK

JSON
{
  "time": 1794044462,
  "total": 8589934592,
  "used": 4131758538,
  "available": 4458176053,
  "percent": 48.1,
  "swap_total": 2147483648,
  "swap_used": 107374182,
  "swap_percent": 5.0
}

Response fields

Memory and swap
FieldTypeMeaning
timeintegerSample time.
totalintegerInstalled memory.
usedintegerMemory in use (total minus available).
availableintegerMemory that can be given to programs without swapping.
percentnumberused as a percentage of total.
swap_totalintegerSwap size (0 if none).
swap_usedintegerSwap in use.
swap_percentnumberSwap in use, 0-100.

Disks

GET /rest/v1/disks

Needs: metrics:read

Mounted real file systems (ext4, xfs, btrfs, ...). Virtual and container mounts are left out.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/disks

Response 200 OK

JSON
{
  "time": 1794044462,
  "disks": [
    {
      "mount": "/",
      "fs": "ext4",
      "total": 107374182400,
      "used": 67645734912,
      "percent": 63.0
    },
    {
      "mount": "/data",
      "fs": "xfs",
      "total": 536870912000,
      "used": 440234147840,
      "percent": 82.0
    }
  ]
}

Response fields

Disks
FieldTypeMeaning
timeintegerSample time.
disksarrayObjects: mount (mount point), fs (type), total, used (bytes), percent (0-100).

Network

GET /rest/v1/network

Needs: metrics:read

Totals and current speed across all physical interfaces (loopback, Docker and virtual interfaces are excluded).

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/network

Response 200 OK

JSON
{
  "time": 1794044462,
  "rx_bytes": 55834574848,
  "tx_bytes": 9663676416,
  "rx_rate": 161966,
  "tx_rate": 42377
}

Response fields

Network
FieldTypeMeaning
timeintegerSample time.
rx_bytesintegerBytes received since boot.
tx_bytesintegerBytes sent since boot.
rx_rateintegerCurrent receive speed, bytes per second.
tx_rateintegerCurrent send speed, bytes per second.

Temperature

GET /rest/v1/temperature

Needs: metrics:read

Highest thermal-zone temperature.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/temperature

Response 200 OK

JSON
{
  "time": 1794044462,
  "celsius": 54.0
}

Response fields

Temperature
FieldTypeMeaning
timeintegerSample time.
celsiusnumber|nullDegrees Celsius; null when the machine exposes no sensor (many virtual servers).

Watched services

GET /rest/v1/services

Needs: metrics:read

The systemd services chosen at install time (--services), checked every 10 seconds. An empty list means none are watched.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/services

Response 200 OK

JSON
{
  "time": 1794044462,
  "services": [
    {
      "name": "nginx",
      "state": "active",
      "active": true
    },
    {
      "name": "sshd",
      "state": "active",
      "active": true
    }
  ]
}

Response fields

Watched services
FieldTypeMeaning
timeintegerSample time.
servicesarrayObjects: name, state (the systemctl is-active answer, e.g. active, inactive, failed), active (boolean).

Top processes

GET /rest/v1/processes

Needs: metrics:read

The five biggest CPU and memory users. Only the process name and PID are exposed, never command lines or arguments.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/processes

Response 200 OK

JSON
{
  "time": 1794044462,
  "count": 143,
  "top_cpu": [
    {
      "pid": 811,
      "name": "mysqld",
      "cpu": 12.4,
      "mem": 671088640
    },
    {
      "pid": 1203,
      "name": "nginx",
      "cpu": 3.1,
      "mem": 41943040
    }
  ],
  "top_mem": [
    {
      "pid": 811,
      "name": "mysqld",
      "cpu": 12.4,
      "mem": 671088640
    },
    {
      "pid": 2210,
      "name": "python3",
      "cpu": 1.0,
      "mem": 220200960
    }
  ]
}

Response fields

Top processes
FieldTypeMeaning
timeintegerSample time.
countintegerTotal number of processes.
top_cpuarrayObjects: pid, name (max 32 characters), cpu (percent of one core), mem (resident bytes).
top_memarraySame objects, ordered by memory.

Everything at once

GET /rest/v1/metrics

Needs: metrics:read

All of the above in one document.

Query parameters

Everything at once
NameTypeDefaultDescription
historyinteger01 adds a history array (the last ~6 minutes, see history).

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/metrics

Response 200 OK

JSON
{
  "time": 1794044462,
  "status": "ok",
  "alerts": [],
  "host": {
    "name": "Production Web 01",
    "hostname": "demo-server",
    "os": "Ubuntu 24.04 LTS (simulated)",
    "kernel": "6.8.0",
    "arch": "x86_64",
    "uptime": 90000
  },
  "cpu": {
    "percent": 24.0,
    "cores": 4,
    "load": [
      0.42,
      0.37
    ]
  },
  "memory": {
    "total": 8589934592,
    "used": 4131758538,
    "available": 4458176053,
    "percent": 48.1,
    "swap_total": 2147483648,
    "swap_used": 107374182,
    "swap_percent": 5.0
  },
  "disks": [
    {
      "mount": "/",
      "fs": "ext4",
      "total": 107374182400,
      "used": 67645734912,
      "percent": 63.0
    },
    {
      "mount": "/data",
      "fs": "xfs",
      "total": 536870912000,
      "used": 440234147840,
      "percent": 82.0
    }
  ],
  "network": {
    "rx_bytes": 55834574848,
    "tx_bytes": 9663676416,
    "rx_rate": 162038,
    "tx_rate": 42392
  },
  "temperature": 54.0,
  "services": [
    {
      "name": "nginx",
      "state": "active",
      "active": true
    },
    {
      "name": "sshd",
      "state": "active",
      "active": true
    }
  ],
  "processes": {
    "count": 143,
    "top_cpu": [
      {
        "pid": 811,
        "name": "mysqld",
        "cpu": 12.4,
        "mem": 671088640
      },
      {
        "pid": 1203,
        "name": "nginx",
        "cpu": 3.1,
        "mem": 41943040
      }
    ],
    "top_mem": [
      {
        "pid": 811,
        "name": "mysqld",
        "cpu": 12.4,
        "mem": 671088640
      },
      {
        "pid": 2210,
        "name": "python3",
        "cpu": 1.0,
        "mem": 220200960
      }
    ]
  }
}

Response fields

Everything at once
FieldTypeMeaning
time, status, alerts, host, cpu, memory, disks, network, temperature, services, processesExactly the objects described for the individual endpoints, in one response.

Recent history

GET /rest/v1/history

Needs: metrics:read

The in-memory history of the last ~6 minutes (one point every 3 seconds, up to 120 points). It is lost when the service restarts. For long-term graphs, collect the numbers yourself by polling.

Query parameters

Recent history
NameTypeDefaultDescription
limitinteger120How many of the newest points to return (1-120).

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  "https://mon.example.com/rest/v1/history?limit=3"

Response 200 OK

JSON
{
  "interval_seconds": 3,
  "points": [
    {
      "t": 1794044462,
      "cpu": 24.0,
      "mem": 48.1,
      "rx": 162020,
      "tx": 42388
    },
    {
      "t": 1794044462,
      "cpu": 24.0,
      "mem": 48.1,
      "rx": 162038,
      "tx": 42392
    }
  ]
}

Response fields

Recent history
FieldTypeMeaning
interval_secondsintegerSeconds between points.
pointsarrayOldest first. Objects: t (time), cpu (%), mem (%), rx, tx (bytes per second).

Errors for this endpoint

Recent history
StatusWhen
400limit is not a number.

Request log

The server's own record of recent requests. Needs logs:read.

Recent requests

GET /rest/v1/logs

Needs: logs:read

The server's in-memory log of the last 1000 requests (any endpoint, including failed logins). Secrets are redacted before they are stored and the log is never written to disk. Fetching the log does not add entries to it.

Query parameters

Recent requests
NameTypeDefaultDescription
sinceinteger0Return only entries with an id greater than this (poll with the latest value you got last time).
limitinteger200Maximum entries, 1-500 (the newest ones).

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  "https://mon.example.com/rest/v1/logs?limit=3"

Response 200 OK

JSON
{
  "latest": 13,
  "entries": [
    {
      "id": 11,
      "ts": 1794044462431,
      "ip": "127.0.0.1",
      "method": "GET",
      "path": "/rest/v1/processes",
      "auth": "token:d310ffff",
      "status": 200,
      "ms": 0.4,
      "bytes": 274,
      "ua": "Python-urllib/3.14"
    },
    {
      "id": 12,
      "ts": 1794044462432,
      "ip": "127.0.0.1",
      "method": "GET",
      "path": "/rest/v1/metrics",
      "auth": "token:d310ffff",
      "status": 200,
      "ms": 0.4,
      "bytes": 1107,
      "ua": "Python-urllib/3.14"
    }
  ]
}

Response fields

Recent requests
FieldTypeMeaning
latestintegerId of the newest entry in the log.
entriesarrayObjects: id, ts (milliseconds), ip, method, path, auth (ok, fail, token:<id>, locked, limited, none), status, ms, bytes, ua.

Errors for this endpoint

Recent requests
StatusWhen
400since or limit is not a number.

One request in detail

GET /rest/v1/logs/{id}

Needs: logs:read

The full record: request and response headers (credentials shown only as [redacted, N chars]) and a short response preview (never for cron endpoints).

Path parameters

One request in detail
NameDescription
idEntry id from the list.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/logs/11

Response 200 OK

JSON
{
  "ts": 1794044462431,
  "ip": "127.0.0.1",
  "peer": "127.0.0.1",
  "method": "GET",
  "path": "/rest/v1/processes",
  "query": "",
  "proto": "HTTP/1.1",
  "auth": "token:d310ffff",
  "status": 200,
  "ms": 0.4,
  "bytes": 274,
  "ua": "Python-urllib/3.14",
  "req_headers": [
    [
      "Accept-Encoding",
      "identity"
    ],
    [
      "Host",
      "127.0.0.1:18899"
    ]
  ],
  "resp_headers": [
    [
      "Server",
      "ZabMonitor"
    ],
    [
      "Date",
      "Sat, 07 Nov 2026 09:41:02 GMT"
    ]
  ],
  "type": "application/json",
  "preview": "{\"time\":1794044462,\"count\":143,\"top_cpu\":[{\"pid\":811,\"name\":\"mysqld\",\"cpu\":12.4,\"mem\":671088640},{\"pid\":1203,\"name\":\"nginx\",\"cpu\":3.1,\"mem\":41943040}],\"top_mem\":[{\"pid\":811,\"name\":\"mysqld\",\"cpu\":12.4,\"mem\":671088640},{\"pid\":2210,\"name\":\"python3\",\"cpu\":1.0,\"mem\":220200960}]}",
  "id": 11
}

Response fields

One request in detail
FieldTypeMeaning
id, ts, ip, peer, method, path, query, proto, auth, status, ms, bytes, uaAs in the list, plus peer (the connection's address) and query (secret-looking values redacted).
req_headers, resp_headersarrayLists of [name, value] pairs.
typestringResponse content type.
previewstringFirst part of the response body (empty for cron paths).

Errors for this endpoint

One request in detail
StatusWhen
404The entry is unknown or already rolled out of the 1000-entry buffer.

Cron jobs

Create, change, run and inspect scheduled scripts. Needs the Cron Jobs manager to be enabled on the server (otherwise every endpoint here answers 404). Reading needs cron:read; anything that changes or runs something needs cron:write, which means running commands on the server as the users the administrator allowed.

The job object

Returned by the job endpoints. Fields you can send are described under "JSON body" of Create a job.

Cron jobs
FieldTypeMeaning
idintegerJob id.
name, schedule, tz, script, script_path, run_as, timeout_sAs sent. schedule has macros expanded. Exactly one of script / script_path is non-empty.
enabledinteger1 scheduled, 0 paused.
next_runinteger|nullNext planned run, Unix seconds; null when paused.
created_at, updated_atintegerUnix seconds.
last_runobject|nullNewest run: id, status, started_at, finished_at, exit_code, trig.
runningbooleanA run is in progress right now.
todaystringToday's date (YYYY-MM-DD) in the job's own time zone.
daysarrayThe last 14 days in the job's zone: day, success, failed, missed, skipped (only in single-job and list responses).

The run object

Cron jobs
FieldTypeMeaning
id, job_idintegerRun id and its job.
job_namestringOnly in the single-run response.
trigstringschedule (started by the schedule) or manual (the run endpoint or the dashboard).
scheduled_for, started_at, finished_atinteger|nullUnix seconds.
exit_codeinteger|nullThe script's exit status; null when it never ran or was killed.
run_asstringThe user it ran as.
outputstringCombined stdout and stderr, only the last 64 KB. Only in the single-run response.
truncatedinteger1 when the output was cut to 64 KB.
statusstringsuccess (exit 0); failed (non-zero exit); timeout (stopped after timeout_s); killed (the service stopped while it ran); missed (the server was down at the scheduled time; it is never run late); skipped (the previous run of the job was still going); running.

Cron manager information

GET /rest/v1/cron/info

Needs: cron:read (cron:write also works)

What the server allows. Read this before creating jobs. All cron endpoints answer 404 with the cron manager is not enabled on this server when the administrator did not enable it.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/cron/info

Response 200 OK

JSON
{
  "users": [
    "zabcron",
    "demo"
  ],
  "default_timeout": 600,
  "max_timeout": 86400,
  "now": 1794044462,
  "timezone": "UTC",
  "tz_name": "UTC",
  "utc_offset": 0,
  "retention_days": 90,
  "named_zones": true,
  "allow_inline": true,
  "script_dirs": [],
  "jobs_dir": "/run/zabmonitor-cron/jobs",
  "data_dir": "/var/lib/zabmonitor"
}

Response fields

Cron manager information
FieldTypeMeaning
usersarraySystem users jobs may run as (the allow-list). A job with any other run_as is refused.
default_timeout, max_timeoutintegerJob timeout default and ceiling, seconds.
nowintegerServer time, Unix seconds.
timezone, tz_name, utc_offsetThe server's local time zone (abbreviation, IANA name when known, offset in seconds).
named_zonesbooleanWhether IANA zone names such as Asia/Tokyo work in tz (otherwise use fixed offsets).
allow_inlinebooleanWhether script (typed script text) is accepted. When false only script_path works.
script_dirsarrayIf not empty, script_path must be inside one of these folders.
retention_daysintegerHow long run history is kept (also at most 500 runs per job).
jobs_dir, data_dirstringServer folders used by the runner (informational).

Preview a schedule

POST /rest/v1/cron/preview

Needs: cron:read (cron:write also works)

Calculates the next run times of a schedule without saving anything. Useful for checking a cron expression and a time zone.

JSON body

Preview a schedule
FieldTypeRequiredDescription
schedulestringyesCron expression or macro, as for jobs.
tzstringnoTime zone, as for jobs.
countintegernoHow many times to return, 1-10 (default 5).

Example request

Terminal
curl -s \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  https://mon.example.com/rest/v1/cron/preview \
  -d '{"schedule": "0 2 * * *", "tz": "UTC+09:00", "count": 3}'

Response 200 OK

JSON
{
  "schedule": "0 2 * * *",
  "tz": "UTC+09:00",
  "next": [
    1794081600,
    1794168000
  ]
}

Response fields

Preview a schedule
FieldTypeMeaning
schedulestringThe normalised schedule (macros expanded).
tzstringThe zone you sent.
nextarrayThe next run times, Unix seconds.

Errors for this endpoint

Preview a schedule
StatusWhen
400Invalid schedule or time zone (the message says what is wrong).

List jobs

GET /rest/v1/cron/jobs

Needs: cron:read (cron:write also works)

All jobs, sorted by name, each with its last run and a 14-day summary. Treat the response as sensitive: it contains the script text of typed jobs.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/cron/jobs

Response 200 OK

JSON
[
  {
    "id": 2,
    "name": "Clean old logs",
    "schedule": "*/15 * * * *",
    "script": "find /var/log -name '*.gz' -mtime +30 -delete\necho cleaned",
    "run_as": "zabcron",
    "timeout_s": 600,
    "enabled": 1,
    "next_run": 1794044700,
    "tz": "",
    "script_path": "",
    "created_at": 1794044461,
    "updated_at": 1794044461,
    "last_run": {
      "id": 28,
      "status": "success",
      "started_at": 1793958061,
      "finished_at": 1793958138,
      "exit_code": 0,
      "trig": "schedule"
    },
    "running": false,
    "today": "2026-11-07",
    "days": [
      {
        "day": "2026-10-24",
        "success": 1,
        "failed": 0,
        "missed": 0,
        "skipped": 0
      },
      {
        "day": "2026-10-25",
        "success": 1,
        "failed": 0,
        "missed": 0,
        "skipped": 0
      }
    ]
  },
  {
    "id": 1,
    "name": "Daily database backup",
    "schedule": "0 0 * * *",
    "script": "#!/bin/bash\nset -euo pipefail\necho \"dumping database...\"\nsleep 1\necho \"backup OK: 1.2 GB\"\n",
    "run_as": "zabcron",
    "timeout_s": 600,
    "enabled": 1,
    "next_run": 1794074400,
    "tz": "UTC+09:00",
    "script_path": "",
    "created_at": 1794044461,
    "updated_at": 1794044461,
    "last_run": {
      "id": 14,
      "status": "success",
      "started_at": 1793958061,
      "finished_at": 1793958069,
      "exit_code": 0,
      "trig": "schedule"
    },
    "running": false,
    "today": "2026-11-07",
    "days": [
      {
        "day": "2026-10-24",
        "success": 1,
        "failed": 0,
        "missed": 0,
        "skipped": 0
      },
      {
        "day": "2026-10-25",
        "success": 1,
        "failed": 0,
        "missed": 0,
        "skipped": 0
      }
    ]
  }
]

Response fields

List jobs
FieldTypeMeaning
(array)arrayJob objects, described under The job object.

Create a job

POST /rest/v1/cron/jobs

Needs: cron:write

Creates a job. It starts running on its schedule right away (unless enabled is false). This lets the caller run commands on the server as the allowed users.

JSON body

Create a job
FieldTypeRequiredDescription
namestringyes (create)1-80 characters, no control characters.
schedulestringyes (create)Five cron fields minute hour day-of-month month day-of-week (lists 1,15, ranges 1-5, steps */10, month/day names) or one of @hourly @daily @midnight @weekly @monthly @yearly @annually. When both day fields are restricted, either may match (classic cron rule).
tzstringnoZone the schedule is read in: empty = server local time, UTC, a fixed offset UTC+09:00, or an IANA name such as Asia/Tokyo (needs Python 3.9+ and tzdata on the server; see named_zones in cron/info).
scriptstringone of script / script_pathThe bash script text (max 100 KB). Refused with 400 when the administrator switched typed scripts off at install time (allow_inline is false in cron/info).
script_pathstringone of script / script_pathAbsolute path of a script file that already exists on the server. It must be a regular file owned by root or the run-as user (root jobs: root only), with no symbolic links, and neither the file nor any parent folder writable by group or others. Checked at save time and before every run. If given, script is ignored.
run_asstringnoSystem user the job runs as. Must be on the server's allow-list (users in cron/info); default: the first allowed user. Anything else is refused with 400, always.
timeout_sintegernoSeconds before the job is stopped, 1 to max_timeout (cron/info). Default: default_timeout.
enabledbooleannoCreate: false creates the job paused. Update: switches it. Prefer the enable/disable endpoints to change it later.

Example request

Terminal
curl -s \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  https://mon.example.com/rest/v1/cron/jobs \
  -d '{"name": "Nightly database backup", "schedule": "0 2 * * *", "tz": "UTC+09:00", "run_as": "zabcron", "timeout_s": 1800, "script": "#!/bin/bash\nset -euo pipefail\necho \"dumping database...\"\nsleep 1\necho \"backup OK: 1.2 GB\"\n"}'

Response 201 Created

JSON
{
  "id": 4,
  "name": "Nightly database backup",
  "schedule": "0 2 * * *",
  "script": "#!/bin/bash\nset -euo pipefail\necho \"dumping database...\"\nsleep 1\necho \"backup OK: 1.2 GB\"\n",
  "run_as": "zabcron",
  "timeout_s": 1800,
  "enabled": 1,
  "next_run": 1794081600,
  "tz": "UTC+09:00",
  "script_path": "",
  "created_at": 1794044462,
  "updated_at": 1794044462,
  "last_run": null,
  "running": false,
  "today": "2026-11-07"
}

Response fields

Create a job
FieldTypeMeaning
(job)objectThe new job, described under The job object.

Errors for this endpoint

Create a job
StatusWhen
400Invalid input: bad schedule/zone, run_as not allowed, empty script, typed scripts switched off, unsafe script_path, bad timeout.
413Body over 256 KB.
415Content-Type is not application/json.

Get one job

GET /rest/v1/cron/jobs/{id}

Needs: cron:read (cron:write also works)

One job object.

Path parameters

Get one job
NameDescription
idJob id.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/cron/jobs/4

Response 200 OK

JSON
{
  "id": 4,
  "name": "Nightly database backup",
  "schedule": "0 2 * * *",
  "script": "#!/bin/bash\nset -euo pipefail\necho \"dumping database...\"\nsleep 1\necho \"backup OK: 1.2 GB\"\n",
  "run_as": "zabcron",
  "timeout_s": 1800,
  "enabled": 1,
  "next_run": 1794081600,
  "tz": "UTC+09:00",
  "script_path": "",
  "created_at": 1794044462,
  "updated_at": 1794044462,
  "last_run": null,
  "running": false,
  "today": "2026-11-07",
  "days": []
}

Response fields

Get one job
FieldTypeMeaning
(job)objectSee The job object.

Errors for this endpoint

Get one job
StatusWhen
404No such job.

Update a job

PUT /rest/v1/cron/jobs/{id}

Needs: cron:write

Changes only the fields you send (a partial update); everything else stays. The next run time is recalculated.

Path parameters

Update a job
NameDescription
idJob id.

JSON body

Update a job
FieldTypeRequiredDescription
namestringyes (create)1-80 characters, no control characters.
schedulestringyes (create)Five cron fields minute hour day-of-month month day-of-week (lists 1,15, ranges 1-5, steps */10, month/day names) or one of @hourly @daily @midnight @weekly @monthly @yearly @annually. When both day fields are restricted, either may match (classic cron rule).
tzstringnoZone the schedule is read in: empty = server local time, UTC, a fixed offset UTC+09:00, or an IANA name such as Asia/Tokyo (needs Python 3.9+ and tzdata on the server; see named_zones in cron/info).
scriptstringone of script / script_pathThe bash script text (max 100 KB). Refused with 400 when the administrator switched typed scripts off at install time (allow_inline is false in cron/info).
script_pathstringone of script / script_pathAbsolute path of a script file that already exists on the server. It must be a regular file owned by root or the run-as user (root jobs: root only), with no symbolic links, and neither the file nor any parent folder writable by group or others. Checked at save time and before every run. If given, script is ignored.
run_asstringnoSystem user the job runs as. Must be on the server's allow-list (users in cron/info); default: the first allowed user. Anything else is refused with 400, always.
timeout_sintegernoSeconds before the job is stopped, 1 to max_timeout (cron/info). Default: default_timeout.
enabledbooleannoCreate: false creates the job paused. Update: switches it. Prefer the enable/disable endpoints to change it later.

Example request

Terminal
curl -s \
  -X PUT \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  https://mon.example.com/rest/v1/cron/jobs/4 \
  -d '{"schedule": "30 1 * * *", "timeout_s": 3600}'

Response 200 OK

JSON
{
  "id": 4,
  "name": "Nightly database backup",
  "schedule": "30 1 * * *",
  "script": "#!/bin/bash\nset -euo pipefail\necho \"dumping database...\"\nsleep 1\necho \"backup OK: 1.2 GB\"\n",
  "run_as": "zabcron",
  "timeout_s": 3600,
  "enabled": 1,
  "next_run": 1794079800,
  "tz": "UTC+09:00",
  "script_path": "",
  "created_at": 1794044462,
  "updated_at": 1794044462,
  "last_run": null,
  "running": false,
  "today": "2026-11-07"
}

Response fields

Update a job
FieldTypeMeaning
(job)objectThe updated job.

Errors for this endpoint

Update a job
StatusWhen
400Invalid input, or nothing to update.
404No such job.

Delete a job

DELETE /rest/v1/cron/jobs/{id}

Needs: cron:write

Deletes the job and its whole run history. A job that is running right now cannot be deleted.

Path parameters

Delete a job
NameDescription
idJob id.

Example request

Terminal
curl -s \
  -X DELETE \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/cron/jobs/4

Response 200 OK

JSON
{
  "deleted": 4
}

Response fields

Delete a job
FieldTypeMeaning
deletedintegerId of the deleted job.

Errors for this endpoint

Delete a job
StatusWhen
404No such job.
409The job is running; wait for it to finish.

Run a job now

POST /rest/v1/cron/jobs/{id}/run

Needs: cron:write

Starts the job immediately, in addition to its schedule. The call returns at once; the job runs in the background. Poll cron/runs/{id} with the returned run id until status is no longer running.

Path parameters

Run a job now
NameDescription
idJob id.

Example request

Terminal
curl -s \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/cron/jobs/4/run

Response 202 Accepted

JSON
{
  "run_id": 43
}

Response fields

Run a job now
FieldTypeMeaning
run_idintegerId of the run that was started.

Errors for this endpoint

Run a job now
StatusWhen
400The job's user is no longer on the allow-list, or its script file is no longer acceptable.
404No such job.
409The job is already running.

Enable a job

POST /rest/v1/cron/jobs/{id}/enable

Needs: cron:write

Turns the schedule on and recalculates the next run. Send an empty JSON object {} (or no body).

Path parameters

Enable a job
NameDescription
idJob id.

Example request

Terminal
curl -s \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  https://mon.example.com/rest/v1/cron/jobs/4/enable \
  -d '{}'

Response 200 OK

JSON
{
  "id": 4,
  "name": "Nightly database backup",
  "schedule": "30 1 * * *",
  "script": "#!/bin/bash\nset -euo pipefail\necho \"dumping database...\"\nsleep 1\necho \"backup OK: 1.2 GB\"\n",
  "run_as": "zabcron",
  "timeout_s": 3600,
  "enabled": 1,
  "next_run": 1794079800,
  "tz": "UTC+09:00",
  "script_path": "",
  "created_at": 1794044462,
  "updated_at": 1794044462,
  "last_run": null,
  "running": false,
  "today": "2026-11-07"
}

Response fields

Enable a job
FieldTypeMeaning
(job)objectThe job with enabled: 1 and a next_run.

Errors for this endpoint

Enable a job
StatusWhen
404No such job.

Disable a job

POST /rest/v1/cron/jobs/{id}/disable

Needs: cron:write

Pauses the schedule (the job and its history are kept; no run starts by itself).

Path parameters

Disable a job
NameDescription
idJob id.

Example request

Terminal
curl -s \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/cron/jobs/4/disable

Response 200 OK

JSON
{
  "id": 4,
  "name": "Nightly database backup",
  "schedule": "30 1 * * *",
  "script": "#!/bin/bash\nset -euo pipefail\necho \"dumping database...\"\nsleep 1\necho \"backup OK: 1.2 GB\"\n",
  "run_as": "zabcron",
  "timeout_s": 3600,
  "enabled": 0,
  "next_run": null,
  "tz": "UTC+09:00",
  "script_path": "",
  "created_at": 1794044462,
  "updated_at": 1794044462,
  "last_run": null,
  "running": false,
  "today": "2026-11-07"
}

Response fields

Disable a job
FieldTypeMeaning
(job)objectThe job with enabled: 0 and next_run: null.

Errors for this endpoint

Disable a job
StatusWhen
404No such job.

Run history of a job

GET /rest/v1/cron/jobs/{id}/runs

Needs: cron:read (cron:write also works)

Executions of the job, newest first. The list leaves out the output text; get it from cron/runs/{id}.

Path parameters

Run history of a job
NameDescription
idJob id.

Query parameters

Run history of a job
NameTypeDefaultDescription
statusstringallall, success, failed (failed, timeout and killed), missed, skipped or running.
from, tointegernoneOnly runs that started at or after from / at or before to (Unix seconds).
limitinteger30Page size (maximum 500).
offsetinteger0Skip this many runs.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  "https://mon.example.com/rest/v1/cron/jobs/4/runs?status=success&limit=5"

Response 200 OK

JSON
{
  "total": 1,
  "runs": [
    {
      "id": 43,
      "job_id": 4,
      "trig": "manual",
      "scheduled_for": null,
      "started_at": 1794044462,
      "finished_at": 1794044463,
      "status": "success",
      "exit_code": 0,
      "run_as": "zabcron",
      "truncated": 0
    }
  ]
}

Response fields

Run history of a job
FieldTypeMeaning
totalintegerNumber of runs matching the filter (before limit/offset).
runsarrayRun objects without output, described under The run object.

Errors for this endpoint

Run history of a job
StatusWhen
400from/to are not Unix timestamps.
404No such job.

Daily summary of a job

GET /rest/v1/cron/jobs/{id}/summary

Needs: cron:read (cron:write also works)

Counts of runs per day, computed in the job's own time zone.

Path parameters

Daily summary of a job
NameDescription
idJob id.

Query parameters

Daily summary of a job
NameTypeDefaultDescription
daysinteger30How many days back.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  "https://mon.example.com/rest/v1/cron/jobs/4/summary?days=7"

Response 200 OK

JSON
{
  "days": [
    {
      "day": "2026-11-07",
      "success": 1,
      "failed": 0,
      "missed": 0,
      "skipped": 0
    }
  ],
  "totals": {
    "runs": 1,
    "success": 1,
    "failed": 0,
    "missed": 0,
    "skipped": 0
  }
}

Response fields

Daily summary of a job
FieldTypeMeaning
daysarrayObjects: day (YYYY-MM-DD in the job's zone), success, failed, missed, skipped.
totalsobjectruns, success, failed, missed, skipped over all kept history.

Errors for this endpoint

Daily summary of a job
StatusWhen
404No such job.

One run, with its output

GET /rest/v1/cron/runs/{id}

Needs: cron:read (cron:write also works)

A single execution including the program output. The output can contain secrets printed by your script: treat it as sensitive.

Path parameters

One run, with its output
NameDescription
idRun id (from a list or from run).

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  https://mon.example.com/rest/v1/cron/runs/43

Response 200 OK

JSON
{
  "id": 43,
  "job_id": 4,
  "job_name": "Nightly database backup",
  "trig": "manual",
  "scheduled_for": null,
  "started_at": 1794044462,
  "finished_at": 1794044463,
  "status": "success",
  "exit_code": 0,
  "run_as": "zabcron",
  "output": "dumping database...\nbackup OK: 1.2 GB\n",
  "truncated": 0
}

Response fields

One run, with its output
FieldTypeMeaning
(run)objectRun object plus output and job_name; see The run object.

Errors for this endpoint

One run, with its output
StatusWhen
404No such run (history is pruned after 90 days / 500 runs per job).

Audit trail

GET /rest/v1/cron/audit

Needs: cron:read (cron:write also works)

Who changed what: every create, update, delete, enable, disable and manual run, newest first. Calls made through this API are recorded with the client address and the token id, e.g. 203.0.113.7 token:9e085d6a.

Query parameters

Audit trail
NameTypeDefaultDescription
limitinteger100Maximum entries.

Example request

Terminal
curl -s \
  -H "Authorization: Bearer $TOKEN" \
  "https://mon.example.com/rest/v1/cron/audit?limit=3"

Response 200 OK

JSON
[
  {
    "ts": 1794044462,
    "ip": "127.0.0.1 token:d310ffff",
    "action": "run_now",
    "job_id": 4,
    "detail": "Nightly database backup"
  },
  {
    "ts": 1794044462,
    "ip": "127.0.0.1 token:d310ffff",
    "action": "enable",
    "job_id": 4,
    "detail": "Nightly database backup"
  }
]

Response fields

Audit trail
FieldTypeMeaning
(array)arrayObjects: ts (Unix seconds), ip (who), action, job_id, detail.

Examples

Python (standard library)

Python
import json, urllib.request

BASE, TOKEN = "https://mon.example.com/rest/v1", "zmt_9e085d6a_..."

def api(method, path, body=None):
    req = urllib.request.Request(BASE + path, method=method, headers={"Authorization": "Bearer " + TOKEN})
    if body is not None:
        req.add_header("Content-Type", "application/json")
        req.data = json.dumps(body).encode()
    with urllib.request.urlopen(req, timeout=20) as r:      # raises HTTPError on 4xx/5xx; the body has {"error": ...}
        return json.loads(r.read())

s = api("GET", "/status")
if s["status"] != "ok":
    print("ALERT:", s["alerts"])
print("CPU %s%%  memory %s%%  fullest disk %s%%" % (s["cpu_percent"], s["memory_percent"], s["disk_max_percent"]))

Node.js (18+)

Node.js
const BASE = "https://mon.example.com/rest/v1", TOKEN = "zmt_9e085d6a_...";
async function api(method, path, body) {
  const r = await fetch(BASE + path, { method, headers: { Authorization: "Bearer " + TOKEN, ...(body && { "Content-Type": "application/json" }) }, body: body && JSON.stringify(body) });
  const data = await r.json();
  if (!r.ok) throw new Error(r.status + " " + data.error);
  return data;
}
console.log(await api("GET", "/memory"));

Shell: create a nightly job, run it now, read the result

Terminal
AUTH="Authorization: Bearer $TOKEN"; API=https://mon.example.com/rest/v1

# 1. which users may jobs run as?
curl -s -H "$AUTH" $API/cron/info | python3 -c 'import sys,json; print(json.load(sys.stdin)["users"])'

# 2. create the job (daily at 02:00 Tokyo time) and keep its id
ID=$(curl -s -H "$AUTH" -H "Content-Type: application/json" $API/cron/jobs -d '{
  "name": "Nightly backup", "schedule": "0 2 * * *", "tz": "Asia/Tokyo", "run_as": "zabcron",
  "script": "#!/bin/bash\nset -e\n/usr/local/bin/backup.sh\n"}' | python3 -c 'import sys,json; print(json.load(sys.stdin)["id"])')

# 3. run it now and wait for the result
RUN=$(curl -s -X POST -H "$AUTH" $API/cron/jobs/$ID/run | python3 -c 'import sys,json; print(json.load(sys.stdin)["run_id"])')
until [ "$(curl -s -H "$AUTH" $API/cron/runs/$RUN | python3 -c 'import sys,json; print(json.load(sys.stdin)["status"])')" != running ]; do sleep 2; done
curl -s -H "$AUTH" $API/cron/runs/$RUN

Uptime-style check with curl

Terminal
# exit code 0 only when the server reports "ok"
curl -sf -H "Authorization: Bearer $TOKEN" https://mon.example.com/rest/v1/status | grep -q '"status":"ok"' 

Security notes

  • HTTPS only. The installer refuses to enable the API over plain HTTP (unless the agent is local-only) and switches it off again if the certificate could not be issued.
  • Treat a token like a password. Keep it in a secret store or environment variable, never in a URL, a repository or a chat message.
  • Least privilege. One token per program; only the scopes it needs; an expiry; an address limit when the caller has a fixed IP.
  • Revoke at once when in doubt: sudo ./install.sh rest-token revoke ID. The next request is refused.
  • cron:write is remote command execution. The server still enforces its own limits: only allowed users, only HTTPS, scripts typed in a request can be forbidden, script files are re-checked before every run, and each change is written to the audit trail with the token id.
  • Nothing secret is logged. The request log stores the Authorization header only as [redacted, N chars], and keeps no response text for cron endpoints.
  • Wrong tokens are throttled and lock the address out; the server compares tokens in constant time.
  • The address limit and the lockout rely on the proxy. nginx/apache pass each caller's address to the agent together with a secret only they know, so a program on the same machine cannot fake an address. This protection is installed by install.sh from the version that added it; sudo ./install.sh status shows whether it is active (older installs: re-run the installer). With --webserver none there is no proxy, so callers connect directly.
  • The REST API cannot start or stop services, edit server configuration or create tokens. Monitoring is read-only; the only way to run something is a cron job.

Versioning

The path carries the version (/rest/v1). New fields may be added to responses without a version change, so ignore fields you do not know. A change that removes or renames something would appear under a new version path.

Every example response on this page was captured from the running API (demo data: a simulated server and a real cron scheduler) when this document was generated by dev/make_api_doc.py. Long lists are cut to two items (marked by the generator). Host name mon.example.com and the token are placeholders.