# Key Safeguards and Approvals

An AI agent can send quickly. These controls let you limit what one API key may
send and hold its messages until you approve them.

:::note Release status
Everything on this page is **available in this release candidate and not yet
deployed**. Until a deployment serves these routes, the dashboard shows "Not
available yet" and the API answers `404`. Do not rely on them in production before
the release notes say they are deployed.
:::

## Per-key controls

Each control belongs to one API key and is read and replaced through the same
resource. Paths work under both `/v1/account/api-keys` and `/v1/api-keys`.

| Request | Purpose |
|---|---|
| `GET /v1/account/api-keys/{keyId}/safeguards` | Read the current controls and this key's usage |
| `PUT /v1/account/api-keys/{keyId}/safeguards` | Replace all controls at once |
| `POST /v1/account/api-keys/{keyId}/stop` | Stop the key from sending, reversibly |
| `POST /v1/account/api-keys/{keyId}/resume` | Let a stopped key send again |

The response `data` object:

```json
{
  "key_id": "…",
  "state": "active",
  "allowlist": { "enforced": true, "emails": ["ops@example.com"], "domains": ["example.com"] },
  "budget": { "per_hour": 20, "per_day": 100, "used_hour": 3, "used_day": 40 },
  "approval": "required"
}
```

`state` is `active`, `stopped` or `revoked`. `PUT` takes `allowlist`, `budget`
(without the `used_*` fields) and `approval` (`off` or `required`), and nothing
else. It replaces the whole set, so send every field.

- **Recipient list.** With `enforced` true, the key can send only to the listed
  addresses and domains. An enforced empty list means the key cannot send to
  anyone. Up to 200 addresses and 200 domains.
- **Budget.** `per_hour` and `per_day` count recipients, not messages, in the
  current UTC hour and UTC day. `null` means this key adds no limit of its own;
  your plan limits and the new-account ceiling still apply. `0` is not accepted.
  When a key reaches its limit the send is refused with
  `api_key_hourly_limit_exhausted` or `api_key_daily_limit_exhausted`.
- **Stop.** A stopped key is refused with `send_authorization_revoked` before its
  next send. Messages already accepted are not recalled. Stopping is reversible;
  [revoke](./key-safeguards#what-else-limits-a-key) is permanent.
- **Revoked keys** answer `409 KEY_REVOKED` to changes. Browser sign-in sessions
  have no safeguards and answer `403 SESSION_MANAGEMENT_REQUIRED`. A credential
  cannot manage a key that holds permissions it lacks.

A recipient list that blocks a send returns `api_key_recipient_denied`.

## Message approval

When a key has `approval` set to `required`, a send from that key is not
transmitted. The inbox send route returns `202` with `approval_status` and
`delivery_status` both `awaiting_approval`. The message waits up to 24 hours.

| Request | Purpose |
|---|---|
| `GET /v1/approvals?status=pending` | Up to 100 messages waiting: `id`, `key_id`, `key_name`, `to`, `subject`, `created_at`, `expires_at` |
| `POST /v1/approvals/{id}/decision` | Body `{"decision":"approve"}` or `{"decision":"reject"}`. Returns `{"id","status"}` with `approved` or `rejected` |

- The key that wrote a message cannot approve it: `403 SEPARATE_APPROVER_REQUIRED`.
- A message already decided, or decided by a concurrent request first, answers
  `409 APPROVAL_ALREADY_DECIDED`. After 24 hours it answers `409 APPROVAL_EXPIRED`
  and is never sent.
- Approval runs the delivery checks again. If they now refuse, or the send or its
  scheduling cannot be confirmed, you get `403`, `502` or `503` with the message
  id. The decision is saved and **is not retried**. Check the message status
  before sending it again.
- Approval by replying to an email is not available.

The dashboard's Key safeguards page uses these same routes.

## What else limits a key

| Control | Where | Notes |
|---|---|---|
| Permissions `read` and `write` | Set when you create or edit a key | A key cannot grant a permission it does not have. |
| Expiry | `expires_at` on the key | An expired key stops working. |
| Revoke | Dashboard or `DELETE /v1/account/api-keys/{keyId}` | Permanent. Anything using the key stops immediately. |
| Rotate | Dashboard or the rotate endpoint | Creates the new key first, then revokes the old one. |
| Send authorization | Applies to every send | Verified ownership, verified domain, recipient approval or account trust, suppression and quotas. See [send authorization](../concepts/send-authorization). |
| Plan and account ceilings | Applies to the whole account | Monthly volume, daily limits and the new-account ceiling. See [rate limits](../rate-limits). |

Recipient approval in the send-authorization chain is a review of **who** may
receive mail from your account. Message approval on this page holds an individual
message.

## Owner notifications

The service records an event when a message starts waiting for approval and when a
key reaches its warning percentage of a budget. The notification worker has an
email template for both in this release candidate (both follow the `security`
preference). Nothing is deployed yet, so
do not assume any account has received these emails. See
[owner notifications](./owner-notifications).

## Recommended practice

- Give each agent its own key, so one can be stopped or revoked alone.
- Set a recipient list on keys that only mail known people.
- Prefer `read` keys for anything that only needs to look.
- Set an expiry on keys you hand to short-lived work.
