# Near-limit notices

Choose the channels that tell a person their weekly or monthly budget is nearly used, read limit_notice on your agent's orders, and know what texts cost.

When an order your agent makes takes a person's weekly or monthly budget to their near-limit percent, Provenance tells them once that window how much of the budget the agent has used, with buttons to adjust the limit or pause the agent. You choose the channels; the person chooses the percent.

**Before you begin:** your agent holds a [network grant](https://provenanceauth.com/docs/mandate/concepts/network-grants.md) with a weekly or monthly budget.

## When a notice goes

- After an authorized order, the first time spent and held reach the person's percent in that window: 80% unless they changed it to 50% or 90% or turned it off, for all agents or for yours.
- Once per window per grant.
- Never for a daily budget, a grant with no budget or a per-order cap.

Your agent's response says so too:

```json
{
  "object": "network_authorization",
  "result": "authorized",
  "limit_notice": { "percent_used": 82, "remaining": 36 }
}
```

`limit_notice` is present on every authorized order at or past the percent, so your agent can tell the person before it asks.

## Choose the channels

Push, text and email are all on by default. A notice goes on each channel you left on that the person has set up: the Provenance app (then web push), a verified phone and a verified email.

[`GET /v1/mandate/settings/limit_notices`](https://provenanceauth.com/docs/api/network.md#get-v1-mandate-settings-limit-notices) reads the setting. [`PUT /v1/mandate/settings/limit_notices`](https://provenanceauth.com/docs/api/network.md#put-v1-mandate-settings-limit-notices) changes it with an admin key or an owner or admin session; a field left out keeps its value.

```json
{ "channels": { "text": false } }
```

To set channels for one grant, send `limit_notice_channels` on its grant request.

## What it costs

Notices are free. Texts you leave on are billed to you at the text price, like any text Provenance sends for you. A Free account sends no texts, so its notices go by push and email.

## The webhook

Subscribe to `mandate.network_grant.limit_near` to hear when a notice went out:

- `percent_used` (number): How much of the budget was spent and held.
- `window` (string): The budget window (`week` or `month`), starting at `window_start`.
- `channels` (array): The channels the notice went on.
- `texts` (integer): Texts billed to you for it.

## Errors you might see

| Code | What to do |
| --- | --- |
| `insufficient_scope` | Change the channels with an admin key, or from the console as an owner or admin. |
| `parameter_invalid` | Send `channels` with only `push`, `text` and `email`, each true or false. |

## See also

- [When a grant changes](https://provenanceauth.com/docs/mandate/guides/when-a-person-changes-a-grant.md)
