Errors and refusal codes
Every refusal has a status and a code. Branch on the code. The text can change.
The shape of a refusal
A tool refusal is the tool's own JSON, with error (a sentence) and code (a stable name), and an HTTP status. A refusal never moves money. Read the code, fix the cause, then call again. Do not retry a 422 without a change.
Status and code
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_arguments | An argument is missing or wrong. The message names it. |
| 400 | api_key_in_url | The key was in the URL. Send it in the Authorization header. Revoke that key. |
| 401 | api_key_missing | No Authorization header. |
| 401 | api_key_invalid | The key is not a Fortell key, or it is unknown. |
| 401 | api_key_revoked | You revoked this key. Make a new one. |
| 401 | api_key_expired | The key passed its expiry date. Make a new one. |
| 401 | api_key_wallet_unlinked | The wallet of this key is no longer linked to your account. |
| 401 | api_key_signed_out | You signed out of every session after this key was made. Make a new one. |
| 401 | api_key_account_inactive | The account is not active. |
| 403 | api_key_scope | The key lacks a scope. The body field needs names it. |
| 403 | confirm_needs_website | This step needs a confirmation on the website. A key cannot give one. |
| 403 | wallet_not_yours | You named a wallet that is not the wallet of the key. Omit wallet. |
| 404 | not_found | No such endpoint. GET /v1/agent lists them. |
| 405 | method_not_allowed | Wrong HTTP method. The Allow header names the right one. |
| 409 | in_flight | The same call is still running. Wait, then read your state. |
| 422 | (the tool's code) | The tool refused. The body has error and code. Read the code and do not retry blindly. |
| 429 | rate_limited | Over a limit. Wait Retry-After seconds. |
| 503 | api_keys_off | API keys are off on this server. |
| 503 | store_unavailable | The server store is down. Try again shortly. |
| 503 | limiter_unavailable | The limiter is down. Try again shortly. |
The 429, 409 and 503 codes are the same ones the MCP returns. A tool also has its own codes, for example for an order below the smallest size. They come back with status 422.
What to do
- 401: check the key, its expiry and its wallet. Make a new key if it was revoked.
- 403
api_key_scope: make a key with the scope named inneeds. - 409: the same call is still running. Wait, then read your state.
- 429: wait the Retry-After seconds.
- 503: try again shortly. Back off between tries.