DocumentationπŸ“‘ API Reference⚠️ Error Codes

Error Codes

All errors follow the same JSON structure:

{
  "error": "Human-readable message",
  "code": "MACHINE_READABLE_CODE",
  "message": "Human-readable message",
  "details": {},
  "requestId": "req_abc123"
}

HTTP status codes are used semantically (400, 401, 403, 429, 500).


Error code reference

CodeHTTPDescription
INVALID_METHOD400Request method is invalid
INVALID_PARAMETER400A required parameter is missing or invalid
INVALID_AGENT400The agent code does not exist or is invalid
INVALID_AGENT_ROLE403The agent does not have the required role
BLOCKED_AGENT403The agent account is blocked
INVALID_USER400The user does not exist
MAX_DEMO_USER400Exceeded max demo users limit (500)
INSUFFICIENT_AGENT_FUNDS400Agent balance is not sufficient
INSUFFICIENT_USER_FUNDS400User balance is not sufficient
DUPLICATED_USER409A user with this code already exists
INVALID_PROVIDER400The game provider is invalid or not supported
INTERNAL_ERROR500Unexpected internal server error
EXTERNAL_ERROR502Error from an upstream provider
API_CHECKING503API is temporarily in maintenance mode
AGENT_SEAMLESS400Seamless integration error from the agent side

Auth errors

CodeHTTPDescription
INVALID_SIGNATURE401Solana signature verification failed
EXPIRED_TOKEN401Bearer token has expired (re-authenticate)
MISSING_AUTH401No Authorization header provided
ADMIN_FORBIDDEN403Wallet does not have the required permission

Rate limit errors

CodeHTTPDescription
RATE_LIMITED429Too many requests; retry after the Retry-After header value

Handling errors

const res = await fetch('/casino/play', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${token}`,
  },
  body: JSON.stringify({ gameType: 'slots', wager: 1000, token: mintAddress }),
})
 
if (!res.ok) {
  const err = await res.json()
  console.error(`[${err.code}] ${err.message}`)
 
  if (err.code === 'EXPIRED_TOKEN') {
    // Re-authenticate
  } else if (err.code === 'INSUFFICIENT_USER_FUNDS') {
    // Show "not enough balance" UI
  }
}