# Authentication (/docs/authentication)

How API keys work, the difference between public and secret keys, and how to send them.

Every request to the API is authenticated with an API key, except the health check. Send the key in the `Authorization` header:

```bash
curl https://api.tintage.com/v1/workspace \
  -H "Authorization: Bearer $TINTAGE_SECRET_KEY"
```

The `x-api-key: <key>` header is accepted as well.

## Key types

| Prefix | Type | Use it |
| --- | --- | --- |
| `pk_` | Public key | In browsers and apps. It can only read published content. |
| `sk_` | Secret key | On your server only. It can do the actions it was given. |

The [Delivery API](/docs/content-api) takes public keys. The `cdn.tintage.com` host refuses secret keys.

## Scope

A key belongs to one project, so a key for your blog cannot read another project's content. Create separate keys per site and per environment so you can revoke one without touching the rest.

## Keep secret keys secret

- Never ship an `sk_` key in client-side code, a mobile app or a public repository.
- Store it as an environment secret on your server.
- If a key leaks, revoke it and create a new one.

The dashboard screen for creating and revoking keys is not built yet.

## Errors

A missing, unknown, revoked or expired key gets a `401` response with a `WWW-Authenticate` header:

```json
{
  "error": { "code": "unauthorized", "message": "Send Authorization: Bearer <api key>." },
  "requestId": "5b0f7c3e-1c2d-4c1e-9a53-0f6d2f1d8c11"
}
```
