This creates one HTTP check through the REST API, tests it from several countries, and reads its results. You need curl, jq and an account.
1. A token
Section titled “1. A token”In the dashboard, open Settings → API tokens → Create token. Give it the scopes checks:read, checks:write, nodes:read and incidents:read, and keep the value in the environment:
export MONITORLY_TOKEN=mly_…export API=https://app.monitorly.cloud/api/v1The value is shown once. Never put it in a file you commit (Authentication).
2. Workspace, project and nodes
Section titled “2. Workspace, project and nodes”curl -fsS "$API/workspaces" -H "Authorization: Bearer $MONITORLY_TOKEN" | jq '.[] | {id, name}'WORKSPACE=$(curl -fsS "$API/workspaces" -H "Authorization: Bearer $MONITORLY_TOKEN" | jq -r '.[0].id')curl -fsS "$API/workspaces/$WORKSPACE/projects" -H "Authorization: Bearer $MONITORLY_TOKEN" | jq '.[] | {id, name}'PROJECT=$(curl -fsS "$API/workspaces/$WORKSPACE/projects" -H "Authorization: Bearer $MONITORLY_TOKEN" | jq -r '.[0].id')A check runs on the nodes you choose. List them with their location and health, and pick two or more in different countries, so that one failing location cannot open an incident on its own (How DOWN is decided):
curl -fsS "$API/workspaces/$WORKSPACE/nodes" -H "Authorization: Bearer $MONITORLY_TOKEN" \ | jq '.[] | {id, name, countryCode, health: .health.status}'NODES=$(curl -fsS "$API/workspaces/$WORKSPACE/nodes" -H "Authorization: Bearer $MONITORLY_TOKEN" \ | jq -c '[.[] | select(.health.status == "online") | .id][:3]')3. Test before saving
Section titled “3. Test before saving”A test runs the check once on each of its nodes and saves nothing:
cat > check.json <<EOF{ "name": "payments-health", "intervalSecs": 300, "nodes": $NODES, "kind": { "type": "http", "method": "GET", "url": "https://api.acme.io/healthz", "maxRedirects": 0, "assertions": [{ "target": "status", "op": "eq", "value": 200 }] }}EOFFive minutes is an interval every plan allows; the shortest is on Plans and limits.
TEST=$(jq '{check: .}' check.json | curl -fsS "$API/projects/$PROJECT/check-tests" \ -H "Authorization: Bearer $MONITORLY_TOKEN" -H "Content-Type: application/json" --data @- | jq -r '.id')sleep 15curl -fsS "$API/check-tests/$TEST" -H "Authorization: Bearer $MONITORLY_TOKEN" \ | jq '{done, results: [.results[] | {nodeId, status, outcome, statusCode, ms: .timings.totalMs}]}'done turns true when every node has answered or its deadline passed: the check’s timeout plus 5 seconds.
4. Create the check
Section titled “4. Create the check”CHECK=$(curl -fsS "$API/projects/$PROJECT/checks" \ -H "Authorization: Bearer $MONITORLY_TOKEN" -H "Content-Type: application/json" \ -H "Idempotency-Key: payments-health-1" --data @check.json | jq -r '.check.id')A retry with the same Idempotency-Key returns the first answer and creates nothing again (Idempotency).
5. Read its results
Section titled “5. Read its results”curl -fsS "$API/checks/$CHECK" -H "Authorization: Bearer $MONITORLY_TOKEN" \ | jq '{status, uptime30dPercent, stations: [.stations[] | {nodeName, outcome, totalMs}]}'curl -fsS "$API/checks/$CHECK/runs?limit=10" -H "Authorization: Bearer $MONITORLY_TOKEN" \ | jq '.items[] | {slotAt, nodeId, outcome, statusCode, totalMs}'curl -fsS "$API/projects/$PROJECT/incidents?state=open" -H "Authorization: Bearer $MONITORLY_TOKEN" \ | jq '.items[] | {checkName, openedAt, ackedAt}'status is absent until the check is first evaluated, then PENDING until its first decision. Alerts go to the project’s alert channels: add one with Add an alert channel or in the dashboard (Alert channels).
When something fails
Section titled “When something fails”Errors are application/problem+json. Branch on type, not on the text:
{ "type": "token.scope_missing", "title": "Forbidden", "status": 403, "detail": "this token needs the scope checks:write", "errors": [] }Field errors point at the field in errors[].pointer, for example /kind/url. Every code is on Errors, and every operation with its parameters, scopes and examples is in the REST reference.