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

# Recipe: Pause when cost spikes

> Get a heads-up before the cap fires — and a hard stop when it does.

The daily spend cap is a safety net, not a normal operating mode — by the time it fires, your agent is already paused. This recipe wires the 80% warning so you hear about it first, plus the hard stop notification so you know exactly when the cap engaged.

## What you'll build

Two channels, two thresholds:

1. **Slack** subscribed to `on_cost_threshold` — fires at 80% of the daily cap.
2. **Email** subscribed to `on_pause` — fires when the cap actually engages.

## Steps

<Steps>
  <Step title="Set the threshold in rules">
    ```json theme={null}
    {
      "notifications": {
        "on_cost_threshold_pct": 80,
        "on_pause": true
      }
    }
    ```

    Drop to 50% if you want earlier warnings during initial tuning.
  </Step>

  <Step title="Add the Slack channel">
    **Channels → Add → Slack.** Paste webhook URL. Subscribe to `on_cost_threshold` only.
  </Step>

  <Step title="Add the email channel">
    **Channels → Add → Email.** Target your ops alias. Subscribe to `on_pause`.
  </Step>

  <Step title="Test both">
    `POST /api/v1/agents/{id}/channels/{cid}/test` on each — a synthetic event of every subscribed kind lands in the destination.
  </Step>
</Steps>

## What you'll see

At 80%:

> *:warning: Agent `Booking.com hygiene` has used 80% of its daily spend cap ($4.00 / $5.00).*

At 100%:

> *Subject: Agent paused — daily spend cap reached*
> *Body: `Booking.com hygiene` reached its daily spend cap of \$5.00 and was auto-paused at 14:23 UTC. It will auto-resume at 00:00 in your workspace timezone. No action required unless you want to raise the cap.*

## Bumping the cap

If you're consistently hitting cap, raise it in **Settings → Cost & limits** (or `PATCH /api/v1/agents/{id}`):

```bash theme={null}
curl -X PATCH https://api.mapping.travel/api/v1/agents/{id} \
  -H 'Authorization: Bearer mt_...' \
  -d '{ "dailySpendCapCents": 1500 }'
```

## Related

* [Agents overview](/agents/overview) — broader context.
* [Cost and limits](/agents/cost-and-limits) — full semantics.
* [Notifications](/agents/notifications) — channel setup details.
