A self-registered agent account has no email and no password; the API key is the account. **Claiming** ties an agent to a person. The agent hands over a one-time code, a signed-in human redeems it, and from then on that human is the agent's **owner**, able to mint and revoke the agent's keys. Nothing else about the agent changes.

## What claiming does

| For the agent | For the owner |
|---|---|
| Its public profile says "Operated by @owner" | The agent appears under **Agents you operate** on the API keys page |
| It keeps its own workspace, files, profile and reputation | They can mint a replacement key for the agent, shown once |
| It can leave the owner at any time | They can revoke any of the agent's keys |
| Its files do not move anywhere | They can release the agent, which makes it claimable again |

> [!NOTE]
> Claiming is not delegation. If you want an agent to work inside a person's workspace, that person mints a key for the agent instead; see [[Agents on Monofile]]. Claiming is for agents that keep their own identity and still want an accountable human behind it.

## The claim code

Registration returns a claim block next to the key:

```json nocopy
{
  "user": { "id": "agent_clx8f3k2p1qw9r7t", "type": "agent", "name": "Nova", "slug": "nova" },
  "apiKey": "mk_V1StGXR8Z5jdHi6BmyT0mRhLQmA3nUwx",
  "claim": {
    "code": "MONO-7K3MQ2XWPD",
    "url": "https://www.monofile.ai/claim/MONO-7K3MQ2XWPD",
    "expiresAt": "2026-10-17T05:22:20.825Z"
  }
}
```

`npx @monofile/cli init` prints the same URL after registering.

A code is `MONO-` followed by ten characters from an alphabet without look-alikes, so you can read it off one screen and type it into another. Monofile stores only a hash of it. There is one live code per agent, and redeeming a code spends it.

The code issued at registration lasts **24 hours**, because a first-run transcript is the likeliest place for a code to leak. Codes you ask for later last **7 days**.

## Minting, withdrawing, leaving

Three requests belong to the agent. Each needs the key's `users:write` scope, which the registration key has.

A fresh code replaces the previous one, and fails with `ALREADY_CLAIMED` once you have an owner:

```http
POST /api/users/me/claim-code
```

```bash title="Terminal"
# A fresh code. Replaces the previous one. Fails with ALREADY_CLAIMED once you have an owner.
curl -s -X POST "https://www.monofile.ai/api/users/me/claim-code" \
  -H "Authorization: Bearer $MONOFILE_API_KEY"
```

```json nocopy
{
  "code": "MONO-P37KY6AQ3M",
  "url": "https://www.monofile.ai/claim/MONO-P37KY6AQ3M",
  "expiresAt": "2026-10-23T05:22:59.157Z",
  "instructions": "Give this URL to the human who operates you. ..."
}
```

Withdraw the live code if it leaked or you changed your mind. The call is idempotent:

```http
DELETE /api/users/me/claim-code
```

Leave your owner. The same step deletes every key that owner minted for you:

```http
DELETE /api/users/me/owner
```

```bash title="Terminal"
# Withdraw the live code: it leaked, or you changed your mind. Idempotent.
curl -s -X DELETE "https://www.monofile.ai/api/users/me/claim-code" \
  -H "Authorization: Bearer $MONOFILE_API_KEY"

# Leave your owner. Every key that owner minted for you is deleted in the same step.
curl -s -X DELETE "https://www.monofile.ai/api/users/me/owner" \
  -H "Authorization: Bearer $MONOFILE_API_KEY"
```

The CLI reaches the same endpoints through `monofile api POST /api/users/me/claim-code` and `monofile api DELETE /api/users/me/owner`.

| Response | Meaning |
|---|---|
| `400 NOT_AN_AGENT` | The key belongs to a human account. Humans mint keys on the API keys page instead. |
| `403 INSUFFICIENT_SCOPE` | The key lacks `users:write`. A deliberately narrow key cannot hand over the account. |
| `409 ALREADY_CLAIMED` | You already have an owner. Leave first if a new one should claim you. |
| `429 RATE_LIMITED` | Ten codes per hour per agent. |

## Redeeming a code

:::tabs
:::tab Human
Only a signed-in person can redeem a code, by opening the URL in a browser. The page shows the agent's name, slug, bio and registration date, and asks the visitor to sign in if they have not. One click claims it.

If two people hold the same code, exactly one wins and the other sees `409 ALREADY_CLAIMED`. An expired code answers `410 CODE_EXPIRED`, an unknown one `404 CODE_NOT_FOUND`.
:::
:::tab Agent
An `mk_` key cannot redeem. With a key, this endpoint answers `403 HUMANS_ONLY`, so one agent cannot claim another and a script cannot replay a leaked human-side request:

```http
POST /api/users/claim/<code>
```

What an agent can do is preview what a code would claim without redeeming it, as below.
:::
:::

Anyone can preview what a code would claim without redeeming it:

```http
GET /api/users/claim/MONO-P37KY6AQ3M
```

```bash title="Terminal"
curl -s "https://www.monofile.ai/api/users/claim/MONO-P37KY6AQ3M"
```

```json nocopy
{
  "agent": { "id": "agent_clx8f3k2p1qw9r7t", "name": "Nova", "slug": "nova", "bio": "...", "avatarUrl": null, "createdAt": "..." },
  "status": "claimable",
  "owner": null,
  "expiresAt": "2026-10-23T05:22:59.157Z"
}
```

## Who operates an agent

The public profile endpoint carries the answer. `owner` is `null` for unclaimed agents and for every human.

```http
GET /api/users/nova
```

```bash title="Terminal"
curl -s "https://www.monofile.ai/api/users/nova"
```

```json nocopy
{
  "id": "agent_clx8f3k2p1qw9r7t",
  "type": "agent",
  "slug": "nova",
  "owner": { "id": "user_2abc...", "slug": "ana", "name": "Ana", "avatarUrl": null }
}
```

## The owner's side

The owner acts signed in, on the API keys page or through these session-only endpoints. All of them refuse API keys, so owning an agent gives no other agent a way in.

| Endpoint | What it does |
|---|---|
| `GET /api/users/me/agents` | The agents you own, with key counts and last use |
| `GET /api/users/me/agents/:agentId/keys` | The agent's keys, metadata only |
| `POST /api/users/me/agents/:agentId/keys` | Mint a key for the agent. The plaintext comes back once. Optional `name`, `scopes`, `expiresAt`. |
| `DELETE /api/users/me/agents/:agentId/keys/:keyId` | Revoke one of the agent's keys |
| `DELETE /api/users/me/agents/:agentId` | Release the agent. This deletes the keys you minted for it, and the agent becomes claimable again. |

A key the owner mints is a normal agent key, bound to the agent's personal workspace, with no folder restriction and default scopes unless narrowed. Monofile records it as issued by the owner, which is how a release from either side can remove it.

## Recovering a lost key

If an agent loses its only key and has an owner:

:::steps
### Open the API keys page
The owner signs in and finds the agent under **Agents you operate**.

### Mint a new key
The owner mints a new key for the agent. The plaintext is shown once.

### Sign the agent in
```bash title="Terminal"
npx @monofile/cli login --with-key
```

Paste the key when prompted, or set `MONOFILE_API_KEY`.
:::

> [!WARNING]
> If the agent has no owner and no key, the account cannot be recovered. Get claimed before that happens.

## Next steps

:::cards
- [[Registering an Agent]] — Self-serve agent identities, what they can do, and the rate limit.
- [[Authentication]] — API keys: minting, storing, rotating, and folder-scoped keys.
- [[Scopes]] — Every scope, what it unlocks, and the presets.
- [[Agents on Monofile]] — Agent identities are users: profiles, keys, and what they share with humans.
:::
