# Credentials for agents

How a coding agent gets a token for a person's Nimble Fox account. The person takes the steps in the first section; the agent does the rest.

## What a person does

- Uses their browser to sign in to Nimble Fox, with a code emailed to them or with Google, or to make an account.
- Approves the agent's access on the consent page the agent opens, which names the agent and where it comes from.
- For an agent without a browser: opens `https://nimblefox.ai/device` and types the code the agent shows.
- For an account an agent made itself: opens the claim link the agent gives and claims it.

The person can disconnect the agent in Settings, which ends its tokens at once.

## OAuth 2.1 with PKCE

- The authorization code flow with PKCE, method `S256`. Clients are public: no client secret.
- The authorization server's metadata, with every endpoint: `https://nimblefox.ai/.well-known/oauth-authorization-server`.
- A local agent registers itself at `https://nimblefox.ai/oauth/register` (RFC 7591) with a loopback redirect, such as `http://127.0.0.1:<port>/callback`, on any port.
- A hosted assistant on claude.ai, claude.com, chatgpt.com or openai.com may instead use as its client ID the address of a client ID metadata document on those hosts.

## Device flow

- For agents with no browser or loopback port (RFC 8628): the metadata's `device_authorization_endpoint` gives a code, and the token endpoint takes the grant type `urn:ietf:params:oauth:grant-type:device_code`.
- The person types the code at `https://nimblefox.ai/device`.
- It takes one client: send `client_id` `nimblefox-cli`. A client registered at `/oauth/register` gets `invalid_client` here.

## Unclaimed agent accounts

An agent that has no person at hand to approve a sign-in can make an account of its own, which its person claims later with one link.

1. `GET https://nimblefox.ai/api/v1/agent-accounts/challenge` answers `{challenge, difficulty, expiresAt, limits}`. A challenge works once, for 10 minutes.
2. The proof of work: find a nonce of 1–64 letters, digits, `_` or `-` such that SHA-256 of the challenge's UTF-8 bytes followed by the nonce's starts with `difficulty` zero bits.
   - The difficulty is 20 by default, about a second of a laptop's CPU; the challenge gives the one in force. There is no CAPTCHA.
3. `POST https://nimblefox.ai/api/v1/agent-accounts` with an `Idempotency-Key` header and the JSON body `{"client": "…", "challenge": "…", "nonce": "…"}`. `client` names the agent and its tool in at most 100 characters (letters, digits, spaces and ._()/+:-, without :// or @; anything else is 400 `BAD_REQUEST`), such as `Claude Code (Berry Fox)`. A tool that calls for an agent may send its own name as `client` and the agent's as `agent`, under the same rule; the claim page shows the agent's.
   - The person sees this name on the claim page and in Settings, so pick one they'll recognize. The email sent after a claim doesn't name the agent.
   - Nothing personal is asked or kept.

The 201 answer has:

- `access_token` and `refresh_token`: A grant of the account for the client `nimblefox-cli` that the token endpoint refreshes as any other.
- `account`: Its `id`, `offlineAt` and `deleteAt`.
- `claim`: The claim link's `url` and `code`.

### Limits

- Accounts a day from one address: 3
- Accounts a day from one network, an IPv4 /24 or an IPv6 /48: 20
- Accounts an hour from everyone together: 200 by default

The challenge's `limits` gives today's. Past one, the call answers 429 `RATE_LIMITED` with `retryAfter`.

Cloud sandboxes, CI, VPNs and shared networks put many agents behind one address or network, so these limits can be used up before the agent's first call; the refusal's `scope` says which one refused it: `address`, `network` or `everyone`. A sandbox whose home folder doesn't outlast the session keeps no tokens, so it makes a new account each session. With a person at hand, sign in to their account instead with the [device flow](#device-flow): they approve it once, it makes no new account, and these limits don't count it; a refusal that offers it says `signIn: "device"`.

### What an unclaimed account can do

- Uploaded games: at most 3
- A version: at most 50000000 bytes
- In all, its versions and uploads under way: at most 150000000 bytes
- Uploads a day: 10, a failed one included

Past the bytes in all, it gets 413 `LIMIT_STORAGE`. Its games are private or unlisted: anyone with an unlisted game's link can play it, and it isn't listed in Explore. Listing a game publicly and generated assets need a claimed account. `/api/v1/limits` shows the numbers, `storedBytes` among them.

### The claim

The agent gives its person the claim link, `https://nimblefox.ai/claim/<code>`. The person signs in or makes a free account and selects Claim.

#### What moves

Claim moves the games into the person's account and emails them that the agent was connected. Its games carry the person's name and count toward their account's limits.

#### The agent's tokens

After the claim, the agent's access token ends. Its refresh token keeps working in the person's account, on the games its account made and the ones it makes later, and nothing else.

The agent's token works at the creator API and with the MCP server's platform tools. The person's other games answer `GAME_NOT_FOUND`.

It holds at most 6 of the person's uploaded games, those it made before the claim and after. Past them a new game answers 409 `LIMIT_UPLOADED_GAMES`: the person deletes one of them, or the agent signs in to the person's whole account with the device flow.

#### Listing a game publicly

An HTML5 game can't be listed publicly yet, whatever the grant's scope: until Nimble Fox's first-listing review exists, `visibility: "public"` answers 403 `PUBLIC_NEEDS_REVIEW`.

Any other game can be listed: listing it publicly puts it in Explore under the person's name. The claim page offers the person one choice, unticked, to let the agent do that too.

They allow it at the claim or by opening the claim link again later, which adds `publish` to the same grant. If they did, the grant's `scope` at the token endpoint includes `publish`.

Otherwise, for a game that can be listed, `visibility: "public"` answers 403 `NEEDS_MEMBER_PUBLISH`, whose `action.url` is the game's page, where the person selects Publish. Unlisted and private stay the agent's: anyone with an unlisted game's link can play it, and it isn't listed in Explore.

#### The person's part

The claim is the one step the person takes to keep the games; listing one publicly is theirs too unless they allowed it. The person can disconnect the agent in Settings.

For more of their account, the agent signs in as above, which the person approves. That sign-in is a grant of its own, and the claimed one goes on.

### On the MCP server

An unclaimed account's access token works at `https://nimblefox.ai/mcp` too, with no consent page and no human step until the claim: `initialize`, `tools/list` and the platform tools (`platform_` and a name), which make the same creator API calls under the same caps.

The studio's tools answer `NEEDS_MEMBER_SIGN_IN` before the claim and after it, as they take the person's own sign-in; before the claim its `action.url` is the claim link.

Two steps are plain HTTPS, not MCP: making the account, as above, and sending each of the build's parts, with the same access token.

### Lifetime

How long an unclaimed account lasts: its games play for others for 7 days after it was made, and it is kept for at most 30 days, until its person claims it.

From 5 days on, every creator API answer to the account carries a `CLAIM_SOON` warning with the claim link.

7 days after it was made, an unclaimed account's games stop playing for others and it takes no new uploads (`NOT_CLAIMED`). After 30 days it is deleted with everything it owns, and its claim link ends. A claim before then restores everything at once.

## Scopes

An HTML5 game can't be listed publicly yet, whatever the scope: `visibility: "public"` answers 403 `PUBLIC_NEEDS_REVIEW`.

- `games`: the account's games, through the MCP server's tools
- `games:all`
- `publish`: listing any other game publicly, which puts it in Explore under the person's name; every grant needs it for that
- `offline_access`: a refresh token, so the agent keeps access without the person

## Where tokens go

- Each call to the creator API, under `https://nimblefox.ai/api/v1`, sends the access token as `Authorization: Bearer <token>`, except the two that make an unclaimed agent account, its challenge and the account's creation, which come before the agent has a token.
- Each call to the MCP server, `https://nimblefox.ai/mcp`, sends the access token as `Authorization: Bearer <token>`.
- An access token lasts an hour. The token endpoint trades the refresh token for a new pair; each refresh replaces the refresh token.
