# Authentication (/guides/authentication)

## Send the key [#header]

```http
Authorization: Bearer tmb_live_AbCd1234_9fQ...
```

All endpoints except `/v1/health` need it. HTTPS only.

## Key format [#format]

| Part | Example | Meaning |
|---|---|---|
| Environment | `tmb_live_` / `tmb_test_` | Live stores or sandbox stores |
| Prefix | `AbCd1234` | Public id of the key, shown in Backoffice and in `/v1/me`. Safe to log. |
| Secret | 32 characters | Never log it. TMBill stores only a hash and can't show it again. |

## When the key is refused [#failures]

| HTTP | code | What to do |
|---|---|---|
| 401 | `invalid_key` | Typo, wrong environment or unknown key. Check the value. |
| 401 | `key_revoked` | The owner revoked it. Ask for a new key. |
| 401 | `key_expired` | Past its expiry, or the old key after a roll. Use the new key. |
| 401 | `ip_not_allowed` | Calling from an IP not in the key's allow-list. |
| 403 | `insufficient_scope` | The key may not read this (e.g. Sales unticked). |
| 403 | `app_suspended` | The integration is paused. Contact TMBill support. |
| 403 | `ip_blocked` | Calls from your network are blocked (for example after many invalid keys). Contact TMBill support with the `request_id`. |

<Callout type="warn">
**Never put a key in a browser, mobile app or public repository.** Anyone with the key reads that restaurant's sales. Call the API from your server and pass on only what your app needs.
</Callout>