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

# API keys & spend controls

> Create keys with access levels, spend limits, reset windows, and expirations; rotate keys; track per-key usage; recharge your wallet automatically.

Every request authenticates with an API key, and every key spends one account's balance.
Manage keys at [dashboard > API keys](https://getanyapi.com/dashboard/keys), or call the
endpoints below with any key or session.

## Keys belong to an account

A key spends the account it was created in: your personal account, or a
[Team](https://getanyapi.com/docs/teams.md). Switching accounts in the dashboard doesn't move a key. To spend a Team's
balance, switch to the Team and create the key there.

Team keys belong to the Team, not to the person who made them. They keep working when that
person leaves the Team; rotate any key a departing member could see. On a Team, the key list
shows who created each key. On a Team, your [role](https://getanyapi.com/docs/teams.md#roles) decides whether you can see
and manage keys, and a Developer manages only **Run APIs** and **View account** keys.

## Create a key

`POST /v1/api-keys` mints a key. The secret is returned exactly once.

```bash theme={"dark"}
curl -s -X POST https://api.getanyapi.com/v1/api-keys \
  -H "X-API-Key: YOUR_ANYAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production",
    "limitUsd": 25,
    "limitInterval": "monthly",
    "expiresIn": "90d"
  }'
```

All fields except `name` are optional:

| Field | Meaning |
| - | - |
| `limitUsd` | Spend ceiling in USD. Omit (or `null`) for unlimited. |
| `limitInterval` | How often the limit resets: `daily`, `weekly`, or `monthly` (UTC calendar windows; weeks start Monday). Omit for a lifetime limit. Requires `limitUsd`. |
| `expiresIn` | `1h`, `1d`, `7d`, `30d`, `90d`, `180d`, `1y`, or `never` (default). Fixed at creation. |

A request that would take the key past its limit is rejected with **402** and the message
`this API key has reached its spend limit`, and nothing is charged. The wallet balance
applies independently.

## Access levels

Pick an access level when you create a key in the dashboard. It can't be changed later;
create a new key instead. Keys created before access levels existed have **Full access**.

| Level | The key can |
| - | - |
| **Full access** | Everything: run APIs, and see balance, usage, billing, and history. |
| **Run APIs** | Run APIs, get quotes, browse the API catalog, fetch results, and check a request by its id. It can't see balance, usage, transactions, or billing. |
| **View account** | See balance, billing settings, transactions and invoices, usage and usage reports, the request list and request activity, results, the catalog, and referral earnings. It can't run APIs or spend. |
| **View seller earnings** | See your seller earnings, payouts, payout account, and payout quote. Nothing else. |

Every level can send feedback and bug reports. A key that calls something outside its
access gets **403** with error code `forbidden`. The same limits apply through the
[MCP server](https://getanyapi.com/docs/mcp-server.md).

Give CI or an agent a **Run APIs** key, and a finance dashboard a **View account** key.

On a Team, keys can't have **View seller earnings** access, and no key reaches referral
earnings. Selling and referrals are [personal-only](https://getanyapi.com/docs/teams.md#personal-only-features).

## Rotate a key

If a secret may have leaked, rotate the key. Open the key's page in
[dashboard > API keys](https://getanyapi.com/dashboard/keys) and choose **Rotate key**
under **Danger zone**.

* The new secret is issued immediately and shown once.
* The old secret stops working on its next request. There is no grace period, so update
  anything that uses it right away.
* The name, spend limit, amount spent, usage history, and access level stay the same.

Deleting is different: it ends the key for good, and a replacement key starts with fresh
limits and empty history.

## Update, disable, delete

`POST /v1/api-keys/{id}` patches a key. Send only what you want to change:

```bash theme={"dark"}
# Lower the limit to $5/day
curl -s -X POST https://api.getanyapi.com/v1/api-keys/42 \
  -H "X-API-Key: YOUR_ANYAPI_KEY" -H "Content-Type: application/json" \
  -d '{ "limitUsd": 5, "limitInterval": "daily" }'

# Remove the limit
curl -s -X POST ... -d '{ "limitUsd": null }'

# Temporarily disable (reversible)
curl -s -X POST ... -d '{ "disabled": true }'
```

* The limit pair travels together: changing `limitInterval` requires `limitUsd` in the
  same request, and `"limitUsd": null` clears both.
* A **disabled** key fails every request with **401** (`this API key is disabled`) until
  you re-enable it with `{ "disabled": false }`.
* An **expired** key fails with **401** (`this API key has expired`). Expiry cannot be
  changed after creation; mint a new key instead.
* `DELETE /v1/api-keys/{id}` revokes a key permanently.

## When your balance runs out

When your balance can't pay for a request, it fails with **402** `insufficient_balance` and
nothing is charged. AnyAPI emails you when your balance runs low and again when it runs out.

If a key keeps calling 48 hours or more after your balance ran out, AnyAPI pauses that key.
A paused key fails with **402** `insufficient_balance` and the message
`this API key is paused because your balance ran out; it resumes when you add funds`, and
shows **Paused** in [dashboard > API keys](https://getanyapi.com/dashboard/keys). A
connected app (such as an MCP client you authorized) pauses the same way, with the message
`this connection is paused because your balance ran out; it resumes when you add funds`.
AnyAPI emails you when it pauses a key or app.

Only the key or app that kept calling is paused; your other keys and your account are
unaffected. Once you add funds and your balance can pay for requests again, the key or app
resumes on its own. You don't need to change anything.

## Per-key usage

`GET /v1/api-keys/{id}/usage?days=7|30|90` returns one key's spend: totals, a per-API
breakdown, a daily series, and calendar totals for today, this week, and this month, all
in USD.

```json theme={"dark"}
{
  "todayUsd": 0.42,
  "thisWeekUsd": 1.1,
  "thisMonthUsd": 3.21,
  "periodLabel": "Last 30 days",
  "totalRequests": 90,
  "totalCostUsd": 3.21,
  "byApi": [{ "api": "Tiktok Profile", "requests": 50, "costUsd": 2.0 }],
  "daily": [{ "label": "Jun 3", "requests": 4, "costUsd": 0.1 }]
}
```

The key list (`GET /v1/api-keys`) also carries each key's 30-day `usage30d`
(`{ requests, costUsd }`) plus its current-window `spentUsd` against `limitUsd`.

## Manual top-ups

Add between \$10 and \$10,000 from **Credits > Buy credits** in the dashboard. Every dollar
you pay adds one dollar to your wallet, with no top-up fee.

You pay on Stripe's hosted checkout page, where you can use a saved payment method or save a
new reusable one. Your wallet updates only after AnyAPI receives the verified payment event.
Some payment methods settle later; the dashboard shows a delayed state until the top-up
lands.

Successful full and partial refunds reduce the wallet by the refunded amount. A dispute reduces
the wallet when it opens, even when that makes the balance negative. Winning the dispute restores
the disputed amount; losing it does not apply another debit.

## Auto top-up

When your balance falls below a threshold, AnyAPI charges your saved card a fixed amount.

```bash theme={"dark"}
# Read the current settings
curl -s https://api.getanyapi.com/v1/billing/auto-topup \
  -H "X-API-Key: YOUR_ANYAPI_KEY"

# Enable: when the balance drops below $5, top up $20
curl -s -X POST https://api.getanyapi.com/v1/billing/auto-topup \
  -H "X-API-Key: YOUR_ANYAPI_KEY" -H "Content-Type: application/json" \
  -d '{ "enabled": true, "thresholdUsd": 5, "amountUsd": 20 }'
```

* Enabling requires a saved reusable payment method. Make a manual top-up first and select
  Stripe's save option (`hasPaymentMethod` on the GET tells you where you stand).
* Amounts are whole dollars; `amountUsd` respects the same minimum as a manual top-up.
* Auto top-ups appear in your [transactions](https://getanyapi.com/dashboard/billing)
  like any other top-up. Burst protection prevents duplicate charges, and repeated card
  failures pause the feature rather than retrying forever.
* Configure it in the dashboard under **Credits → Auto top-up**.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.