Developers

CLI

Every command, flag, and environment variable in the UptimeWarden CLI.

The UptimeWarden CLI is the uw binary in the @uptimewarden/cli package. It is on npm; the source is at github.com/UptimeWarden/cli. The current command surface is intentionally narrow: auth, heartbeat, and apply. Future releases will add pull, destroy, init, and a TypeScript config loader.

Global flags

FlagPurpose
-v, --versionPrint the CLI version and exit
-h, --helpPrint help for any command and exit

Both work fully offline, no network access required.

Environment variables

VariablePurpose
UW_API_TOKENAPI token (overrides ~/.uw/config.json)
UW_API_URLAPI base URL (default https://app.uptimewarden.online)
UW_WORKSPACEWorkspace label kept in the config file
UW_CONFIG_DIRConfig directory (default ~/.uw)

uw auth

uw auth login --token <token> [--base-url <url>] [--workspace <name>]
uw auth status
uw auth logout

Persists the API token to ~/.uw/config.json with 0600 permissions. uw auth status reports whether you are signed in without ever printing the token.

uw heartbeat <token>

uw heartbeat <heartbeat-token> [--state success|failure] [--message "..."] [--base-url <url>]

Sends POST /api/heartbeat/:token/ping. The endpoint is anonymous, the heartbeat token itself is the credential, so this command does not require uw auth login first. It is designed for cron jobs, scheduled deploys, and batch pipelines.

--state failure reports that the job ran and failed: the monitor goes down at the next evaluation (within 30 seconds) instead of waiting for the interval and grace period, and --message becomes the incident's error message (500 characters at most). The next successful ping brings it back up. Scripts without the CLI can do the same with POST /api/heartbeat/<token>/fail.

The token is the monitor's heartbeatToken, returned when you create a heartbeat monitor and by GET /api/v1/monitors/<publicId>.

uw apply -f <file>

uw apply -f monitors.uw.json [--yes] [--allow-delete] [--diff-only] [--base-url <url>]

Reads a Monitoring-as-Code config file, fetches the live state of monitors managed by the CLI, computes a Create / Update / Delete diff.

Without --yes the command is always dry-run, it prints the plan and exits. Add --yes to actually apply changes.

Flags:

FlagPurpose
--yesApply changes. Without this flag the run is always dry-run.
--allow-deleteEnable deletion of monitors no longer in the config. Without this flag deletes are shown in the plan but never applied.
--diff-onlyExit 2 when drift is detected (useful for PR gates). Exit 0 when no drift. It does not decide whether changes are applied; that happens only with --yes.

Exit codes:

CodeMeaning
0No changes / apply succeeded
1File not found, parse error, network error, or auth missing
2Drift detected (only with --diff-only)

Fields: a monitor in the config file takes externalId (required, the stable handle), name, type, url, interval, timeout, region and isActive. The API accepts every other monitor setting as well (thresholds, alert routing, verification regions; see API endpoints); the CLI config file cannot carry them.

Drift detection compares: name, type, url, interval, timeout, region, isActive. Fields omitted from the config are not considered.

Example:

# Show plan
uw apply -f monitors.uw.json

# Apply creates + updates (no deletes)
uw apply -f monitors.uw.json --yes

# Apply everything including deletes
uw apply -f monitors.uw.json --yes --allow-delete

# PR gate: fail if config is out of sync
uw apply -f monitors.uw.json --diff-only

Where files live

  • ~/.uw/config.json. API token, base URL, and workspace label
  • monitors.uw.json, your Monitoring-as-Code source of truth

Nothing else is persisted. The CLI does not maintain a state file, drift is computed live against the API on every run.

Bu sayfayı Türkçe okuyun