---
title: "Monitoring as code — the Uptrack CLI — Uptrack"
description: "Define monitors in a version-controlled YAML file and sync them from CI with the uptrack CLI. Install, authenticate and apply."
url: https://uptrack.app/guides/monitoring-as-code
---
Guide
# Monitoring as code
Click-ops is fine until you have thirty monitors and no record of who changed what. The `uptrack` CLI lets you keep your monitors in a YAML file in your repo, review changes in a pull request, and sync them from CI on merge — the same monitors, now under version control.
## Step 1 — Install the CLI
It’s a single static binary (no runtime to install). On macOS or Linux:
```
curl -fsSL https://raw.githubusercontent.com/Uptrack-App/uptrack-cli/main/install.sh | sh
```
Or download a binary for your platform from the [latest release](https://github.com/Uptrack-App/uptrack-cli/releases/latest) and put it on your `PATH`.
## Step 2 — Authenticate
Create an API key under **Settings → API keys** and put it in your environment:
```
export UPTRACK_API_KEY=utk_…
```
Now `uptrack list` shows your monitors with their status and 30-day uptime; `uptrack status` prints an up/down summary.
## Step 3 — Define monitors in YAML
Already have monitors? `uptrack export -o uptrack.yaml` dumps them to a file to commit. Starting fresh, the format is small:
```
monitors:
- name: Homepage
url: https://example.com
type: http
interval: 60
- name: Login keyword
url: https://example.com/login
type: keyword
keyword: "Sign in"
```
Monitors are matched by name. `type` defaults to `http`; `interval` (seconds) and `keyword` are optional.
## Step 4 — Apply from your shell or CI
`apply` creates anything new, updates what changed, and leaves the rest alone. Preview first with `--dry-run`; add `--prune --yes` to also delete monitors not in the file.
```
uptrack apply -f uptrack.yaml --dry-run # preview
uptrack apply -f uptrack.yaml # sync
```
In GitHub Actions, sync on merge:
```
- run: curl -fsSL https://raw.githubusercontent.com/Uptrack-App/uptrack-cli/main/install.sh | sh
- run: uptrack apply -f uptrack.yaml
env:
UPTRACK_API_KEY: ${{ secrets.UPTRACK_API_KEY }}
```
## Put your monitors in Git
Pro includes 50 monitors at 30-second checks. Create a key, export, commit, and apply from CI.
[Get started ](https://uptrack.app/signup)·[CLI on GitHub](https://github.com/Uptrack-App/uptrack-cli)