Error Codes

Paybin API uses a comprehensive error code system to provide clear and actionable error messages. Understanding these error codes is essential for building robust applications that can handle various failure scenarios gracefully.

Error Response Format

All Paybin API errors follow a consistent response format:

{
  "apiVersion": "1.0.0.0",
  "data": null,
  "code": 400,
  "message": "Z200"
}
FieldTypeDescription
apiVersionstringThe API version being used
dataobject/nullAlways null for error responses
codeintegerHTTP status code
messagestringUnique error code for specific error type

General Errors

These are the most common error codes that can occur across all API endpoints.

Error CodeHTTP StatusDescriptionSolution
Z100500An error was occurredCheck request parameters and try again
Z200400Invalid credentialsVerify your API keys are correct
Z202400Invalid TFA CodeCheck your two-factor authentication code
Z204400The finger print is not sameVerify your request signature/hash
Z206403Your account is blocked. Please contact your administratorContact support to unblock your account
Z300400You requested with invalid symbol. Please check your request parametersVerify the cryptocurrency symbol is supported
Z400400Blockchain network error. Please contact your administratorContact support for network issues
Z500400You do not have any wallet yet. Please contact your administratorContact support to set up your wallet
Z600400You requested with invalid parameters. Please check your request parametersReview and correct your request parameters
Z700400Please verify you are not robotComplete the captcha verification
Z800400Invalid body hashVerify your hash generation logic
Z900401The token is expiredRefresh your authentication token

Authentication Errors

These errors occur when there are issues with API authentication or authorization.

Error CodeHTTP StatusDescriptionSolution
Z200400Invalid credentialsCheck your secret key and ensure it's correct
Z202400Invalid TFA CodeVerify your two-factor authentication code
Z204400The finger print is not sameVerify your request signature/hash
Z206403Your account is blockedContact support to unblock your account
Z800400Invalid body hashCheck your hash generation algorithm
Z900401The token is expiredRefresh your authentication token

Example Authentication Error Handling

async function handleAuthError(error) {
  const errorCode = error.response?.data?.message;
  
  switch (errorCode) {
    case 'Z200':
      console.error('Authentication failed. Please check your API keys.');
      return { type: 'auth', action: 'update_keys' };
      
    case 'Z202':
      console.error('Invalid TFA code. Please check your authenticator app.');
      return { type: 'auth', action: 'check_tfa' };
      
    case 'Z204':
      console.error('Request signature verification failed.');
      return { type: 'auth', action: 'check_signature' };
      
    case 'Z206':
      console.error('Account blocked. Please contact support.');
      return { type: 'auth', action: 'contact_support' };
      
    case 'Z800':
      console.error('Invalid request hash. Please verify your hash generation.');
      return { type: 'auth', action: 'check_hash' };
      
    case 'Z900':
      console.error('Token expired. Please refresh your authentication.');
      return { type: 'auth', action: 'refresh_token' };
      
    default:
      return { type: 'auth', action: 'contact_support' };
  }
}

Validation Errors

These errors occur when request parameters are invalid or missing.

Error CodeHTTP StatusDescriptionSolution
Z300400You requested with invalid symbol. Please check your request parametersCheck the cryptocurrency symbol is supported
Z400400Blockchain network error. Please contact your administratorVerify the network ID is supported for the symbol
Z600400You requested with invalid parameters. Please check your request parametersReview and correct your request parameters
Z700400Please verify you are not robotComplete the captcha verification

Example Validation Error Handling

function validateWithdrawRequest(data) {
  const errors = [];
  
  if (!data.symbol || !['BTC', 'ETH', 'LTC', 'USDT', 'USDC', 'BNB', 'TRX'].includes(data.symbol)) {
    errors.push({ code: 'Z300', field: 'symbol', message: 'Invalid cryptocurrency symbol' });
  }
  
  if (!data.amount || data.amount <= 0) {
    errors.push({ code: 'Z600', field: 'amount', message: 'Amount must be positive' });
  }
  
  if (!data.address || !isValidAddress(data.address, data.symbol)) {
    errors.push({ code: 'Z600', field: 'address', message: 'Invalid address format' });
  }
  
  return errors;
}

Withdrawal Errors

These errors are specific to withdrawal operations and provide detailed information about withdrawal-related issues.

Error CodeHTTP StatusDescriptionSolution
Z501400This withdraw is executed. Check you parametersWithdrawal already processed, check your parameters
Z502400This reference id has wallet for related symbol and networkReference ID already exists for this symbol/network
Z503400This reference id has wallet for related symbol and networkReference ID already exists for this symbol/network
Z504400This reference id has wallet for related symbol and networkReference ID already exists for this symbol/network
Z505400Invalid RequestCheck your withdrawal request parameters
Z507400Insufficient withdraw amountEnsure withdrawal amount meets minimum requirements
Z509200Please check your email to approve your withdrawCheck your email for withdrawal approval
Z511400Invalid addressVerify the withdrawal address format
Z513400Insufficient balanceEnsure sufficient balance for the withdrawal
Z514400Insufficient balance for feeEnsure sufficient balance to cover withdrawal fees
Z515400Invalid withdraw update requestCheck your withdrawal update parameters
Z517404Withdraw not foundVerify the withdrawal reference ID exists
Z519400Duplicate withdraw requestUse a unique reference ID for each withdrawal
Z521400Invalid credentialsCheck your API keys
Z523400Invalid body hashVerify your hash generation
Z525400You requested with invalid symbol. Please check your request parametersVerify the cryptocurrency symbol
Z527400Invalid authorized user for withdrawContact support for withdrawal permissions
Z529200Please check your phone to approve your withdrawCheck your phone for SMS verification
Z531400Please check your phone to approve your withdrawVerify your SMS OTP code
Z533400Invalid credentialsCheck your IP whitelist settings
Z535400Invalid amount for withdraw confirmationVerify the confirmation amount matches
Z537200You can approve this transfer on Back OfficeComplete withdrawal approval in back office
Z539400You can approve this transfer on Back OfficeWithdrawal already processed
Z540400The member reached the address limitReduce number of active withdrawal addresses

Example Withdrawal Error Handling

async function handleWithdrawalError(error) {
  const errorCode = error.response?.data?.message;
  
  switch (errorCode) {
    case 'Z501':
    case 'Z539':
      console.error('Withdrawal already executed');
      return { type: 'withdrawal', action: 'check_status', retry: false };
      
    case 'Z502':
    case 'Z503':
    case 'Z504':
      console.error('Reference ID already exists');
      return { type: 'withdrawal', action: 'use_new_reference', retry: false };
      
    case 'Z507':
      console.error('Insufficient withdrawal amount');
      return { type: 'withdrawal', action: 'increase_amount', retry: false };
      
    case 'Z509':
      console.log('Check email for withdrawal approval');
      return { type: 'withdrawal', action: 'check_email', retry: false };
      
    case 'Z511':
      console.error('Invalid withdrawal address');
      return { type: 'withdrawal', action: 'verify_address', retry: false };
      
    case 'Z513':
    case 'Z514':
      console.error('Insufficient balance');
      return { type: 'withdrawal', action: 'check_balance', retry: false };
      
    case 'Z517':
      console.error('Withdrawal not found');
      return { type: 'withdrawal', action: 'check_reference', retry: false };
      
    case 'Z519':
      console.error('Duplicate withdrawal request');
      return { type: 'withdrawal', action: 'use_unique_reference', retry: false };
      
    case 'Z525':
      console.error('Invalid cryptocurrency symbol');
      return { type: 'withdrawal', action: 'check_symbol', retry: false };
      
    case 'Z529':
      console.log('Check phone for SMS verification');
      return { type: 'withdrawal', action: 'check_sms', retry: false };
      
    case 'Z531':
      console.error('Invalid SMS OTP');
      return { type: 'withdrawal', action: 'verify_sms', retry: false };
      
    case 'Z533':
      console.error('IP not whitelisted');
      return { type: 'withdrawal', action: 'whitelist_ip', retry: false };
      
    case 'Z535':
      console.error('Invalid confirmation amount');
      return { type: 'withdrawal', action: 'check_amount', retry: false };
      
    case 'Z537':
      console.log('Complete approval in back office');
      return { type: 'withdrawal', action: 'back_office_approval', retry: false };
      
    case 'Z540':
      console.error('Address limit reached');
      return { type: 'withdrawal', action: 'reduce_addresses', retry: false };
      
    default:
      return { type: 'withdrawal', action: 'contact_support', retry: false };
  }
}

Error Handling Best Practices

🔄 Retry Strategy

Implement a robust retry strategy for transient errors:

async function apiCallWithRetry(apiFunction, maxRetries = 3) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await apiFunction();
    } catch (error) {
      const errorCode = error.response?.data?.message;
      
      // Don't retry on client errors (4xx) except for specific cases
      if (error.response?.status >= 400 && error.response?.status < 500) {
        // Only retry on specific error codes
        if (!['Z100', 'Z509', 'Z529', 'Z537'].includes(errorCode)) {
          throw error;
        }
      }
      
      if (attempt === maxRetries) {
        throw error;
      }
      
      // Exponential backoff
      const delay = Math.pow(2, attempt) * 1000;
      await new Promise(resolve => setTimeout(resolve, delay));
    }
  }
}

📊 Error Logging

Implement comprehensive error logging:

class ErrorLogger {
  logError(error, context = {}) {
    const errorInfo = {
      timestamp: new Date().toISOString(),
      errorCode: error.response?.data?.message,
      httpStatus: error.response?.status,
      url: error.config?.url,
      method: error.config?.method,
      requestData: error.config?.data,
      context: context,
      stack: error.stack
    };
    
    // Log to your monitoring system
    console.error('Paybin API Error:', errorInfo);
    
    // Send to monitoring service (e.g., Sentry, LogRocket)
    if (this.monitoringService) {
      this.monitoringService.captureException(error, errorInfo);
    }
  }
}

🛡️ User-Friendly Messages

Provide user-friendly error messages:

const errorMessages = {
  'Z100': 'An unexpected error occurred. Please try again.',
  'Z200': 'Authentication failed. Please check your API configuration.',
  'Z202': 'Invalid two-factor authentication code.',
  'Z204': 'Request verification failed. Please check your signature.',
  'Z206': 'Your account is blocked. Please contact support.',
  'Z300': 'Invalid cryptocurrency symbol. Please check supported currencies.',
  'Z400': 'Blockchain network error. Please contact support.',
  'Z500': 'Wallet not found. Please contact support to set up your wallet.',
  'Z600': 'Invalid request parameters. Please check your input.',
  'Z700': 'Please complete the captcha verification.',
  'Z800': 'Request verification failed. Please check your hash.',
  'Z900': 'Authentication token expired. Please refresh your token.',
  'Z501': 'Withdrawal already processed.',
  'Z502': 'Reference ID already exists for this currency.',
  'Z503': 'Reference ID already exists for this currency.',
  'Z504': 'Reference ID already exists for this currency.',
  'Z505': 'Invalid withdrawal request.',
  'Z507': 'Withdrawal amount is too small.',
  'Z509': 'Please check your email for withdrawal approval.',
  'Z511': 'Invalid withdrawal address format.',
  'Z513': 'Insufficient balance for withdrawal.',
  'Z514': 'Insufficient balance to cover withdrawal fees.',
  'Z515': 'Invalid withdrawal update request.',
  'Z517': 'Withdrawal not found.',
  'Z519': 'Duplicate withdrawal request. Please use a unique reference ID.',
  'Z521': 'Invalid credentials for withdrawal.',
  'Z523': 'Request verification failed for withdrawal.',
  'Z525': 'Invalid cryptocurrency symbol for withdrawal.',
  'Z527': 'Unauthorized for withdrawal. Please contact support.',
  'Z529': 'Please check your phone for SMS verification.',
  'Z531': 'Invalid SMS verification code.',
  'Z533': 'IP address not whitelisted for withdrawal.',
  'Z535': 'Invalid confirmation amount.',
  'Z537': 'Please complete withdrawal approval in back office.',
  'Z539': 'Withdrawal already processed.',
  'Z540': 'Maximum withdrawal addresses reached.',
  'default': 'An unexpected error occurred. Please try again.'
};

function getUserFriendlyMessage(errorCode) {
  return errorMessages[errorCode] || errorMessages.default;
}

🔍 Error Monitoring

Set up error monitoring and alerting:

class ErrorMonitor {
  constructor() {
    this.errorCounts = new Map();
    this.alertThreshold = 10; // Alert after 10 errors
  }
  
  trackError(errorCode) {
    const count = this.errorCounts.get(errorCode) || 0;
    this.errorCounts.set(errorCode, count + 1);
    
    if (count + 1 >= this.alertThreshold) {
      this.sendAlert(errorCode, count + 1);
    }
  }
  
  sendAlert(errorCode, count) {
    console.warn(`High error rate detected: ${errorCode} (${count} occurrences)`);
    // Send alert to your monitoring system
  }
}

📱 Client-Side Error Handling

Implement client-side error handling for web applications:

// React example
function useApiError() {
  const [error, setError] = useState(null);
  
  const handleApiError = useCallback((error) => {
    const errorCode = error.response?.data?.message;
    const userMessage = getUserFriendlyMessage(errorCode);
    
    setError({
      code: errorCode,
      message: userMessage,
      timestamp: new Date()
    });
    
    // Auto-clear error after 5 seconds
    setTimeout(() => setError(null), 5000);
  }, []);
  
  return { error, handleApiError, clearError: () => setError(null) };
}

🧪 Testing Error Scenarios

Test your error handling:

// Jest test example
describe('Paybin API Error Handling', () => {
  test('should handle authentication errors', async () => {
    const mockError = {
      response: {
        data: { message: 'Z200' },
        status: 400
      }
    };
    
    const result = await handleAuthError(mockError);
    expect(result.type).toBe('auth');
    expect(result.action).toBe('update_keys');
  });
  
  test('should handle withdrawal errors', async () => {
    const mockError = {
      response: {
        data: { message: 'Z513' },
        status: 400
      }
    };
    
    const result = await handleWithdrawalError(mockError);
    expect(result.type).toBe('withdrawal');
    expect(result.action).toBe('check_balance');
  });
});

Was this page helpful?