Error Codes

All errors follow a consistent format with machine-readable codes.

Error Format

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description",
    "violations": [...]  // Only for POLICY_DENIED
  }
}

MCP Errors

CodeHTTPDescription
POLICY_DENIED200Transaction violates one or more active policies. Includes violations array with policyId, policyType, and reason.
TX_EXECUTION_FAILED200On-chain transaction failed after policy approval (gas, revert, etc).
INSUFFICIENT_BALANCE200Agent wallet balance is less than the requested amount.
MCP_AUTH_MISSING401No Authorization header provided.
MCP_AUTH_INVALID401API key is invalid, revoked, or malformed.
MCP_SCOPE_DENIED403API key lacks the required scope (read/write) for this tool.
RATE_LIMITED429Too many requests. Check Retry-After header.
WALLET_FROZEN200The agent wallet has been frozen by the owner.

Note: Policy denials return HTTP 200 (not 403) so agents can read the structured error and react.

REST API Errors

CodeHTTPDescription
AUTH_INVALID_CREDENTIALS401Wrong email or password.
AUTH_EMAIL_EXISTS409Email already registered.
AUTH_TOKEN_EXPIRED401JWT has expired. Re-authenticate.
WALLET_NOT_FOUND404Agent wallet does not exist or belongs to another user.
INVALID_AMOUNT400Amount must be a positive number.
INSUFFICIENT_MASTER_BALANCE400Master wallet has insufficient funds for this transfer.
KEY_NOT_FOUND404API key does not exist or is already revoked.
POLICY_NOT_FOUND404Policy does not exist.
TX_NOT_FOUND404Transaction does not exist.
TX_NOT_PENDING400Transaction is not in pending state (already approved/rejected).
NOT_FOUND404Endpoint does not exist.
VALIDATION_ERROR400Request body failed Zod validation.

SDK Error Classes

The TypeScript SDK maps these codes to typed error classes:

ClassCodeExtra Fields
PolicyDeniedErrorPOLICY_DENIEDviolations: PolicyViolation[]
InsufficientBalanceErrorINSUFFICIENT_BALANCE
ExecutionFailedErrorTX_EXECUTION_FAILEDtxHash: string | null
AuthenticationErrorAUTH_ERROR
RateLimitErrorRATE_LIMITEDretryAfter: number
BithavenError(any)Base class for all errors