# Errors

Source: https://docs.testnet.mog.xyz/api/reference/errors/

Markdown: https://docs.testnet.mog.xyz/api/reference/errors.md

Reviewed protocol version: 11.0.0

Protocol review date: 2026-10-30

Scope: reviewed public documentation. Numerical examples use illustrative or launch settings; they are not live quotes or a guarantee of current deployed parameters. Consult the app for current market and position values.

## CLI exit codes

Every `mog` command exits with one of these codes. With `--json`, the same number is in `error.exit`.

| Code | Meaning                                                                    | Retry                                      |
| ---- | -------------------------------------------------------------------------- | ------------------------------------------ |
| 0    | Done                                                                       | —                                          |
| 1    | An unexpected fault in the CLI                                             | Report it                                  |
| 2    | Bad arguments. Nothing was signed or sent.                                 | Fix the command                            |
| 3    | No usable session key, or a wallet signature is missing. Nothing was sent. | Fix the key                                |
| 4    | The venue or the relay refused. Nothing changed.                           | Read `error.code` first                    |
| 5    | A service did not answer. Nothing was sent.                                | Safe                                       |
| 6    | A signed instruction may be on chain, or may still land                    | **Wait for the deadline, then read state** |

After exit 6, the first signed instruction can still land until its deadline. Anyone who holds its bytes can deliver it, the relay included. Find that time in this order:

- `error.details.liveUntil` or `error.details.deadline`, when present.
- A wallet-signed instruction (withdraw, give up a claim, grant or revoke a key): `mog pending show <id>` prints its deadline. The id is `error.details.pending`.
- A trading instruction signed by the CLI's session key: 5 minutes after the CLI signed it. The CLI signs a few seconds after the command starts, so wait at least 6 minutes from the start.

Do not sign a new instruction for the same decision before then. After it, run `mog orders` or `mog positions`, and sign again only if the first instruction did not apply. A second signature is a second instruction, so an early retry can open a second position.

## Relay refusals

`POST /submit` answers a refusal with a JSON body: `error`, `code`, and `preBroadcast`. `preBroadcast: true` means this request sent nothing. An earlier delivery of the same signed bytes may still be on its way, so treat it like exit 6 when you sent those bytes before. Some refusals add `index`, the failing instruction, and `retryAfterMs`.

### Fix the request

| Code                                             | HTTP | Meaning                                                                                  |
| ------------------------------------------------ | ---- | ---------------------------------------------------------------------------------------- |
| `ORIGIN_NOT_ALLOWED`                             | 403  | A browser request from a site the relay does not serve. Send from your server instead.   |
| `BAD_BODY`, `BAD_JSON`, `BAD_INTENT`             | 400  | The body is not `{ "intents": [ … ] }`                                                   |
| `TOO_MANY_INTENTS`                               | 400  | Too many instructions in one request                                                     |
| `BODY_TOO_LARGE`                                 | 413  | The body is too large                                                                    |
| `BAD_TARGET`, `WRONG_TARGET`, `UNKNOWN_SELECTOR` | 400  | The instruction is not a signed entry point of that contract                             |
| `BAD_CALLDATA`                                   | 400  | The call data is malformed                                                               |
| `BAD_SIGNATURE`                                  | 400  | The signature is malformed                                                               |
| `MIXED_TARGETS`, `SINGLE_NOT_BATCHABLE`          | 400  | Trading instructions batch together. Key and withdrawal instructions go one per request. |
| `FORM_RETIRED`                                   | 400  | The instruction uses an old signed format. Sign it again with the current one.           |
| `EXPIRED`                                        | 400  | The signed deadline is behind the chain clock. Sign again.                               |

### The instruction cannot apply

| Code                    | HTTP | Meaning                                                                                                                                                                                                                       |
| ----------------------- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NOT_AUTHORIZED`        | 403  | The signer is not the account or a live session key of it. With `retryAfterMs`, the relay has not seen the key yet: a key registered seconds ago needs one more moment. Send the same instruction again after `retryAfterMs`. |
| `NONCE_USED`            | 409  | This signed instruction already applied, or its nonce was spent                                                                                                                                                               |
| `INTENT_WOULD_FAIL`     | 400  | A dry run on the chain failed. `revert` names the reason.                                                                                                                                                                     |
| `BELOW_SPONSORED_MIN`   | 402  | Below the smallest amount the relay pays gas for. An order: raise the margin, or send it yourself. A withdrawal or a claim give-up: take the whole balance or claim, or send it yourself.                                     |
| `UNFUNDED`              | 402  | The relay grants session keys only to accounts with a funded balance                                                                                                                                                          |
| `TOP_UP_NOT_ACCEPTED`   | 409  | The market's prices are behind. Send the same instruction again later.                                                                                                                                                        |
| `RENOUNCE_NOT_ACCEPTED` | 409  | The delivery's work budget left cash waiting to be paid out. Send the same signed instruction again with a larger budget (`--max-steps` in the CLI), or later.                                                                |

### Wait, then send the same instruction

| Code                                     | HTTP | Meaning                                                                                                                                                                                                                                                                                                                                                            |
| ---------------------------------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `RATE_LIMITED`                           | 429  | A request window is spent. `window` names which: your address (each instruction in a batch counts), your signer, or all callers.                                                                                                                                                                                                                                   |
| `ROOT_BUDGET_SPENT`                      | 429  | The account has used the relay's daily network-fee budget. Send it yourself, or wait for `retryAfterMs`.                                                                                                                                                                                                                                                           |
| `RETRY_CAP_SPENT`                        | 429  | The relay delivered this signed instruction its daily maximum of times                                                                                                                                                                                                                                                                                             |
| `INTENT_IN_FLIGHT`                       | 429  | An instruction in the request is part of a delivery the relay has sent and not yet confirmed. Do not send it again: wait for that delivery, then read state. The message says "wait for that transaction". If the message says "did not reach the node; send it again", the earlier delivery failed, and you can send the same request again after `retryAfterMs`. |
| `GAS_ABOVE_CEILING`                      | 503  | The network fee is above the relay's ceiling                                                                                                                                                                                                                                                                                                                       |
| `BUSY`                                   | 503  | The relay is at capacity                                                                                                                                                                                                                                                                                                                                           |
| `CHAIN_UNREACHABLE`, `CHAIN_READ_FAILED` | 503  | The chain did not answer. The relay sent nothing.                                                                                                                                                                                                                                                                                                                  |

### Unknown outcome

| Code          | HTTP | Meaning                                                                                                                                                                                   |
| ------------- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SEND_FAILED` | 502  | With `preBroadcast: true`, the relay sent nothing. With `preBroadcast: null`, the network may hold the transaction: treat it like exit 6 and wait for the deadline before you sign again. |

A signed instruction can apply only once. Sending the same signed bytes again never applies it twice. Signing a new instruction for the same order can.
