Skip to main content

Error Response Format

All API errors follow a unified response format:
{
  "code": 40001,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Human readable error message",
  "details": {
    // Optional additional information
  }
}

HTTP Status Codes

StatusDescriptionError Code Range
400Bad Request400, 40001-40040
401Unauthorized401
403Forbidden403, 40301
404Not Found404, 40401-40406
429Too Many Requests429, 42901-42902
500Internal Server Error500, 50001-50036
510Red Packet Error51000-51004
520Webhook Error52000-52001

Client Errors (400)

Parameter Validation Errors

CodeNameDescriptionSolution
400BAD_REQUESTBad requestCheck request format
40001VALIDATION_ERRORRequest parameters are abnormal or incorrectCheck parameter format and values
40002INVALID_PARAMETERInvalid parameterCheck if parameter value meets requirements
40003INVALID_TOKENInvalid access tokenCheck token format
40004MISSING_PARAMETERMissing required parameterAdd missing required parameters
40005INVALID_ADDRESSInvalid wallet address formatCheck address format
40027INVALID_CURSORInvalid cursorUse valid pagination cursor
40031INVALID_TIMESTAMPInvalid timestamp formatUse ISO 8601 format
40032INVALID_RESOLUTIONInvalid resolution parameterUse supported K-line periods
40033INVALID_NUMBER_FORMATInvalid number formatUse correct number format
{
  "code": 40002,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Invalid parameter",
  "details": {
    "parameter": "resolution",
    "value": "2h",
    "allowed_values": ["1s", "1m", "5m", "15m", "1h", "4h", "1d"]
  }
}
CodeNameDescriptionSolution
40009INVALID_TOKEN_ADDRESSInvalid token addressCheck token contract address
40028TOKEN_ADDRESSES_LIMIT_EXCEEDEDToken addresses limit exceededMaximum 100 addresses
40034TOKEN_ALREADY_CREATEDToken already createdCheck for duplicate creation
CodeNameDescriptionSolution
40029WALLET_ADDRESSES_LIMIT_EXCEEDEDWallet addresses limit exceededMaximum 100 addresses
CodeNameDescriptionSolution
40010TRANSACTION_FAILEDTransaction execution failedCheck parameters and balance
40011TRANSACTION_REJECTEDTransaction rejectedCheck signature and permissions
40012INVALID_TRANSACTIONInvalid transactionCheck transaction structure
40025TRANSACTION_NOT_SIGNEDTransaction not signedSign before serialization
40026TRANSACTION_SIGNATURE_MISSINGTransaction signature missingAdd transaction signature
40039TRANSACTION_SIZE_EXCEEDEDTransaction size exceededReduce transaction complexity

DEX Trading Errors

CodeNameDescriptionSolution
40006LIQUIDITY_INSUFFICIENTInsufficient liquidityReduce trade amount
40007PRICE_IMPACT_TOO_HIGHPrice impact too highReduce amount or increase slippage
40008SLIPPAGE_TOO_HIGHSlippage too highAdjust slippage settings
40014INVALID_AMOUNTInvalid amountUse valid number
40015AMOUNT_TOO_SMALLAmount too smallIncrease trade amount
40016AMOUNT_TOO_LARGEAmount too largeAmount exceeds safe range
40017SAME_TOKEN_SWAPSame token swapInput and output cannot be same
40018INVALID_SLIPPAGEInvalid slippage valueUse valid slippage value
40019SLIPPAGE_TOO_LOWSlippage too lowSlippage must be greater than zero
40020POOL_NOT_SUPPORTEDPool not supportedUse supported pool
40021UNSUPPORTED_SWAP_MODESwap mode not supportedUse supported swap mode
40022FEE_PARAMETER_ERRORInvalid fee parameterCheck fee configuration
40023ANTI_MEV_REJECTEDAnti-MEV validation failedCheck Anti-MEV settings
40030POOL_INPUT_MISMATCHPool input mismatchInput token doesn’t match pool
{
  "code": 40006,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Insufficient liquidity",
  "details": {
    "requested_amount": "1000000000",
    "available_liquidity": "500000000"
  }
}
CodeNameDescriptionSolution
40035INVALID_MARKET_PRICESInvalid market pricesCheck price parameters
40036INVALID_ORDER_PARAMETERSInvalid order parametersCheck order configuration

Other Client Errors

CodeNameDescriptionSolution
40013PARAMETER_ERRORParameter errorMust set total or fixed amount
40024NOT_IMPLEMENTEDMethod not implementedUse implemented methods
40037UNSUPPORTED_VALUE_TYPEValue type not supportedUse supported value types
40038PARSE_ERRORParse failedCheck data format
40040INVALID_MIGRATE_TYPEInvalid migration typeUse valid migration type

Authentication Errors (401)

CodeNameDescriptionSolution
401UNAUTHORIZEDUnauthorized. Token is missing or invalidCheck Authorization header
{
  "code": 401,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Unauthorized. Token is missing or invalid"
}
Handling Example:
if (error.code === 401) {
  // Refresh token
  const newToken = await getAccessToken();
  // Retry request with new token
}

Permission Errors (403)

CodeNameDescriptionSolution
403FORBIDDENForbiddenSee details below
40301INSUFFICIENT_PERMISSIONSInsufficient permissionsObtain required permissions
403 errors can be triggered by:
  • Quota exhausted: Monthly API call quota depleted, upgrade plan or wait for next month reset
  • Blacklisted: IP or account has been blacklisted
  • Not whitelisted: Request origin not in allowed whitelist
When API quota is exhausted, the gateway returns 403 directly. This differs from 429 (rate limit):
  • 429: Short-term rate limiting (requests per second/minute exceeded)
  • 403: Account quota limit (monthly usage exhausted) or permission issues
{
  "code": 403,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Forbidden"
}
{
  "code": 40301,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Insufficient permissions",
  "details": {
    "required_scope": "kyt.write",
    "current_scopes": ["kyt.read"]
  }
}

Resource Not Found Errors (404)

CodeNameDescriptionSolution
404NOT_FOUNDResource not foundCheck if resource exists
40401POOL_NOT_FOUNDLiquidity pool not foundCheck pool address and chain
40402MARKET_INFO_NOT_FOUNDMarket info not foundCheck if market exists
40403OPEN_ORDER_NOT_FOUNDOpen order account not foundCheck order account
40404ORDER_NOT_FOUNDOrder not foundCheck order ID
40405CHAIN_NOT_FOUNDChain not foundUse supported chain identifier
40406DEX_NOT_FOUNDDEX not foundUse supported DEX
{
  "code": 40401,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Liquidity pool not found",
  "details": {
    "chain": "sol",
    "pool_address": "INVALID_ADDRESS"
  }
}

Rate Limit Errors (429)

CodeNameDescriptionSolution
429RATE_LIMITToo many requests. Rate limit reachedWait and retry
42901API_USAGE_LIMIT_EXCEEDEDAPI usage limit exceededUpgrade plan or wait for reset
42902KYT_USAGE_LIMIT_EXCEEDEDKYT API usage limit exceededUpgrade KYT plan
{
  "code": 429,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Too Many Requests. Rate limit reached",
  "details": {
    "limit": 100,
    "remaining": 0,
    "reset_at": 1706745600
  }
}
Handling Example:
if (response.status === 429) {
  const retryAfter = response.headers.get('Retry-After') || 1;
  await sleep(retryAfter * 1000);
  // Retry request
}

Server Errors (500)

General Server Errors

CodeNameDescriptionSolution
500INTERNAL_SERVER_ERRORInternal server errorRetry later
50001UNKNOWN_ERRORUnknown errorContact support
50005DATABASE_ERRORData operation failedRetry later
50007EXTERNAL_SERVICE_ERRORExternal service call failedRetry later
50029EXTERNAL_API_ERRORExternal API request failedRetry later
CodeNameDescriptionSolution
50002CHAIN_CONNECTION_ERRORBlockchain connection errorCheck network status
50003CHAIN_SYNC_ERRORBlockchain synchronization errorWait for sync completion
50004TRANSACTION_TIMEOUTTransaction timeoutRetry or increase timeout
50006TRANSACTION_ERRORTransaction errorCheck transaction parameters
50008CHAIN_NOT_SUPPORTEDChain not supportedUse supported chain
50017INSUFFICIENT_BALANCEInsufficient balanceCheck account balance
50026TRANSACTION_SEND_FAILEDTransaction send failedCheck network and parameters
50027TRANSACTION_CONFIRMATION_FAILEDTransaction confirmation failedCheck transaction status
50028TRANSACTION_SIGNATURE_EMPTYTransaction signature is emptyAdd signature
CodeNameDescriptionSolution
50009DEX_NOT_SUPPORTEDDEX not supportedUse supported DEX
50010DEX_ROUTE_BUILD_FAILEDDEX route build failedCheck token pair liquidity
50011DEX_SWAP_BUILD_FAILEDDEX swap build failedCheck trade parameters
50012DEX_SWAP_SIMULATED_FAILEDDEX swap simulation failedAdjust trade parameters
50019DEX_AGGREGATOR_NOT_FOUNDDEX aggregator not foundContact support
50020DEX_BUILDER_NOT_FOUNDDEX builder not foundContact support
50033CURVE_CALCULATION_ERRORCurve calculation errorCheck parameters
50034LOOKUP_TABLE_ERRORAddress lookup table errorRetry later
50035SWAP_ROUTE_ERRORSwap route calculation errorCheck token pair

Jupiter API Errors

CodeNameDescriptionSolution
50013JUPITER_API_UNAUTHORIZEDJupiter API unauthorizedCheck API key
50014JUPITER_API_RATE_LIMITJupiter API rate limitRetry later
50015JUPITER_API_BAD_REQUESTJupiter API bad requestCheck parameters
50016JUPITER_API_ERRORJupiter API errorRetry later

Configuration and Initialization Errors

CodeNameDescriptionSolution
50018PROVIDER_NOT_INITIALIZEDProvider not initializedConfigure rpcUrl
50021ORDER_BUILDER_NOT_FOUNDOrder builder not foundContact support
50022MARKET_EXPIREDMarket has expiredUse valid market
50023CONFIG_NOT_FOUNDConfig not foundCheck configuration
50030FEE_CONFIGURATION_REQUIREDFee configuration requiredConfigure fee
50036METAFIELD_NOT_FOUNDMetafield not foundCheck metadata

File Upload Errors

CodeNameDescriptionSolution
50024IPFS_UPLOAD_FAILEDIPFS upload failedRetry later
50025SIGNED_URL_FAILEDSigned URL creation failedRetry later

Bundle Processing Errors

CodeNameDescriptionSolution
50031BUNDLE_PROCESSING_FAILEDBundle processing failedCheck bundle configuration
50032TIP_ACCOUNTS_NOT_AVAILABLETip accounts not availableRetry later
{
  "code": 50010,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "DEX route build failed",
  "details": {
    "input_token": "So11111111111111111111111111111111111111112",
    "output_token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "reason": "No valid route found"
  }
}

Red Packet Errors (510)

CodeNameDescriptionSolution
51000RED_PACKET_INVALID_PARAMETER_ERRORRed packet parameter errorProvide red packet ID or share ID
51001RED_PACKET_NOT_FOUND_ERRORRed packet not foundCheck red packet ID
51002RED_PACKET_WITHDRAWN_ERRORRed packet withdrawnRed packet no longer available
51003RED_PACKET_ALREADY_CLAIMED_ERRORAlready claimed red packetEach user can claim once
51004RED_PACKET_TRANSACTION_ERRORRed packet transaction errorRetry later
{
  "code": 51003,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "You have already claimed this red packet"
}

Webhook Errors (520)

CodeNameDescriptionSolution
52000WEBHOOKS_APPLICATION_NOT_FOUNDWebhook application not foundCheck webhook ID
52001WEBHOOKS_ENDPOINT_LIMIT_REACHEDWebhook endpoint limit reachedDelete unused endpoints
{
  "code": 52001,
  "timestamp": "2026-02-05T10:30:00.000Z",
  "message": "Webhooks endpoint limit reached",
  "details": {
    "current_count": 10,
    "max_allowed": 10
  }
}

Error Handling Best Practices

import { ChainStreamClient } from '@chainstream-io/sdk';

const client = new ChainStreamClient(process.env.CHAINSTREAM_ACCESS_TOKEN);

async function safeApiCall(apiFunction) {
  try {
    return await apiFunction();
  } catch (error) {
    const { code, message, details } = error;
    
    // Handle errors by category
    if (code === 401) {
      // Authentication error: refresh token
      await refreshToken();
      return safeApiCall(apiFunction);
    }
    
    if (code === 429 || code === 42901 || code === 42902) {
      // Rate limit: wait and retry
      const retryAfter = details?.reset_at 
        ? (details.reset_at * 1000 - Date.now()) 
        : 1000;
      await sleep(retryAfter);
      return safeApiCall(apiFunction);
    }
    
    if (code >= 40000 && code < 41000) {
      // Client parameter error: log and throw
      console.error(`Parameter error: ${message}`, details);
      throw new ValidationError(message, details);
    }
    
    if (code >= 40400 && code < 40500) {
      // Resource not found
      console.warn(`Resource not found: ${message}`);
      return null;
    }
    
    if (code >= 50000) {
      // Server error: log and retry
      console.error(`Server error: ${message}`, details);
      await sleep(1000);
      return safeApiCall(apiFunction);
    }
    
    // Unknown error
    throw error;
  }
}

// Usage example
const tokenInfo = await safeApiCall(() => 
  client.token.getToken('sol', 'TOKEN_ADDRESS')
);

Getting Help

If you encounter unresolvable errors:
When reporting issues, please provide the complete error response (including code, timestamp, message, and details) so we can quickly identify the problem.