Skip to content

Error Handling

The GetRaze API uses conventional HTTP response codes to indicate success or failure.

HTTP Status Codes

CodeDescription
200Success
201Created
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Error Response Format

All errors return a consistent JSON structure:

json
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message",
    "details": {}
  }
}

Error Codes

Authentication Errors

CodeStatusDescription
MISSING_API_KEY401No API key was provided
INVALID_API_KEY401API key is invalid or has been revoked
EXPIRED_API_KEY401API key has expired
INSUFFICIENT_PERMISSIONS403API key lacks required permission

Validation Errors

CodeStatusDescription
VALIDATION_ERROR400Request body validation failed
INVALID_PARAMETER400Invalid query parameter
MISSING_REQUIRED_FIELD400Required field is missing
INVALID_EMAIL400Email format is invalid

Resource Errors

CodeStatusDescription
NOT_FOUND404Requested resource was not found
ALREADY_EXISTS409Resource already exists
CONFLICT409Operation conflicts with current state

Rate Limiting

CodeStatusDescription
RATE_LIMIT_EXCEEDED429Too many requests, try again later

Example Error Responses

Missing API Key

json
{
  "success": false,
  "error": {
    "code": "MISSING_API_KEY",
    "message": "API key is required. Include it in the X-API-Key header."
  }
}

Validation Error

json
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Validation failed",
    "details": {
      "fields": {
        "email": "Invalid email format",
        "name": "Name is required"
      }
    }
  }
}

Resource Not Found

json
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Contact not found"
  }
}

Handling Errors

javascript
async function apiCall(endpoint, options) {
  const response = await fetch(endpoint, options);
  const data = await response.json();

  if (!data.success) {
    switch (data.error.code) {
      case 'RATE_LIMIT_EXCEEDED':
        // Wait and retry
        await sleep(60000);
        return apiCall(endpoint, options);

      case 'INVALID_API_KEY':
        // Check your API key configuration
        throw new Error('Invalid API key');

      case 'VALIDATION_ERROR':
        // Log validation details
        console.error('Validation errors:', data.error.details);
        throw new Error(data.error.message);

      default:
        throw new Error(data.error.message);
    }
  }

  return data;
}

GetRaze - AI-Powered Lead Generation