# Keys and account API

An account holds up to 20 named access keys. See [Access keys and identity](concepts-keys.md) for why a key is shown once.

## The key object

```json
{"id":"k_37ea501438da","name":"ci-bot","fingerprint":"sha256:ebd50918c725db83",
 "hint":"bHTU","created_at":"...","last_used":null,"current":false}
```

- `id` is `k_` plus 12 hex characters and says nothing about the key.
- `fingerprint` is `sha256:` plus the first 16 hex characters of the key's SHA-256. It is what you put on a private link's allow-list.
- `hint` is the last four characters of the key.
- `last_used` is `null` until the key is used. It is refreshed at most once a minute, so it can lag.
- `current` is true for the key making the request.

## List

```sh
curl -H "Authorization: Bearer $FUZZY_KEY" https://fuzzyshare.com/me/keys
```

Returns `{"keys":[...]}`.

## Create

```sh
curl -H "Authorization: Bearer $FUZZY_KEY" -X POST https://fuzzyshare.com/me/keys -d '{"name":"ci-bot"}'
```

`201` with `{"key":"fuzzy_...","info":{...},"note":"..."}`. The key is shown once. Names are 1 to 40 characters (letters, digits, space, `.`, `_`, `-`), unique per account ignoring case. `400` for a bad name, `409` for a duplicate or the 21st key.

## Revoke

```sh
curl -H "Authorization: Bearer $FUZZY_KEY" -X DELETE https://fuzzyshare.com/me/keys/k_37ea501438da
```

Takes effect at once. `409` if it is your only key. Revoking the key you are using is allowed when another remains. A revoked key also stops working on the allow-lists of private links.

## Replace the key in use

`POST /me/key` keeps the key's id and name and gives it a new secret. The old secret stops working at once. See [the overview](api-overview.md#replace-the-key-in-use).

## Operator endpoints

With the admin key (`FUZZY_ADMIN_KEY`):

- `GET /admin/users` returns `{"users":[...]}`. Each row has `id`, `full_name`, `email`, `organization`, `purpose`, `created_at`, `last_seen`, `files`, `bytes` and `keys` (how many keys the person holds). It has no key hint, name or fingerprint.
- `DELETE /admin/users/{id}` removes an account and its files.

The admin key manages accounts only. It has no files of its own and cannot read link activity.
