# Authentication and keys

> How to make a key, send it, and give it only the scopes it needs.

On the web: https://www.aeyho.com/docs/api/authentication-and-keys

## Sending a key

Every call sends your key as a bearer token:

```
Authorization: Bearer aey_live_...
```

A call with no key, or with one that's unknown, revoked or past its expiry, answers `401` with the code [`unauthorized`](/docs/api/errors#unauthorized).

## Making a key

Make keys in aeyho's settings. Each key has:

- **A name**, so you can tell keys apart.
- **A mode.** Live keys (`aey_live_…`) do real work and use credits. Test keys (`aey_test_…`) answer changes with samples. See [test mode](/docs/api/test-mode).
- **Scopes**, which say what the key may do.
- **An expiry**, if you want one.

A key is `aey_live_` or `aey_test_` followed by 32 letters and digits. It's shown once, when it's made. aeyho keeps only a hash of it, so a lost key can't be shown again: revoke it and make a new one. You can have 10 keys at a time.

## Scopes

| Scope | What it allows |
|---|---|
| `read` | Read anything in your account: brands, plans, reels, versions, comments, webhooks. Also Reel Score checks. |
| `make` | Change things: make brands, reels and carousels, ask for changes, comment, fix, restore, manage taste and webhooks. Most of these use credits. |
| `post` | Kept for posting. No v1 route needs it yet. |

A key with no scopes chosen gets `read`. A call the key's scopes don't cover answers `403` with the code [`forbidden`](/docs/api/errors#forbidden). The [API reference](/docs/api/reference) lists the scope of every route.

## Keeping keys safe

- Keep keys on your server, in an environment variable or a secret store. Never in a public page or an app people can download.
- Give each integration its own key, with only the scopes it needs.
- Revoke a key in aeyho's settings as soon as you think it leaked. It stops working at once.
- Keys start with `aey_`, so secret scanners can spot one in code.

## Try it

```bash
curl https://www.aeyho.com/api/v1/account \
  -H "Authorization: Bearer $AEYHO_KEY"
```
