API Error Codes

This document provides a comprehensive guide to the error handling system used in the HIFI API. Understanding these error codes will help you effectively handle exceptions and communicate issues to your users.

Error Code Structure

Error codes follow a consistent format that provides information about the source and type of error:

SSCEESS

Where:

  • SS: Service identifier (2 digits)
  • C: Error category (2 digits)
  • EE: Error sequence (2 digits)

Example: Error code 100001 indicates a generic validation error (Service ID: 10, Category: 00, Sequence: 01).

Service Identifiers

Service IDDescription
10Generic Services
20Authentication
30User Management
40Transaction Processing
50Account Management
60Wallet Services
70System Infrastructure

Error Categories

Category IDDescription
00Validation Error
01Authentication Error
02Authorization Error
03Not Found Error
04Service Unavailable
05Inactive Resource

Error Response Format

All error responses follow a consistent JSON structure:

{
  "code": 100001,
  "error": "FIELD_VALIDATION_ERROR",
  "errorDetails": "Fields provided are either missing or invalid"
}

Error Code Reference

Generic Errors (10xxxx)

CodeErrorDescription
100001FIELD_VALIDATION_ERRORFields provided are either missing or invalid
100002METHOD_NOT_ALLOWEDMethod not allowed
100003INVALID_VERSIONInvalid version
100004DEPRECATED_RESOURCEThis resource has been deprecated
100005RESOURCE_CONFLICTResource conflict, please try different request id

Authentication Errors (20xxxx)

CodeErrorDescription
200301BILLING_CONFIG_NOT_FOUNDBilling configuration not found
200001INVALID_API_KEYInvalid API key
200201PRODUCTION_NOT_ENABLEDProduction is not enabled for this profile
200202USER_ROLE_NOT_ALLOWEDUser role not allowed to perform this action
200203UNAUTHORIZEDUnauthorized
200301KEY_DOES_NOT_EXISTKey does not exist
200204PROFILE_FROZENProfile is not authorized to access this resource

User Management Errors (30xxxx)

CodeErrorDescription
300301USER_NOT_FOUNDUser not found
300201USER_ACTION_NOT_ALLOWEDUser is not allowed to perform this action
300201USER_COMPLIANCE_VERIFICATION_FAILEDUser compliance information is not approved
300202USER_COMPLIANCE_DATA_INVALIDUser compliance data is invalid
300001USER_ALREADY_EXISTSUser already exists
300202USER_FROZENUser is not authorized to access this resource

Transaction Errors (40xxxx)

CodeErrorDescription
400401INSUFFICIENT_BALANCEInsufficient balance for transaction
400402INSUFFICIENT_CREDIT_BALANCEInsufficient credit balance for transaction fee
400001INVALID_TRANSACTION_ROUTEInvalid transaction route (combination of currency, crypto, and rail)
400403TRANSACTION_INITIATION_FAILEDTransaction initiation failed
400002INVALID_ACCOUNT_FOR_TRANSACTIONInvalid bank account for the transaction
400003TRANSACTION_REQUEST_ALREADY_EXISTSTransaction request already exists
400301TRANSACTION_NOT_FOUNDTransaction not found
400302QUOTE_NOT_FOUNDQuote not found
400005QUOTE_NOT_READYQuote is not ready yet
400006INVALID_QUOTEExpired or invalid quote

Account Management Errors (50xxxx)

CodeErrorDescription
500301ACCOUNT_NOT_FOUNDBank account ID not found
500501INACTIVE_ACCOUNTBank account is not active
500001INVALID_ACCOUNT_DATAInvalid bank account data provided

Wallet Management Errors (60xxxx)

CodeErrorDescription
600301WALLET_NOT_FOUNDWallet not found for the user
600001INVALID_WALLET_CONFIGInvalid wallet configuration provided
600001WALLET_ALREADY_EXISTSWallet already exists for this configuration
600501INACTIVE_WALLETWallet is not active

System/Infrastructure Errors (70xxxx)

CodeErrorDescription
700401INTERNAL_SERVER_ERRORInternal server error

Usage Example

JavaScript

try {
  // API call
} catch (error) {
  if (error.code === 300301) {
    // Handle USER_NOT_FOUND error
    console.log('User was not found in the system');
  } else if (error.code === 400401) {
    // Handle INSUFFICIENT_BALANCE error
    console.log('Transaction failed due to insufficient balance');
  }
}

HTTP Response Example

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "code": 400001,
  "error": "INVALID_TRANSACTION_ROUTE",
  "errorDetails": "Invalid transaction route with the provided transaction details"
}

© HiFi Bridge API. All rights reserved.