# Errors

Every code the creator API answers with: its HTTP status and message, the fix where there is one, and whether a retry helps.

Other endpoints, such as OAuth's, answer with their own errors, which aren't listed here.

## The error object

A refusal's body is one object, `error`; NOT_CLAIMED's, as the server sends it:

```json 403
{
  "error": {
    "code": "NOT_CLAIMED",
    "message": "This account is an agent's own, which no person has claimed yet.",
    "fix": "The person the agent works for opens the claim link in `action.url`, signs in or makes a free account, and claims it; the agent's refresh token then works in their account, on the games the agent made and new ones it makes, and nothing else; listing them publicly then needs the person's leave too (NEEDS_MEMBER_PUBLISH). Until then its games stay private or unlisted, and from offlineAt on it takes no new uploads.",
    "retryable": false,
    "needsHuman": true,
    "docs": "https://nimblefox.ai/docs/agents/errors.md#not_claimed",
    "action": {
      "url": "https://nimblefox.ai/claim/…",
      "says": "Your agent made a Nimble Fox account for your game. Open this link, sign in or make a free account, and claim it to keep the game and share it."
    }
  }
}
```

| Field | Type | When | Meaning |
| --- | --- | --- | --- |
| `code` | string | Always | One of the codes below, each under its HTTP status. |
| `message` | string | Always | What was refused. |
| `fix` | string | Always | What to change before calling again. |
| `docs` | string (uri) | Always | The code's entry here. |
| `retryable` | boolean | Always | Whether the same call may work later. |
| `needsHuman` | boolean | Always | Whether the next step is a person's. If so, the agent stops calling, gives its person the `fix` and any `action.url` with `action.says`, and waits. |
| `action` | object | When `needsHuman` | The page for the person, `url`, and a sentence to pass on, `says`. |
| `retryAfter` | integer | When a wait helps | Seconds to wait, also in the `Retry-After` header. |
| `limit` | integer | A limit's refusal | The limit that refused the call. |
| `used` | integer | A limit's refusal | How much of the limit is used. |
| `resetsAt` | string (date-time) | A limit's refusal | When the limit's window ends. |
| `scope` | string | SCOPE_MISSING, RATE_LIMITED | SCOPE_MISSING: the OAuth scope the call needs. RATE_LIMITED from the agent-account calls: the limit that refused, address, network or everyone; from an upload, account or address. |
| `signIn` | "device" | RATE_LIMITED, while offered | RATE_LIMITED from the agent-account calls, only while the refusal offers it: signing in to a person's account with the device flow is the way on now. Absent, waiting is the only remedy. |
| `where` | object | A field, file or line | `file`, `field` and `line`: where in the request or the build. |
| `detail` | string | Some codes | What was wrong, in the server's words. |

## HTTP 400 Bad Request

### IDEMPOTENCY_KEY_REQUIRED

- Status: 400
- Message: POST, PATCH and DELETE calls take an Idempotency-Key header of 8–64 letters, digits, `_` or `-`.
- Fix: Send a new random key, such as a UUID, with each new call, and the same key with the same body when retrying it.
- Retryable: no

### CHALLENGE_INVALID

- Status: 400
- Message: The proof of work's challenge is unknown, used or expired, or the nonce doesn't solve it.
- Fix: Send the `challenge` that GET /api/v1/agent-accounts/challenge answered, with a nonce such that SHA-256 of the challenge followed by the nonce starts with `difficulty` zero bits. A challenge works once and expires: a used or expired one needs a new one from that call.
- Retryable: yes

### BAD_REQUEST

- Status: 400
- Message: The request isn't valid.
- Fix: Correct the field named in `where.field`; `detail` says what it takes. The body is one JSON object. Where the answer has no `where`: `detail` says what the request needs. The body is one JSON object, and a value in it can't hold a bare `"` or `\`.
- Retryable: no

### BUNDLE_FILE_TYPE

- Status: 400
- Message: The build has a file of a type Nimble Fox doesn't serve.
- Fix: Leave out or rename the file in `where.file`; `detail` names the rule. HTML5 builds take web files (scripts, styles, JSON, images, audio, fonts, text), and no service worker.
- Retryable: no

### BUNDLE_PATH

- Status: 400
- Message: A file's path isn't one Nimble Fox accepts.
- Fix: Rename the file in `where.file`: paths use English letters, digits, `_`, `-`, `.` and `/`, have no empty, “.” or “..” parts, sit under Build/Web/ for HTML5 and appear once.
- Retryable: no

### BUNDLE_TOO_LARGE

- Status: 400
- Message: The build, or one of its files, is over its size limit.
- Fix: Make the file in `where.file`, or the whole build, smaller than `limit` bytes; /api/v1/limits gives every size limit.
- Retryable: no

### BUNDLE_TOO_MANY_FILES

- Status: 400
- Message: The build has more files than an upload takes.
- Fix: Bundle files together until the build has at most `limit` files.
- Retryable: no

### BUNDLE_LAYOUT

- Status: 400
- Message: The files aren't a complete build of the game's runtime.
- Fix: For an HTML5 build, upload its page as Build/Web/index.html, saved as UTF-8, not UTF-16, with the files it loads beside it; for a Unity WebGL build, exactly one each of .loader.js, .framework.js, .data and .wasm in Build/Build/, and its StreamingAssets in Build/StreamingAssets/. `detail` says what is missing or wrong.
- Retryable: no

### MANIFEST_INVALID

- Status: 400
- Message: The build's Build/Web/nimblefox.json isn't valid, so the build wasn't published.
- Fix: nimblefox.json is a JSON object. `where.field` is the first field that broke a rule and `detail` says how. Upload the build again with the file fixed.
- Retryable: no

### PART_SIZE

- Status: 400
- Message: The part's body isn't this part's exact length.
- Fix: Send exactly this part's bytes: every part but a file's last is `partSize` bytes, and the last is the rest of the file.
- Retryable: no

### FEEDBACK_SECRET

- Status: 400
- Message: The report looks like it holds a secret, such as an access token, a key or a password, so it wasn't kept.
- Fix: Remove the secret from the field in `where.field` (`detail` names its kind), or replace it with a placeholder such as \<token\>, then send the report again. Never send secrets or personal data in a report.
- Retryable: no

## HTTP 401 Unauthorized

### AUTH_REQUIRED

- Status: 401
- Message: This call needs an access token.
- Fix: Send an access token as Authorization: Bearer \<token\>. With a person at hand, get one from Nimble Fox's OAuth server, which the resource_metadata link in WWW-Authenticate names; the person approves the sign-in once. Where this server offers agent accounts (auth.md says whether it does), an agent with no person at hand makes an account of its own with POST /api/v1/agent-accounts, after a proof of work from GET /api/v1/agent-accounts/challenge; the answer has its tokens and a claim link for the person. The docs link describes both.
- Retryable: no

### AUTH_INVALID

- Status: 401
- Message: The access token is unknown, expired or revoked.
- Fix: Get a new access token with the refresh token at the token endpoint; if that is refused too, sign in again.
- Retryable: no

## HTTP 403 Forbidden

### SCOPE_MISSING

- Status: 403
- Message: This token's grant doesn't include the scope this call needs.
- Fix: Sign in again asking for the scope named in `scope` as well as the grant's others; the member approves it.
- Retryable: no

### NOT_CLAIMED

- Status: 403
- Message: This account is an agent's own, which no person has claimed yet.
- Fix: The person the agent works for opens the claim link in `action.url`, signs in or makes a free account, and claims it; the agent's refresh token then works in their account, on the games the agent made and new ones it makes, and nothing else; listing them publicly then needs the person's leave too (NEEDS_MEMBER_PUBLISH). Until then its games stay private or unlisted, and from offlineAt on it takes no new uploads.
- Retryable: no

### NEEDS_MEMBER_PUBLISH

- Status: 403
- Message: Making this game public lists it under the member's name, which this grant does only with the member's leave.
- Fix: The member makes the game public from its page in `action.url`, or opens the claim link again and allows it there, which adds `publish` to this grant (the token endpoint's next `scope` shows it). Unlisted, shared with anyone who has its link, and private stay the agent's to set.
- Retryable: no

### NEEDS_MEMBER_SIGN_IN

- Status: 403
- Message: This tool acts on the member's whole account, which this grant, on only the games its agent made, can't reach.
- Fix: The member connects the assistant to Nimble Fox with a normal sign-in of their own, approving it on the consent page; that grant has every tool. The `platform_` tools work with this grant as it is.
- Retryable: no

### UNLISTED_NEEDS_PRO

- Status: 403
- Message: Sharing a game by its unlisted link is part of Pro.
- Fix: The person's plan must include sharing by link: they get Pro, or keep the game private. A game that can be listed publicly, which an HTML5 game can't be yet, may be made public instead, within the free plan's public games.
- Retryable: no

### PUBLIC_NEEDS_REVIEW

- Status: 403
- Message: An HTML5 game can't be made public before Nimble Fox's first-listing review, which isn't open yet.
- Fix: Make the game unlisted, which shares it with anyone who has its link (`play`, or the QR code at `qr`), or keep it private. Unlisted is part of Pro where plans apply.
- Retryable: no

### CHECK_MINER_SUSPECTED

- Status: 403
- Message: This version's deploy checks found code that mines cryptocurrency, so Nimble Fox serves it only to its owner.
- Fix: Upload a new version without the mining code, with POST /api/v1/games/{id}/versions; GET /api/v1/games/{id}/versions/{version}/checks gives every check of a version. A build that mines nothing can ask support\@nimblefox.ai for a person to look.
- Retryable: no

### CHECK_PHISHING_SUSPECTED

- Status: 403
- Message: This version's deploy checks found a form that asks for passwords or payment details as phishing pages do, so Nimble Fox serves it only to its owner.
- Fix: Upload a new version without the password or payment form, with POST /api/v1/games/{id}/versions; GET /api/v1/games/{id}/versions/{version}/checks gives every check of a version. A build that phishes no one can ask support\@nimblefox.ai for a person to look.
- Retryable: no

### CHECK_PENDING

- Status: 403
- Message: This version's deploy checks haven't finished yet, so Nimble Fox serves it only to its owner until they have.
- Fix: Retry after a few minutes: Nimble Fox checks the version again by itself, first after a minute, then less often, and nothing needs changing in the build. GET /api/v1/games/{id}/versions/{version}/checks says `pending` until then, and the result after.
- Retryable: yes

## HTTP 404 Not Found

### NOT_FOUND

- Status: 404
- Message: The creator API has no such address.
- Fix: No creator API operation is at this address: an id in it may be empty or wrong. /openapi.json lists the creator API's operations.
- Retryable: no

### GAME_NOT_FOUND

- Status: 404
- Message: This account has no game with this ID.
- Fix: GET /api/v1/games lists the account's games with their IDs.
- Retryable: no

### VERSION_NOT_FOUND

- Status: 404
- Message: This game has no version with this ID.
- Fix: A version's ID is the `version` of the upload's job once it is live; GET /api/v1/games/{id} gives the game's currentVersion and publishedVersion.
- Retryable: no

### UPLOAD_NOT_FOUND

- Status: 404
- Message: This account has no upload with this ID, or it has no such file or part.
- Fix: Use the upload's `id`, and each file's `index` and its parts from 0 to `parts` − 1, as the call that started it answered.
- Retryable: no

### JOB_NOT_FOUND

- Status: 404
- Message: This account has no job with this ID.
- Fix: A job's ID is the `job` of the upload that started it; GET /api/v1/games/{id} shows a game's upload under way.
- Retryable: no

## HTTP 405 Method Not Allowed

### METHOD_NOT_ALLOWED

- Status: 405
- Message: This address doesn't take this method.
- Fix: Use one of the methods in `allow`.
- Retryable: no

## HTTP 408 Request Timeout

### BODY_TIMEOUT

- Status: 408
- Message: The request's body didn't arrive within its time.
- Fix: Send the call again, with the same Idempotency-Key; the whole body has 30 seconds to arrive.
- Retryable: yes

### PART_TIMEOUT

- Status: 408
- Message: The part didn't arrive within its time.
- Fix: Send the part again; each part has five minutes, never past the upload's `expiresAt`, and is cut off once it sends nothing for 15 seconds.
- Retryable: yes

## HTTP 409 Conflict

### IDEMPOTENCY_MISMATCH

- Status: 409
- Message: This Idempotency-Key was used for another call in the last 24 hours.
- Fix: Use a new key for a new call. A retry repeats its first call's key with the same method, address and body.
- Retryable: no

### LIMIT_UPLOADED_GAMES

- Status: 409
- Message: This account keeps as many uploaded games as it can.
- Fix: A deleted uploaded game makes room for another; `limit` and `used` give the numbers.
- Retryable: no

### LIMIT_PUBLIC_GAMES

- Status: 409
- Message: The free plan keeps only this many games public.
- Fix: Keep this game private, or make room by making another of the account's public games private; Pro keeps more public. `limit` and `used` give the numbers.
- Retryable: no

### GAME_HIDDEN

- Status: 409
- Message: Nimble Fox has hidden this game, so it stays private until we show it again.
- Fix: Leave the game private: no call changes its visibility while Nimble Fox hides it. Its other settings, such as its title, can still change; the person can ask Nimble Fox's support why it is hidden.
- Retryable: no

### GAME_SOLD

- Status: 409
- Message: This game is kept for the people who bought it, so it can't be made private.
- Fix: Keep the game public or unlisted; `detail` says why it is kept. Its buyers play it for as long as Nimble Fox runs.
- Retryable: no

### NEWER_VERSION

- Status: 409
- Message: A newer version arrived while releasing.
- Fix: A newer version arrived while releasing. Release again to publish the newest version, or check which version it is first.
- Retryable: yes

### ITEMS_NEED_OWNER

- Status: 409
- Message: This is one of Nimble Fox's own games, so only its owner publishes its versions.
- Fix: Its owner publishes this version in the Publish dialog on the game's page, where the version's items are listed with Nimble Fox's checklist; `action` is that page. No call publishes it.
- Retryable: no

### UPLOAD_IN_PROGRESS

- Status: 409
- Message: This game has an upload or change under way.
- Fix: Wait for it to end, with GET /api/v1/jobs/{job}?wait=40 for the game's `upload.job`, or cancel it with DELETE /api/v1/jobs/{job}; then start the new build.
- Retryable: yes

### NOT_AN_UPLOADED_GAME

- Status: 409
- Message: This game was made with prompts on Nimble Fox, and only uploaded games take builds.
- Fix: Upload the build as a new game with POST /api/v1/games.
- Retryable: no

### NO_VERSION

- Status: 409
- Message: This game has no playable version yet.
- Fix: Wait for its upload's job to turn `live` (GET /api/v1/jobs/{job}?wait=40), then try again.
- Retryable: no

### PART_MISMATCH

- Status: 409
- Message: A stored file doesn't match the bytes sent for it.
- Fix: Start the upload again with POST /api/v1/games for a new game, or POST /api/v1/games/{id}/versions for a new build, sending each part's bytes as they are.
- Retryable: no

### JOB_FINISHED

- Status: 409
- Message: This job has already ended.
- Fix: GET /api/v1/jobs/{id} gives how it ended.
- Retryable: no

### UPLOAD_PROCESSING

- Status: 409
- Message: This upload's build is being stored, so it can no longer be cancelled.
- Fix: GET /api/v1/jobs/{id}?wait=40 shows it go live; to replace it, start a new build with POST /api/v1/games/{id}/versions.
- Retryable: yes

## HTTP 410 Gone

### GAME_DELETED

- Status: 410
- Message: The game was deleted while this upload was under way.
- Fix: Start again with POST /api/v1/games for a new game, or POST /api/v1/games/{id}/versions for a new build.
- Retryable: no

### UPLOAD_EXPIRED

- Status: 410
- Message: The upload's two hours to send its parts have passed.
- Fix: Start the upload again with POST /api/v1/games for a new game, or POST /api/v1/games/{id}/versions for a new build.
- Retryable: no

### UPLOAD_CANCELLED

- Status: 410
- Message: The upload was cancelled.
- Fix: Start it again with POST /api/v1/games for a new game, or POST /api/v1/games/{id}/versions for a new build.
- Retryable: no

## HTTP 413 Content Too Large

### LIMIT_VERSION_BYTES

- Status: 413
- Message: This build is larger than the account takes for one version.
- Fix: Send a build of at most `limit` bytes in all, versionBytes in /api/v1/limits; a claimed account takes larger ones.
- Retryable: no

### LIMIT_STORAGE

- Status: 413
- Message: This account holds as many bytes of builds as it can.
- Fix: The account holds at most `limit` bytes in all, its uploaded games' versions and its uploads under way: storedBytes in /api/v1/limits, whose `used` this is. Cancel an upload under way, delete an uploaded game it no longer needs, or send a smaller build; an unclaimed account takes more once its person claims it.
- Retryable: no

### BODY_TOO_LARGE

- Status: 413
- Message: The request's body is too large.
- Fix: Send a body of at most `bodyBytes` bytes, the `limit` here and in /api/v1/limits, as compact JSON without indentation.
- Retryable: no

### FEEDBACK_TOO_LARGE

- Status: 413
- Message: The report is longer than a report takes.
- Fix: Shorten the field in `where.field` to at most `limit` characters; without a `where`, the whole report is over `limit` characters. Keep the steps and the lines of the log around the failure; /api/v1/limits gives every cap in feedback.
- Retryable: no

## HTTP 429 Too Many Requests

### RATE_LIMITED

- Status: 429
- Message: Too many calls in this window.
- Fix: Send the call again after `retryAfter` seconds; `limit` is the window's allowance and /api/v1/limits shows them all.
- Retryable: yes

### LIMIT_UPLOAD_BYTES

- Status: 429
- Message: This account's uploads have sent as many bytes today as it takes.
- Fix: Send the upload again after `retryAfter` seconds, at `resetsAt`; `limit` and `used` are the day's bytes, uploadBytesPerDay in /api/v1/limits.
- Retryable: yes

## HTTP 500 Internal Server Error

### UPLOAD_FAILED

- Status: 500
- Message: The upload failed.
- Fix: Start it again with POST /api/v1/games for a new game, or POST /api/v1/games/{id}/versions for a new build.
- Retryable: no

## HTTP 502 Bad Gateway

### STORAGE_FAILED

- Status: 502
- Message: Every part arrived, but storing the build kept failing.
- Fix: Start the upload again with POST /api/v1/games for a new game, or POST /api/v1/games/{id}/versions for a new build.
- Retryable: no

## HTTP 503 Service Unavailable

### BUSY

- Status: 503
- Message: The server is holding as many parts as it takes at once, from this account or in all.
- Fix: Send the part again after `retryAfter` seconds; an account sends at most 2 parts at once.
- Retryable: yes

### SERVICE_UNAVAILABLE

- Status: 503
- Message: The service is temporarily unavailable.
- Fix: Send the call again after `retryAfter` seconds, with the same Idempotency-Key if it has one.
- Retryable: yes

## Deploy checks

GET /api/v1/games/{id}/versions/{version}/checks answers a version's deploy checks. Each check that doesn't pass carries its finding as an error object. A failed miner or phishing check holds the version: it is served only to its owner, under [`CHECK_MINER_SUSPECTED`](#check_miner_suspected) or [`CHECK_PHISHING_SUSPECTED`](#check_phishing_suspected). A version whose checks couldn't finish, a storage read that failed say, is held the same way under [`CHECK_PENDING`](#check_pending): its checks answer `pending`, its owner plays it as usual, and other players who open it get CHECK_PENDING's 403 until Nimble Fox has checked it again, by itself, within minutes. There is nothing to change in the build: retry the checks address later, and the result then settles it (served to everyone, or held as a miner or phishing).

### Findings that hold nothing

#### CHECK_FILE_FORMAT

- Message: A file of this version isn't the kind of file its name says, or isn't one a web game can use.
- Fix: Export the file in `where.file` again in its real format, or leave it out, then upload a new version. The version is served meanwhile.

#### CHECK_EXTERNAL_HOSTS

- Message: This version loads or connects to other websites, which games here can't reach, so those parts don't work for players.
- Fix: Bundle the files from the hosts in `hosts` with the game, or install the libraries with npm and bundle them, then upload a new version. The version is served meanwhile.

## Relaying a sign-in from the CLI

When a new account's [`RATE_LIMITED`](#rate_limited) means a wait of over an hour, its `action` sends the person to `/device`. An agent using the `nimblefox` CLI relays the CLI's own sign-in when its Fix names `nimblefox login`: that Fix, then the Open link and the code that `nimblefox login --device` prints. It doesn't relay the `/device` sentence in the refusal's `action.says` as well.

## The CLI's own codes

The `nimblefox` CLI ends with these codes of its own as well as the creator API's. With `--json`, each is the answer's `error.code`, and the exit code is the process's.

### USAGE

- Exit code: 2
- Message: The command as given isn't one the CLI runs: an unknown command, flag or value, or a folder or setting it refuses.
- Fix: Run `nimblefox --help` for the commands and their flags, or `nimblefox <command> --help` for one command's.

### INTERRUPTED

- Exit code: 130
- Exit code 143 instead: stopped by SIGTERM, or because the launcher that started it, such as npm's package runner, ended.
- Message: The command was stopped by Ctrl+C or a signal before it finished.
- Fix: Run the same command again. Its own Fix line says what the stopped run left to do. Run through `npx`, read `--json`'s `INTERRUPTED` answer, which comes a moment after npx ends: npx's own exit status is the signal's.

### GAME_IN_UNCLAIMED_ACCOUNT

- Exit code: 3
- Message: This folder's game is in the unclaimed agent account this computer made earlier, not in the account signed in now.
- Fix: The person opens the claim link, which `nimblefox claim` shows, while signed in to their account, which moves the game there; then run `nimblefox deploy` again. Or run `nimblefox deploy --new-game` to make a new game in this account.
