API Errors

Comprehensive guide to handling errors in the UltraReach.ai API, including error codes, troubleshooting steps, and best practices for error handling.

Error Response Format

{
  "error": {
    "type": "validation_error",
    "code": "INVALID_PARAMETER",
    "message": "The provided parameter is invalid",
    "details": {
      "field": "email",
      "reason": "invalid_format"
    },
    "request_id": "req_123456789"
  }
}

Common Error Types

Authentication Errors

Issues with API keys or access tokens

Validation Errors

Invalid input parameters or formats

Rate Limit Errors

Too many requests in a time period

Server Errors

Internal system issues or downtime

HTTP Status Codes

4xx Client Errors

400Bad Request

The request was malformed or invalid

401Unauthorized

Missing or invalid authentication

403Forbidden

Valid auth but insufficient permissions

404Not Found

The requested resource doesn't exist

429Too Many Requests

Rate limit has been exceeded

5xx Server Errors

500Internal Server Error

Unexpected server error occurred

502Bad Gateway

Invalid response from upstream server

503Service Unavailable

Server is temporarily unavailable

504Gateway Timeout

Upstream server request timeout

Error Handling Best Practices

  • Always check error responses
  • Implement retry logic with backoff
  • Log errors with request IDs
  • Handle rate limits gracefully

Retry Strategy

const retry = async (fn, maxAttempts = 3) => {
  for (let i = 0; i < maxAttempts; i++) {
    try {
      return await fn();
    } catch (error) {
      if (!isRetryable(error) || 
          i === maxAttempts - 1) {
        throw error;
      }
      await wait(Math.pow(2, i) * 1000);
    }
  }
};

Rate Limiting Headers

X-RateLimit-Limit

Total requests allowed

X-RateLimit-Remaining

Requests remaining

X-RateLimit-Reset

Time until limit resets

Error Resolution Guide

Authentication

Check API keys and token validity

Validation

Verify request parameters and formats

Rate Limits

Implement request throttling

Server Issues

Check system status and retry later