API
Probeward's REST API is the one the UI uses. It lives under /api/v1, takes and returns JSON, and is described by an OpenAPI 3.1 document at /api/v1/openapi.json (a browsable reference is at /api/docs). This page is about calling it from scripts: how to authenticate, and the calls most scripts need.
In the examples $PW is the base URL (for example https://monitor.example.org) and $TOKEN an API token.
Authentication
There are two ways in, and they never mix on one request.
| Browser session | API token | |
|---|---|---|
| Sent as | the probeward_session cookie, set by login | Authorization: Bearer pwt_... |
CSRF header on POST, PUT, PATCH, DELETE | required (X-Probeward-CSRF, any non-empty value) | not needed |
| Sets a cookie | yes | never |
| Role | the user's | the token's, at most its owner's current role |
| For | people at the UI | scripts and tools |
When a request carries a bearer token the cookie is ignored. A token request that fails answers 401 with the code invalid_token; ten failures from one address make that address wait (HTTP 429 with Retry-After, doubling up to 15 minutes), separately from the login throttle.
API tokens
Every user can create tokens for themselves under Account, API tokens in the UI, or with the API (from a browser session, since a token cannot create tokens):
curl -fsS -X POST "$PW/api/v1/tokens" -b cookies.txt -H 'X-Probeward-CSRF: 1' \
-H 'Content-Type: application/json' \
-d '{"name": "nightly backup check", "role": "operator", "expires_at": "2027-12-31T23:59:59Z"}'The answer has the token in secret. It is shown once. Probeward stores only its SHA-256, so it cannot show it again; lose it and you revoke the token and make another.
- Name: 1 to 80 characters. It appears in lists and in the audit log.
- Role:
viewer,operatororadmin, never higher than your own. If the owner is later demoted, the token is limited to the new role at once. - Expiry (optional): a time in the future, at most 10 years ahead. An expired token answers 401 with "this API token has expired". Without an expiry a token lasts until revoked.
- Limits: 50 active tokens per user.
- Last used: the time and address of the last request are recorded (at most once a minute) and shown in the list.
Administrators list everyone's tokens (GET /api/v1/tokens?all=true) and revoke any of them (DELETE /api/v1/tokens/{id}); other users see and revoke only their own. A revoked token stops working at once. Disabling a user stops their tokens at once, and enabling the user brings them back; deleting a user removes them.
What a token cannot do, whatever its role (answer 403 token_not_allowed): create or revoke tokens, change a password or a two-factor setting, end sessions, reset another user's password or two-factor login, or open the live event stream. These need a person at a browser.
What is audited. Creating, revoking and expiring a token each write an audit record. Every change a token makes is audited like any other, and the record names the owner and the token, for example olga via API token "nightly backup check" (0194…). The token itself appears in no log, audit record, event, export or error message: the request log never contains a header, and the push path is masked.
Choosing the hash
A token is 256 random bits. A password hash is slow and salted because people choose passwords from a small space that can be searched offline; there is nothing to search in a random 256-bit value, so a slow hash would only cost time on every request. SHA-256 keeps a copy of the table from being usable as credentials. A keyed hash would add protection only if the table leaked without the server's configuration, at the price of one more secret to back up. The lookup is by hash and the stored hash is compared in constant time.
Common tasks
Each example sends the token in a header. Roles needed are in brackets. Ids are UUIDs from GET /api/v1/tree.
List sensors and their state [viewer]
curl -fsS -H "Authorization: Bearer $TOKEN" "$PW/api/v1/tree" \
| jq -r '.sensors[] | [.id, .name, (.status.health // "none"), (.status.freshness // "none")] | @tsv'One sensor, with its channels, limits and last values:
curl -fsS -H "Authorization: Bearer $TOKEN" "$PW/api/v1/sensors/$SENSOR"Pause and resume [operator]
Pausing takes the node's current version (so two people cannot overwrite each other) and an optional duration or end time and reason. Nodes are probe, group, device or sensor.
VERSION=$(curl -fsS -H "Authorization: Bearer $TOKEN" "$PW/api/v1/sensors/$SENSOR" | jq .sensor.version)
curl -fsS -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d "{\"version\": $VERSION, \"duration_minutes\": 60, \"reason\": \"firmware upgrade\"}" \
"$PW/api/v1/nodes/sensor/$SENSOR/pause"Resume the same way with POST /api/v1/nodes/sensor/$SENSOR/resume and the current version.
Acknowledge [operator]
curl -fsS -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"note": "looking into it"}' "$PW/api/v1/sensors/$SENSOR/acknowledge"An incident can be acknowledged by id with POST /api/v1/incidents/{id}/acknowledge; open incidents are in GET /api/v1/incidents.
Scan now [operator]
curl -fsS -X POST -H "Authorization: Bearer $TOKEN" "$PW/api/v1/sensors/$SENSOR/scan-now"The answer is {"accepted": true} once the engine has taken the request. A sensor that is paused answers 409. A push sensor is never polled and answers 409 not_pollable.
History and availability [viewer]
# Seven days, 300 points per channel: min, avg and max of each bucket, and which level served it.
curl -fsS -H "Authorization: Bearer $TOKEN" \
"$PW/api/v1/sensors/$SENSOR/series?from=2026-11-21T00:00:00Z&to=2026-11-28T00:00:00Z&max_points=300"
# Availability over 30 days.
curl -fsS -H "Authorization: Bearer $TOKEN" \
"$PW/api/v1/sensors/$SENSOR/availability?from=2026-10-29T00:00:00Z&to=2026-11-28T00:00:00Z"The series response has level (raw, 5m or 1h), bucket_secs, the channels with min, avg, max and count per bucket, failures (the failed polls that raw scans still show) and outcome_buckets (poll counts by health per bucket, for rolled-up levels). level= forces a level. The availability response has poll counts by health and availability_percent, the share of polls that found the sensor up or warning. See storage for how the level is chosen and what the percentage means.
Settings and retention [admin]
curl -fsS -X PATCH -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"raw_retention_days": 30, "rollup_5m_retention_days": 90, "rollup_1h_retention_days": 730}' \
"$PW/api/v1/settings"Configuration as files
An administrator can export the tree as files and import files back, as a plan first and then an apply that must name the plan it was shown. See export and import for the format and the rules.
# Export the whole tree as a tar archive of one YAML file per site, group and device.
curl -fsS -H "Authorization: Bearer $TOKEN" \
"$PW/api/v1/config/export?scope=tree&layout=directory&format=tar" -o config.tar
# Plan an import (nothing changes), then apply the plan whose id came back.
curl -fsS -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"files": {"probeward.yaml": "..."}}' "$PW/api/v1/config/import/plan"
curl -fsS -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"files": {"probeward.yaml": "..."}, "plan_id": "3f2a..."}' "$PW/api/v1/config/import/apply"Sensors from a MIB file [operator]
Read a MIB file, list its scalars and tables, and have the sensors for the ones you pick drafted, then create them with the ordinary sensor route. The two MIB routes store nothing. See importing a MIB.
# The scalars and tables in the file (jq builds the JSON so the file's text is escaped).
jq -n --rawfile t EXAMPLE-MIB.mib '{files: [{name: "EXAMPLE-MIB.mib", text: $t}]}' |
curl -fsS -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
--data-binary @- "$PW/api/v1/devices/$DEVICE/mib/inspect"
# Drafts for a scalar and one row of a table, found by name; each draft goes to POST /api/v1/sensors as it is.
jq -n --rawfile t EXAMPLE-MIB.mib '{files: [{text: $t}], selections: [
{type: "scalar", name: "exTemperature"},
{type: "table", table: "exProbeTable", columns: ["exProbeValue"], row: {by: "name", name: "intake"}}]}' |
curl -fsS -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
--data-binary @- "$PW/api/v1/devices/$DEVICE/mib/drafts"Messages a receiver sensor matched [viewer]
# The newest 50 traps or syslog messages a sensor matched; add n=200 and before=<id of the last one> for more.
curl -fsS -H "Authorization: Bearer $TOKEN" "$PW/api/v1/sensors/$SENSOR/events?n=50"Each event has an id (to page with), at (when the probe received it), level (for syslog, from the severity), summary and detail (the parsed message). For a netflow or sflow sensor an event is a summary of who talked in the intervals since the last poll, and detail holds the totals and the top sources, destinations, conversations and services (see the NetFlow sensor). A sensor of another kind answers with an empty list. See receivers.
Pushing values in
A push sensor takes reports from jobs and scripts at its own URL, POST /api/v1/push/{token} (or GET with query parameters). That endpoint takes no session and no API token; its secret is the last path segment.
Errors
Every error has the body {"error": {"code": "...", "message": "...", "fields": [...]}}. Codes you will meet in scripts: unauthenticated (401), invalid_token (401), forbidden (403), token_not_allowed (403), csrf_header_missing (403, cookie sessions only), not_found (404), validation_failed (400, with fields), version_conflict (409, with current_version), too_many_attempts (429, with retry_after_secs) and runtime_unavailable (503).