Skip to content

Error Handling

This guide covers error formats, common error types, and implementation patterns for the Synthetix API.

Error Response Format

All API errors follow a consistent JSON format:

{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "message": "Failed to list subaccounts",
    "details": { /* optional context */ }
  },
  "request_id": "5ccf215d37e3ae6d",
  "timestamp": "2025-01-01T00:00:00Z"
}

Example Error Response

{
  "status": "error",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Insufficient margin for trade",
    "details": {
      "requiredMargin": "1000.00",
      "availableMargin": "500.12"
    }
  },
  "request_id": "a1b2c3d4e5f67890",
  "timestamp": "2025-01-01T00:00:00.500Z"
}

HTTP Status Codes

Status CodeDescriptionCommon Causes
200SuccessRequest processed successfully
400Bad RequestInvalid request format, missing parameters
401UnauthorizedInvalid signature, authentication failed
403ForbiddenInsufficient permissions, account restricted
404Not FoundInvalid endpoint, resource not found
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer-side error
503Service UnavailableSystem maintenance, temporary outage

Common Error Types

Authentication Errors

Error MessageDescriptionSolution
Invalid signatureEIP-712 signature validation failedVerify signing implementation, check domain separator
Signature expiredRequest timestamp too oldEnsure system clock is synchronized
Invalid nonceNonce already used or invalidUse incrementing nonce, check nonce management
Unauthorized subaccount accessNo permission for subaccount tradingVerify delegation permissions for subaccount

Trading Errors

Error CodeDescriptionSolution
VALIDATION_ERRORNot enough collateral for orderAdd more collateral or reduce order size
NOT_FOUNDOrder ID doesn't existVerify order ID, check if already filled/cancelled
NOT_FOUNDInvalid market symbolCheck supported markets, verify symbol format
INVALID_VALUEUnsupported order type or parametersUse supported types: limit, market, trigger
VALIDATION_ERRORBelow minimum order sizeCheck market minimums
VALIDATION_ERRORExceeds maximum order sizeCheck position limits, split into smaller orders
VALIDATION_ERRORMaximum position size reachedReduce position or close existing
VALIDATION_ERRORPost-only order would take liquidityAdjust price or use different TIF
VALIDATION_ERRORReduce-only flag with wrong sideCheck position side, adjust order

Market Data Errors

Error MessageDescriptionSolution
Symbol not foundInvalid market symbolCheck available markets
Invalid timeframeUnsupported candle timeframeUse supported timeframes
Data not availableHistorical data not foundCheck date range, data availability

Rate Limit Errors

Error MessageDescriptionSolution
Rate limit exceededToo many requestsImplement backoff, reduce request rate
IP rate limit exceededIP-based limit hitDistribute requests, use multiple IPs
Address rate limit exceededWallet-based limit hitOptimize request patterns

Validation Errors

Error MessageDescriptionSolution
Invalid market symbolSymbol format incorrectUse format: "BTC-USDT"
Invalid price formatPrice not a valid stringSend prices as strings, not numbers
Invalid quantityQuantity format or value invalidSend as string, check decimals
Nonce already usedDuplicate nonceEnsure nonce always increases
Request expiredexpiresAfter timestamp passedUse longer expiration, check clock sync

Implementation Notes

The Synthetix API provides detailed error information to help identify and resolve issues:

  • Error codes follow a consistent taxonomy for easy classification
  • Error details include context-specific information when available
  • HTTP status codes map to specific error categories
  • Retry-After headers indicate when to retry rate-limited requests

WebSocket Error Handling

WebSocket connections use a different error format for responses:

{
  "id": "request-123",
  "status": 400,
  "error": {
    "code": 400,
    "message": "Invalid order parameters"
  }
}

WebSocket-specific error codes:

  • Connection errors result in WebSocket close codes
  • Authentication failures close the connection with code 1008
  • Protocol errors use code 1002