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"
}
Field | Type | Description |
---|---|---|
apiVersion | string | The API version being used |
data | object/null | Always null for error responses |
code | integer | HTTP status code |
message | string | Unique error code for specific error type |
Paybin uses unique error codes (like Z200) instead of generic HTTP status messages to enable better internationalization and more precise error handling.
General Errors
These are the most common error codes that can occur across all API endpoints.
Error Code | HTTP Status | Description | Solution |
---|---|---|---|
Z100 | 500 | An error was occurred | Check request parameters and try again |
Z200 | 400 | Invalid credentials | Verify your API keys are correct |
Z202 | 400 | Invalid TFA Code | Check your two-factor authentication code |
Z204 | 400 | The finger print is not same | Verify your request signature/hash |
Z206 | 403 | Your account is blocked. Please contact your administrator | Contact support to unblock your account |
Z300 | 400 | You requested with invalid symbol. Please check your request parameters | Verify the cryptocurrency symbol is supported |
Z400 | 400 | Blockchain network error. Please contact your administrator | Contact support for network issues |
Z500 | 400 | You do not have any wallet yet. Please contact your administrator | Contact support to set up your wallet |
Z600 | 400 | You requested with invalid parameters. Please check your request parameters | Review and correct your request parameters |
Z700 | 400 | Please verify you are not robot | Complete the captcha verification |
Z800 | 400 | Invalid body hash | Verify your hash generation logic |
Z900 | 401 | The token is expired | Refresh your authentication token |
Authentication Errors
These errors occur when there are issues with API authentication or authorization.
Error Code | HTTP Status | Description | Solution |
---|---|---|---|
Z200 | 400 | Invalid credentials | Check your secret key and ensure it's correct |
Z202 | 400 | Invalid TFA Code | Verify your two-factor authentication code |
Z204 | 400 | The finger print is not same | Verify your request signature/hash |
Z206 | 403 | Your account is blocked | Contact support to unblock your account |
Z800 | 400 | Invalid body hash | Check your hash generation algorithm |
Z900 | 401 | The token is expired | Refresh 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 Code | HTTP Status | Description | Solution |
---|---|---|---|
Z300 | 400 | You requested with invalid symbol. Please check your request parameters | Check the cryptocurrency symbol is supported |
Z400 | 400 | Blockchain network error. Please contact your administrator | Verify the network ID is supported for the symbol |
Z600 | 400 | You requested with invalid parameters. Please check your request parameters | Review and correct your request parameters |
Z700 | 400 | Please verify you are not robot | Complete 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 Code | HTTP Status | Description | Solution |
---|---|---|---|
Z501 | 400 | This withdraw is executed. Check you parameters | Withdrawal already processed, check your parameters |
Z502 | 400 | This reference id has wallet for related symbol and network | Reference ID already exists for this symbol/network |
Z503 | 400 | This reference id has wallet for related symbol and network | Reference ID already exists for this symbol/network |
Z504 | 400 | This reference id has wallet for related symbol and network | Reference ID already exists for this symbol/network |
Z505 | 400 | Invalid Request | Check your withdrawal request parameters |
Z507 | 400 | Insufficient withdraw amount | Ensure withdrawal amount meets minimum requirements |
Z509 | 200 | Please check your email to approve your withdraw | Check your email for withdrawal approval |
Z511 | 400 | Invalid address | Verify the withdrawal address format |
Z513 | 400 | Insufficient balance | Ensure sufficient balance for the withdrawal |
Z514 | 400 | Insufficient balance for fee | Ensure sufficient balance to cover withdrawal fees |
Z515 | 400 | Invalid withdraw update request | Check your withdrawal update parameters |
Z517 | 404 | Withdraw not found | Verify the withdrawal reference ID exists |
Z519 | 400 | Duplicate withdraw request | Use a unique reference ID for each withdrawal |
Z521 | 400 | Invalid credentials | Check your API keys |
Z523 | 400 | Invalid body hash | Verify your hash generation |
Z525 | 400 | You requested with invalid symbol. Please check your request parameters | Verify the cryptocurrency symbol |
Z527 | 400 | Invalid authorized user for withdraw | Contact support for withdrawal permissions |
Z529 | 200 | Please check your phone to approve your withdraw | Check your phone for SMS verification |
Z531 | 400 | Please check your phone to approve your withdraw | Verify your SMS OTP code |
Z533 | 400 | Invalid credentials | Check your IP whitelist settings |
Z535 | 400 | Invalid amount for withdraw confirmation | Verify the confirmation amount matches |
Z537 | 200 | You can approve this transfer on Back Office | Complete withdrawal approval in back office |
Z539 | 400 | You can approve this transfer on Back Office | Withdrawal already processed |
Z540 | 400 | The member reached the address limit | Reduce 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');
});
});
Always implement proper error handling to ensure your application remains stable and provides a good user experience even when API calls fail.