# Authentication

Every `/v2/*` request needs a credential. For developers that credential is
an **API key**.

## Creating a key

Create a key from [Account → API](https://cardog.app/login?next=/account/api); the [Quickstart](https://cardog.app/docs/quickstart) walks through it.

## Sending the key

Two headers are accepted, and they are equivalent:

```bash
# x-api-key header
curl "https://api.cardog.app/v2/vin/2T3R1RFV7MW180266" \
  -H "x-api-key: $CARDOG_API_KEY" \
  -H "Cardog-Version: 2026-10-26"

# Authorization bearer
curl "https://api.cardog.app/v2/vin/2T3R1RFV7MW180266" \
  -H "Authorization: Bearer $CARDOG_API_KEY" \
  -H "Cardog-Version: 2026-10-26"
```

## Plans

Monthly request allowances per plan, rendered from the platform's own plan
definitions. See [/pricing](https://cardog.app/pricing) for current prices.

| Plan | Credits / month |
| --- | --- |
| Free | 50 |
| Starter | 1,000 |
| Pro | 5,000 |
| Business | 25,000 |
| Enterprise | 100,000 |

A VIN decode is 2 credits; a recall check by VIN is 5. See [Credits](https://cardog.app/docs/credits).

Metered responses carry `X-Credits-*` headers, and `GET /v2/pricing` returns
the machine-readable rate card without auth.

## When auth fails

Failures use the standard [error envelope](https://cardog.app/docs/errors):

- `401 unauthorized`: no valid key, session, or internal credential
- `403 forbidden`: the credential lacks the scope for this route group
- `402 insufficient_credits`: free-tier hard stop (paid tiers bill overage instead)
- `429 rate_limited`: per-minute rate limit exceeded

## Key hygiene

- Never commit keys to version control. Use environment variables.
- Use separate keys for development and production.
- Rotate keys periodically and revoke unused keys in the dashboard.
- Monitor usage under [Account → API](https://cardog.app/login?next=/account/api).

---

Previous: [Quickstart](https://cardog.app/docs/quickstart.md) (Getting started)
Next: [The Vehicle Graph](https://cardog.app/docs/vehicle-graph.md) (Getting started)
