Error
Handling

The SignupGuard API uses standard HTTP status codes and returns structured JSON error responses. This page covers all possible error scenarios and how to handle them.

Error Response Format

All error responses follow a consistent JSON structure. The success field is always false for errors, and the response includes either a message string or an errors object with field-specific details.

General Error

{
  "success": false,
  "message": "A description of what went wrong."
}

Validation Error (field-specific)

{
  "success": false,
  "errors": {
    "email": ["Enter a valid email address."],
    "domain": ["This field is required when email is not provided."]
  }
}

HTTP Status Codes

CodeStatusDescription
200OKRequest succeeded. The response contains the requested data.
400Bad RequestThe request was malformed or missing required parameters. Check the errors field for specifics.
403ForbiddenAuthentication failed. Your API key is missing, invalid, or has been revoked.
404Not FoundThe requested endpoint does not exist. Check the URL path.
422Unprocessable EntityThe request was understood but could not be processed. This typically occurs when an upstream service is temporarily unavailable.
429Too Many RequestsRate limit exceeded. Check the Retry-After header and wait before retrying.
500Server ErrorAn unexpected error occurred on the server. If this persists, contact support.
503Service UnavailableThe service is temporarily unavailable due to maintenance or high load. Retry with exponential backoff.

Common Error Scenarios

Authentication Errors (403)

Missing API key header

You forgot to include the X-sg-apikey header in your request.

{ "success": false, "message": "API key required" }

Invalid API key

The API key you provided does not exist or has been revoked.

{ "success": false, "message": "Invalid API key" }

Validation Errors (400)

Missing required parameter

A required parameter was not included in the request.

{
  "success": false,
  "errors": {
    "email": ["This field is required when domain is not provided."]
  }
}

Invalid format

A parameter value does not match the expected format.

{
  "success": false,
  "errors": {
    "ip": ["Enter a valid IPv4 or IPv6 address."]
  }
}

Rate Limit Errors (429)

Too many requests

You've exceeded your rate limit. Wait for the number of seconds indicated in the Retry-After header. See the Rate Limits page for details.

{ "success": false, "message": "Rate limit exceeded. Please try again later." }

Best Practices

  • Always check the success field. Before accessing response data, verify that success is true.
  • Handle HTTP status codes. Use the HTTP status code to determine the error category before parsing the response body.
  • Implement retry logic for 5xx errors. Server errors are usually transient. Retry with exponential backoff for 500 and 503 responses.
  • Do not retry 400 or 403 errors. These indicate client-side issues that need to be fixed before retrying (bad parameters or invalid authentication).
  • Respect rate limits. Always handle 429 responses by waiting the indicated time. Do not retry immediately.
  • Log errors for debugging. Log the full error response (status code, headers, body) to help diagnose issues.

Example — Error Handling in Code

python — comprehensive error handling
python
import requests
import time

def check_email(email, api_key):
    try:
        response = requests.get(
            "https://signupguard.io/api/v1/disposable/check/",
            params={"email": email},
            headers={"X-sg-apikey": api_key},
            timeout=10
        )

        if response.status_code == 200:
            data = response.json()
            if data["success"]:
                return data["data"]

        elif response.status_code == 400:
            errors = response.json().get("errors", {})
            print(f"Validation error: {errors}")

        elif response.status_code == 403:
            print("Authentication failed — check your API key")

        elif response.status_code == 429:
            retry_after = int(response.headers.get("Retry-After", 5))
            print(f"Rate limited — retry after {retry_after}s")
            time.sleep(retry_after)
            return check_email(email, api_key)  # Retry once

        elif response.status_code >= 500:
            print(f"Server error ({response.status_code}) — retry later")

        return None

    except requests.exceptions.Timeout:
        print("Request timed out — retry later")
        return None
    except requests.exceptions.ConnectionError:
        print("Connection error — check network")
        return None
javascript — comprehensive error handling
javascript
async function checkEmail(email, apiKey) {
  try {
    const response = await fetch(
      `https://signupguard.io/api/v1/disposable/check/?email=${email}`,
      { headers: { "X-sg-apikey": apiKey } }
    );

    if (response.ok) {
      const { success, data } = await response.json();
      if (success) return data;
    }

    if (response.status === 400) {
      const { errors } = await response.json();
      console.error("Validation error:", errors);
    }

    if (response.status === 403) {
      console.error("Authentication failed — check your API key");
    }

    if (response.status === 429) {
      const retryAfter = parseInt(response.headers.get("Retry-After") || "5");
      console.warn(`Rate limited — retrying in ${retryAfter}s`);
      await new Promise(r => setTimeout(r, retryAfter * 1000));
      return checkEmail(email, apiKey); // Retry once
    }

    if (response.status >= 500) {
      console.error(`Server error (${response.status}) — retry later`);
    }

    return null;
  } catch (error) {
    console.error("Network error:", error.message);
    return null;
  }
}

Need Help?

If you're encountering persistent errors or need help debugging an integration issue, contact our support team at [email protected] with the following details:

  • The endpoint you're calling
  • The HTTP status code you received
  • The full error response body
  • The approximate time the error occurred