# Getting a key (/guides/getting-a-key)

## Create a key (owner) [#create]

<Steps>
<Step>
**Open Backoffice as the owner**

Log in with the company owner account and go to **Settings › API keys**. Staff and sub-user logins do not see this screen.
</Step>

<Step>
**Fill in the form**

- **Name**: who it is for, e.g. "Acme ERP" (letters, digits and `. , & ( ) ' _ -`, up to 100 characters).
- **Environment**: `live` for real stores or `test` for the sandbox.
- **What it may read**: Sales, Stores (both ticked by default).
- **Stores**: all stores (including stores opened later), or chosen brands, markets, clusters or single stores.
- **Allowed IP addresses** (optional, up to 20, IPv4/IPv6 or CIDR): the key works only from these.
- **Expiry** (optional): default is never.
</Step>

<Step>
**Confirm with the one-time code**

TMBill emails a 6-digit code to the owner's verified address. It is valid for 5 minutes, works once, and only approves exactly the form that was sent. TMBill staff and developers will never ask for it.
</Step>

<Step>
**Copy the key**

The key is shown **once**. The owner passes it to you through a safe channel (a password manager share, not chat or email).
</Step>
</Steps>

## Roll a key (no downtime) [#roll]

Rolling issues a new key and keeps the old one working for a chosen time: **now**, **1 hour**, **24 hours** or **7 days**. It also needs the owner's one-time code. Deploy the new key, check `/v1/me` with it, then let the old one stop.

## Revoke a key [#revoke]

The owner clicks **Revoke**. The key stops working on the very next call (`401 key_revoked`). No code is needed, because revoking only removes access. Do this at once if a key may have leaked.

## Rules worth knowing [#rules]

| Rule | Why |
|---|---|
| Keys never expire unless the owner sets an expiry | Integrations should not break on a date nobody remembers |
| At most 2 active keys per app and environment | Enough for a roll; more means something is wrong |
| If the owner's email or phone changed in the last 14 days, new keys wait | Stops someone who took over a login from minting keys |
| A revoked or already stopped key can't be rolled | Retired keys stay retired |