# Security Settings

> Find risky API keys, clean up unused ones, and restrict API keys to a list of trusted IP addresses.


# Security settings

The Key safety section of dashboard Settings ([anyrouter.dev/dashboard/settings#key-safety](https://anyrouter.dev/dashboard/settings#key-safety)) has three tabs: **Overview**, **Key safety** and **IP allowlist**.

## Overview

Four cards count active keys needing attention: **No spend limit**, **Never expires**, **Never used or idle** (never used, or unused 90+ days) and **Safe to remove** (idle 90+ days, under $1 lifetime spend). Click one to open **Key safety** filtered to it. Owners and admins can **Copy CSV** of every active key with its owner.

## Key safety

Lists active `sk-ar-v1` keys; turn on **Management keys** to include management keys. Filter by name (owners and admins also by owner), Risk, Inactivity (30, 60, 90, 180+ days, never used) or Safe to remove.

The **Risk** column flags no spend limit, a limit of $1,000 or more, no expiry, or an expiry over 365 days away. Several flags show red.

| Status | Meaning |
|---|---|
| **Safe to remove** | Idle 90+ days and spent under $1. |
| **Review** | Idle 90+ days but carried real traffic. Check first. |
| **In use** | Used in the last 90 days, or created recently. |

Owners and admins can act on each key:

- **Set limit**: add or change the spend limit.
- **Disable**: stops the key within about a minute. Re-enable it from **API keys**.
- **Archive**: permanent. Type `archive` to confirm.

To retire a key that never expires, rotate it: create a new key with an expiry and spend limit, move your apps to it, disable the old key, then archive it once nothing breaks.

## IP allowlist

Limits which IPs can use your workspace's keys. Available on **Pro and above**, though you can remove entries on any plan.

- Add IPv4 (`203.0.113.7`), IPv6 (`2001:db8::1`) or CIDR ranges (`203.0.113.0/24`, `2001:db8::/32`), each with an optional label. **An empty list allows every IP.**
- With at least one entry, every request using an `sk-ar-v1` key in the workspace must come from a listed IP.
- Changes apply to all workspace keys within about a minute. The dashboard is not affected.
- Owners and admins edit; members can view. **Add my IP** adds your current address. List every server, CI runner and office network first.

A blocked request returns `403`:

```json
{
  "error": {
    "message": "Requests from IP 198.51.100.4 are not allowed for this workspace. Add it to the IP allowlist in Security settings.",
    "type": "permission_error",
    "code": "ip_not_allowed"
  }
}
```

### Manage with the API

Use a [management key](/api-reference/management-keys) with the `read:security` or `write:security` scope:

```bash
curl https://anyrouter.dev/api/v1/security/ip-allowlist \
  -H "Authorization: Bearer $ANYROUTER_MANAGEMENT_KEY"

curl -X POST https://anyrouter.dev/api/v1/security/ip-allowlist \
  -H "Authorization: Bearer $ANYROUTER_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cidr": "203.0.113.0/24", "label": "Office"}'

curl -X DELETE https://anyrouter.dev/api/v1/security/ip-allowlist/<id> \
  -H "Authorization: Bearer $ANYROUTER_MANAGEMENT_KEY"
```

`GET /api/v1/security/keys` returns the active keys shown on Key safety.


## Related

- [Managing API Keys](/docs/features/api-keys.md)
- [Errors](/docs/guides/errors.md)
