# Authentication

Every request carries a workspace API key in the `Authorization` header:

```http
GET /v1/results HTTP/1.1
Host: pub.hiringbranch.com
Authorization: Bearer hbk_your_key
```

## What a key can read

A key belongs to one workspace and reads that workspace's results only. Create one key for each system
that connects, so you can see which one is which and replace one without touching the others.

Keep keys on your servers. Don't put a key in a web page or a mobile app, where anyone can read it.

## When a key stops working

A key is refused when:

- it expires;
- an admin deletes it on the API keys page;
- an admin rotates it and the old key's time runs out (see below);
- HiringBranch turns off API access for the workspace, which ends every key of the workspace.

Every refusal gets the same answer, `401 Unauthorized`, whatever the reason. Check the key's status on the
API keys page to find out which one applies.

## Rotate a key

Rotate a key when it may have leaked, or before it expires. On the API keys page, open the key's menu and
select **Rotate**. A new key is created at once, and you pick when the old one stops working:

- **Immediately**, when the key may have leaked. Any system still using the old key loses access until you
  give it the new one.
- **24 hours** or **7 days**, for a routine change. Both keys work until then, so you can replace the key
  everywhere without downtime.

The new key gets the same lifetime as the old one: 90 days stays 90 days, and a key that never expired
still doesn't. A key can have at most three working versions at a time; past that, only an immediate
rotation is accepted.

## Delete a key

Deleting a key on the API keys page stops it at once, and can't be undone. Use it when a system no longer
needs access. To replace a key, rotate it instead.
