# Authentication and API keys

> Authenticate Klupt API calls with an X-Api-Key header. Keys are 256-bit random secrets shown once, stored only as a keyed hash, with revoke, rotate, IP allowlists and per-key limits.

Send your key in the `X-Api-Key` header on every request. Live keys start with `kd_live_`; sandbox keys start with `kd_test_`.

```bash
curl "https://api.klupt.io/v1/account" -H "X-Api-Key: kd_live_YOUR_KEY"
```

## How keys are protected

- Each key carries more than 256 bits of randomness.
- We store only a keyed hash (HMAC-SHA256 with a server-side secret). The full key is shown **once**, when you create it. The dashboard shows only the first characters.
- **Rotate** issues a new key with the same name and settings. The old one stops at once, or after a grace period of up to 7 days so you can deploy the new one.
- **Revoke** stops a key within seconds.
- **IP allowlist:** limit a key to your servers' addresses or CIDR ranges (IPv4 or IPv6). Calls from anywhere else answer `403 ip_not_allowed`.
- **Per-key limits:** give a key a lower requests-per-second limit or a monthly credit cap, for example for a staging server.
- Keep keys on your server. Never ship them in a browser, a mobile app or a public repository.

## Account access

The docs, OpenAPI spec and pricing are public. Using the API needs a business account, which moves through these levels:

| Level | How you get there | What you can do |
|---|---|---|
| Email confirmed, in review | You signed up; an automatic check needs a person to look | Unlimited sandbox (`kd_test_`) keys |
| Limited | Automatic checks passed (business email, website, no blocklist hit) | Sandbox, 1 live key, 3 requests a second, the $20 and $50 packs, 25 live test calls |
| Approved | A person reviewed your account (usually within one business day) | Up to 10 live keys, 10 requests a second, every pack, monthly plans, add-ons, plus 50 live test calls |

Accounts that break the [acceptable use policy](/docs/acceptable-use) are suspended: every key answers `403 account_suspended` at once.

**Live test calls** are spent only after your paid credits, at 1 request a second and up to 5 pages of any list. When they run out you get `402 insufficient_credits` with a link to buy a pack.

## Dashboard sign-in

The dashboard uses one-time sign-in links sent by email (valid 15 minutes, single use). You can turn on **two-factor authentication** (any authenticator app) under **Security**; you then get recovery codes to store safely.

## Account endpoint

`GET /v1/account` is free and returns your plan, credit balance, rate limits and this key's monthly spend. Use it as a health check for your integration.

```json
{
  "data": {
    "plan": "payg",
    "credits": { "total": 26950.5, "plan_allowance": 0, "prepaid": 26950.5 },
    "limits": { "requests_per_second": 10, "concurrent_requests": 5 },
    "key": { "prefix": "kd_live_Ab12Cd", "name": "production", "mode": "live", "monthly_credit_limit": null, "credits_used_this_month": 49.5 }
  },
  "meta": { "request_id": "req_…", "credits_charged": 0 }
}
```
