Response Codes
Understand our API response and error codes
Response Codes
Bridge Developer API uses a combination of HTTP status codes and custom response codes to provide detailed information about request outcomes.
HTTP Status Codes
| Code | Status | Description |
|---|---|---|
200 | OK | Request successful |
202 | Accepted | Request received and queued for processing |
400 | Bad Request | Invalid request parameters |
401 | Unauthorized | Authentication failed |
403 | Forbidden | Access denied |
404 | Not Found | Resource not found |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Server error |
Custom Response Codes
Success Codes
| Code | Description | Usage |
|---|---|---|
000 | Success | General success response |
202 | Request Accepted | Payment request received for processing |
370 | SMS Queued | SMS request received for processing |
Error Codes
| Code | Description | HTTP Status | Action Required |
|---|---|---|---|
100 | Not Allowed | 401 | Check authentication credentials |
400 | Bad Request | 400 | Validate request parameters |
401 | Unauthorized | 401 | Provide valid authentication |
402 | Insufficient Balance | 402 | Top up account balance |
403 | Forbidden | 403 | Check account permissions |
404 | Not Found | 404 | Verify resource exists |
429 | Rate Limited | 429 | Reduce request frequency |
500 | Server Error | 500 | Contact support |
Transaction Status Codes
| Code | Description | Meaning |
|---|---|---|
000 | Transaction Successful | Payment completed successfully |
001 | Transaction Failed | Payment failed |
002 | Transaction Pending | Payment still processing |
003 | Transaction Cancelled | Payment was cancelled |
Response Format
All API responses follow this consistent format:
Success Response
{
"response_data": {
// Endpoint-specific data (optional)
},
"response_message": "Success",
"response_code": "000"
}Error Response
{
"response_message": "Error description",
"response_code": "Error code"
}Common Error Scenarios
Authentication Errors
{
"response_message": "You are not allowed to use this service",
"response_code": "100"
}Solution: Verify your API credentials and ensure they're correctly encoded.
Invalid Parameters
{
"response_message": "Missing required parameter: service_id",
"response_code": "400"
}Solution: Check that all required parameters are included in your request.
Insufficient Balance
{
"response_message": "Insufficient balance for transaction",
"response_code": "402"
}Solution: Top up your account balance before making the request.
Rate Limiting
{
"response_message": "Rate limit exceeded. Please try again later.",
"response_code": "429"
}Solution: Implement exponential backoff and reduce request frequency.
Error Handling Best Practices
1. Always Check Response Codes
const response = await fetch('/api/endpoint', options);
const data = await response.json();
if (data.response_code === '000') {
// Success
console.log('Operation successful');
} else {
// Handle error
console.error('Error:', data.response_message);
}2. Implement Retry Logic
async function makeRequestWithRetry(url, options, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
const response = await fetch(url, options);
const data = await response.json();
if (data.response_code === '000') {
return data;
}
// Don't retry for client errors
if (data.response_code === '400' || data.response_code === '401') {
throw new Error(data.response_message);
}
// Retry for server errors
if (i < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, i)));
}
} catch (error) {
if (i === maxRetries - 1) throw error;
}
}
}3. Log Errors for Debugging
function handleApiError(error, context) {
console.error('API Error:', {
message: error.response_message,
code: error.response_code,
context: context,
timestamp: new Date().toISOString()
});
// Send to error tracking service
// trackError(error, context);
}4. User-Friendly Error Messages
function getErrorMessage(responseCode) {
const errorMessages = {
'100': 'Authentication failed. Please check your credentials.',
'400': 'Invalid request. Please check your parameters.',
'402': 'Insufficient balance. Please top up your account.',
'429': 'Too many requests. Please try again later.',
'500': 'Server error. Please contact support.'
};
return errorMessages[responseCode] || 'An unexpected error occurred.';
}Testing Error Scenarios
Test Authentication
# Test with invalid credentials
curl -X POST "https://api.bridgeagw.com/make_payment" \
-H "Authorization: Basic invalid_credentials" \
-H "Content-Type: application/json" \
-d '{"service_id": 1}'Test Invalid Parameters
# Test with missing required parameters
curl -X POST "https://api.bridgeagw.com/make_payment" \
-H "Authorization: Basic <valid_credentials>" \
-H "Content-Type: application/json" \
-d '{}'Test Rate Limiting
# Make multiple rapid requests to test rate limiting
for i in {1..10}; do
curl -X POST "https://api.bridgeagw.com/get_account_balance" \
-H "Authorization: Basic <valid_credentials>" \
-H "Content-Type: application/json" \
-d '{"service_id": 1, "request_time": "2025-08-31 23:35"}'
doneSupport
If you encounter error codes not listed here or need assistance with error handling, please contact our support team with:
- The complete error response
- The request that caused the error
- Your service ID
- Timestamp of the error