# Authentication

Every request is authenticated with an API key sent in a header.

## API key

Send your key in the `X-API-Key` header on every request. Create and revoke keys in the [developer portal](https://autospec.launchit.ro/). A key is shown once, at creation, so store it somewhere safe.

**Request**

```bash
curl "https://autospec.launchit.ro/v1/makes" \
  -H "X-API-Key: as_live_your_key"
```

The same key also works as a bearer token, for clients that only speak that:

**Request**

```bash
curl "https://autospec.launchit.ro/v1/makes" \
  -H "Authorization: Bearer as_live_your_key"
```

A request with no key, or a key we do not recognise, is answered `401`. A key works until it is revoked or reaches its expiry date, if it was given one. Revoking takes effect immediately.

**401**

```json
{
  "error": "INVALID_CREDENTIAL",
  "detail": "A valid API key is required. Send it as X-API-Key or as a bearer token."
}
```

## What does not need a key

`GET /v1/health` is open, so an uptime check does not need a credential. Everything else does.

> **Keep keys server-side**
>
> An API key carries your account's whole budget, so it belongs on your server, not in a browser or a mobile app you ship. If a key is exposed, revoke it and create a new one. Every key on the account draws on the same budget, so rotating one does not disturb the others.
