# Money guards

> The spend cap on API-started calls, the day limits on one key, the numbers we won't dial, and the limit on calling one lead.

A key that can add leads can start real phone calls, and calls cost money. A runaway loop in a CRM, or a leaked key, could get expensive. These guards are there so it can't.

## The spend cap

Your organization has a daily and a monthly budget for calls started through the API. By default it's **$300 a day** and **$3,000 a month**. The spend is the calls' billable minutes at your rate, the same numbers as your bill. Days and months follow your organization's time zone.

Only API-started calls count. Leads you load into a campaign in the app keep dialing as usual.

When a cap is reached:

- New API leads aren't refused. They're kept and **held**: `"status": "held"`, `"held_reason": "spend_cap_reached"`. The same goes for `POST /calls`.
- API leads already waiting aren't dialed until the cap lifts.
- Your organization's admins get one email about it (once per cap, per day or month).

The cap lifts by itself at midnight (or on the 1st, for the monthly cap), or as soon as the cap is raised. Held leads are then called in their usual order.

Org admins can lower the caps in CallView. To go above the defaults, ask CallView support.

## Limits for one key

The spend cap covers your whole organization. A CRM stuck in a loop could still use all of it on its own, so each key can have day limits of its own as well. Both are optional, and you set them on the key in **Settings > API**:

| Limit | What it counts | Allowed values |
| --- | --- | --- |
| Calls per day | Calls started for the leads this key added, re-sent or called with `POST /calls` | 1 to 100,000 |
| Daily spend cap | What those calls cost: billable minutes at your rate, the same rule as the organization's cap | $1 to $1,000,000, in cents |

Leave one empty and the key has no limit of that kind. The organization's spend cap still applies either way. The day is your organization's day, in its time zone. A test key's pretend calls cost nothing and never count.

When a key reaches either limit:

- New leads from that key, and `POST /calls`, aren't refused. They're kept and **held**: `"status": "held"`, `"held_reason": "key_limit_reached"`.
- A lead of that key's that comes up to be dialed isn't called. It waits until midnight in your organization's time zone, and the campaign moves on to its other leads, so other keys' leads and the campaign's own keep dialing.
- At midnight the key starts a new day and its waiting leads are called in their usual order.

If both the organization's cap and the key's limit are reached, the answer is `spend_cap_reached`: the organization's cap is checked first.

Two things to know when you size a limit:

- **It can go over by up to a minute's worth of calls.** We count each key's calls and spend once a minute, not on every call, so calls that start in that minute can take a key a little past its limit. The organization's cap works the same way.
- **Raising a limit doesn't bring back leads already waiting for midnight.** New leads are dialed under the new limit within a minute. To call a waiting lead today, send it again with `POST /calls`.

## Numbers we won't dial

Premium-rate numbers (900, 976 and the like) and international numbers, including `+1` numbers in the Caribbean, are refused for API leads:

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "number_not_allowed",
    "message": "phone: premium-rate numbers (such as 900 and 976) are not dialed for this organization. Ask CallView support to allow them.",
    "param": "phone",
    "request_id": "req_6f1c2a9b0d3e4f5a6b7c8d9e0f1a2b3c",
    "reason": "premium"
  }
}
```

`reason` is `premium` or `international`. If you really need to call one of these, ask CallView support to allow it for your organization.

## Calling one lead again

`POST /calls` calls an existing lead right away. Each lead can be called this way at most 3 times in 24 hours. The 4th gets `429 call_limit_reached`, with `Retry-After` saying when you can again.

## Knowing which key started a call

Every call says what started it, in `started_by`: `{ "type": "api", "api_key_id": "ck_live_..." }` for a call your key started, `dialer` for the campaign's own dialing, or `person` for a call someone placed by hand. The calls with your key's ID are the ones its day limits count. Settings > API shows each key's calls and cost for today and the last 30 days, next to any limit it has.
