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

# Notifications

> Get alerted when monitors fail

Notifications let you receive alerts when your monitors fail, recover, or meet specific conditions. Configure them directly in your monitor files using the `notify` DSL.

## Defining notifications

Add notifications when creating your monitor:

```typescript theme={null}
import { createMonitorBuilder, notify, Frequency, GET, Json } from "@griffin-app/griffin";

const monitor = createMonitorBuilder({
  name: "health-check",
  frequency: Frequency.every(1).minute(),
  notifications: [
    notify.onFailure().toSlack("#alerts"),
    notify.onRecovery().toEmail(["oncall@example.com"]),
  ],
})
  .request("check", { ... })
  .build();

export default monitor;
```

Notifications are deployed with your monitor when you run `griffin apply`.

## Trigger types

### On failure

Fires every time a run fails:

```typescript theme={null}
notify.onFailure().toSlack("#alerts")
```

### On recovery

Fires when a monitor succeeds after a failure:

```typescript theme={null}
notify.onRecovery().toSlack("#alerts")
```

### On consecutive failures

Fires after N consecutive failed runs:

```typescript theme={null}
notify.onConsecutiveFailures(3).toSlack("#alerts")
```

### On success rate below threshold

Fires when the success rate drops below a percentage over a time window:

```typescript theme={null}
notify.onSuccessRateBelow(95, 60).toEmail(["team@example.com"])
// 95% threshold over the last 60 minutes
```

### On latency above threshold

Fires when latency exceeds a threshold at a given percentile:

```typescript theme={null}
notify.onLatencyAbove({
  threshold_ms: 2000,
  percentile: "p95",
  window_minutes: 30,
}).toSlack("#performance")
```

## Delivery channels

### Slack

```typescript theme={null}
notify.onFailure().toSlack("#channel-name")
```

Requires a Slack integration. See [Integrations](/platform/integrations).

### Email

```typescript theme={null}
notify.onFailure().toEmail(["alice@example.com", "bob@example.com"])
```

Requires an email integration.

### Webhook

```typescript theme={null}
notify.onFailure().toWebhook("my-webhook-integration")
```

The argument is the name of a webhook integration.

## Cooldowns

Add a cooldown to prevent alert fatigue. The notification won't fire again within the cooldown period:

```typescript theme={null}
notify.onFailure()
  .withCooldown(15)  // 15 minutes
  .toSlack("#alerts")
```

## Viewing notification activity

```bash theme={null}
# List notification rules
griffin notifications list

# Filter by monitor
griffin notifications list --monitor health-check

# Send a test notification
griffin notifications test --integration slack --channel "#test"
```
