Back to Documentation

Error Codes

Complete reference of API error codes with descriptions and resolution steps.

Error Response Format

All error responses follow a consistent JSON structure:

Error Response
{
  "error": {
    "code": "INVALID_EMAIL",
    "message": "The email address format is invalid",
    "details": {
      "field": "to",
      "value": "invalid-email"
    },
    "request_id": "req_abc123xyz"
  }
}

Response Fields

  • code - Machine-readable error code
  • message - Human-readable error description
  • details - Additional context (optional)
  • request_id - Unique request identifier for support

Authentication Errors (401)

CodeMessageResolution
INVALID_API_KEYThe API key provided is invalidCheck that your API key is correct and starts with 'ek_live_' or 'ek_test_'
EXPIRED_API_KEYThe API key has expiredGenerate a new API key from your dashboard settings
REVOKED_API_KEYThe API key has been revokedGenerate a new API key from your dashboard settings
MISSING_API_KEYNo API key was providedInclude your API key in the Authorization header

Validation Errors (400)

CodeMessageResolution
INVALID_EMAILThe email address format is invalidEnsure the 'to' field contains a valid email address
INVALID_PHONEThe phone number format is invalidUse E.164 format for phone numbers (e.g., +14155552671)
MISSING_REQUIRED_FIELDA required field is missingCheck the error details for the missing field name
INVALID_TEMPLATE_IDThe specified template does not existVerify the template ID in your dashboard
INVALID_ATTACHMENTThe attachment is invalid or too largeEnsure attachments are base64 encoded and under 25MB
INVALID_SCHEDULE_TIMEThe scheduled time is in the pastSet scheduled_at to a future timestamp

Permission Errors (403)

CodeMessageResolution
INSUFFICIENT_PERMISSIONSYour API key lacks the required scopeGenerate a new API key with the needed scopes
DOMAIN_NOT_VERIFIEDThe sending domain is not verifiedVerify your domain in the dashboard settings
PHONE_NOT_REGISTEREDThe sending phone number is not registeredPurchase or register a phone number in your account
FEATURE_NOT_AVAILABLEThis feature is not available on your planUpgrade your plan to access this feature

Resource Errors (404)

CodeMessageResolution
EMAIL_NOT_FOUNDThe specified email does not existVerify the email ID is correct
SMS_NOT_FOUNDThe specified SMS does not existVerify the SMS ID is correct
CALL_NOT_FOUNDThe specified call does not existVerify the call ID is correct
TEMPLATE_NOT_FOUNDThe specified template does not existCheck the template ID in your dashboard
WEBHOOK_NOT_FOUNDThe specified webhook does not existVerify the webhook ID is correct

Rate Limit Errors (429)

CodeMessageResolution
RATE_LIMIT_EXCEEDEDToo many requestsWait for the Retry-After period and implement backoff
DAILY_LIMIT_EXCEEDEDDaily sending limit exceededWait until the limit resets or upgrade your plan
MONTHLY_LIMIT_EXCEEDEDMonthly sending limit exceededUpgrade your plan for higher limits

Server Errors (500)

CodeMessageResolution
INTERNAL_ERRORAn unexpected error occurredRetry the request. If it persists, contact support
SERVICE_UNAVAILABLEThe service is temporarily unavailableWait and retry with exponential backoff
GATEWAY_TIMEOUTThe request timed outRetry the request with a smaller payload

Handling Errors

JavaScript

javascript
async function sendEmail(data) {
  try {
    const response = await fetch('/api/emails', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer ek_live_xxxxxxxxxxxxx',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(data),
    });

    if (!response.ok) {
      const error = await response.json();
      
      switch (error.error.code) {
        case 'INVALID_EMAIL':
          console.error('Invalid email:', error.error.details.value);
          break;
        case 'RATE_LIMIT_EXCEEDED':
          const retryAfter = response.headers.get('Retry-After');
          console.log(`Retry after ${retryAfter} seconds`);
          break;
        case 'DOMAIN_NOT_VERIFIED':
          console.error('Please verify your domain first');
          break;
        default:
          console.error('API Error:', error.error.message);
      }
      
      return null;
    }

    return response.json();
  } catch (err) {
    console.error('Network error:', err);
    return null;
  }
}

Python

python
from ekdsend import EKDSend
from ekdsend.exceptions import (
    ValidationError,
    AuthenticationError,
    RateLimitError,
    APIError
)

client = EKDSend('ek_live_xxxxxxxxxxxxx')

try:
    email = client.emails.send(
        from_email='hello@yourdomain.com',
        to='user@example.com',
        subject='Hello',
        html='<p>World</p>'
    )
except ValidationError as e:
    print(f"Validation error: {e.code}")
    print(f"Details: {e.details}")
except AuthenticationError as e:
    print(f"Auth error: {e.message}")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except APIError as e:
    print(f"API error ({e.status_code}): {e.message}")
    print(f"Request ID: {e.request_id}")

Need Help?

If you encounter an error that you cannot resolve, please include the request_id from the error response when contacting support. This helps us quickly identify and resolve your issue.