> ## Documentation Index
> Fetch the complete documentation index at: https://docs.happyuptime.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Config-as-code

Declare your monitors, status pages, and alerts in YAML. Apply with one command.

# Config-as-code

Drop `happyuptime.yml` in your repo, version-control it like Terraform / Pulumi, and use `happy config push` in CI to apply changes. Diffs against remote state — only updates what changed.

## Schema (high level)

```yaml
version: 1

monitors:
  - name: Web App
    url: https://app.acme.com
    type: http
    interval: 60
    regions: [us-east, us-west, eu-west]
    expected_status_codes: [200]
    alerts:
      - slack-ops
      - email-pagerduty

status_pages:
  - name: Acme Status
    slug: acme
    template: minimal
    components:
      - name: Web App
        monitor: Web App
      - name: API
        monitor: API

alert_channels:
  - id: slack-ops
    type: slack_app
    channel: alerts
    notify_oncall: true

oncall_schedules:
  - name: Engineering On-Call
    layers:
      - name: Primary
        rotation_type: weekly
        handoff_day: 1   # Monday
        handoff_hour: 9
        timezone: America/New_York
        members: [alice@acme.com, bob@acme.com, carol@acme.com]
```

## Workflow

**Scaffold from current state**

```bash
    happy config init > happyuptime.yml
    ```

    Captures everything currently in your account. Edit from there.

  **Validate before pushing**

```bash
    happy config validate happyuptime.yml
    ```

  **Preview the diff**

```bash
    happy config push happyuptime.yml --dry-run
    ```

    Color-coded diff. Make sure deletes are intentional.

  **Apply**

```bash
    happy config push happyuptime.yml
    ```

## Env vars

```yaml
monitors:
  - name: ${SERVICE_NAME} API
    url: ${SERVICE_URL}/health
```

Env vars resolve from the shell. CI tip: store URLs and slugs in env vars so the same YAML file works in staging and prod.

## In CI/CD

See [the CI/CD guide](/cli/ci-cd) for full GitHub Actions / GitLab CI examples.

```yaml
# .github/workflows/uptime.yml (excerpt)
- name: Apply uptime config
  env:
    HAPPYUPTIME_API_KEY: ${{ secrets.HAPPYUPTIME_API_KEY }}
  run: |
    npx happyuptime-cli config validate happyuptime.yml
    npx happyuptime-cli config push happyuptime.yml
```