Bridge API DocsBridge API Docs
Bridge API Docs

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

CodeStatusDescription
200OKRequest successful
202AcceptedRequest received and queued for processing
400Bad RequestInvalid request parameters
401UnauthorizedAuthentication failed
403ForbiddenAccess denied
404Not FoundResource not found
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error

Custom Response Codes

Success Codes

CodeDescriptionUsage
000SuccessGeneral success response
202Request AcceptedPayment request received for processing
370SMS QueuedSMS request received for processing

Error Codes

CodeDescriptionHTTP StatusAction Required
100Not Allowed401Check authentication credentials
400Bad Request400Validate request parameters
401Unauthorized401Provide valid authentication
402Insufficient Balance402Top up account balance
403Forbidden403Check account permissions
404Not Found404Verify resource exists
429Rate Limited429Reduce request frequency
500Server Error500Contact support

Transaction Status Codes

CodeDescriptionMeaning
000Transaction SuccessfulPayment completed successfully
001Transaction FailedPayment failed
002Transaction PendingPayment still processing
003Transaction CancelledPayment 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"}'
done

Support

If you encounter error codes not listed here or need assistance with error handling, please contact our support team with:

  1. The complete error response
  2. The request that caused the error
  3. Your service ID
  4. Timestamp of the error