Errors

Mailbeam uses standard HTTP status codes. All error responses include a machine-readable error field and a human-readable message.

Error response structure

{
  "error": "invalid_email_format",
  "message": "The email address is not RFC 5322 compliant.",
  "request_id": "req_01hx9abc123"
}

Always check the error field in your code — message may change; error is stable.

HTTP status codes

CodeMeaning
200Request succeeded
400Bad request — check your payload
401Authentication failed
403Forbidden — insufficient permissions
422Validation error — email address has a specific issue
429Rate limit or quota exceeded
500Internal server error — contact support

Error codes

Authentication errors

ErrorStatusDescription
missing_api_key401No Authorization header
invalid_api_key401Key format is invalid
revoked_api_key401Key has been revoked
insufficient_permissions403Key lacks required scope

Validation errors

ErrorStatusDescription
invalid_email_format422Email fails RFC 5322 syntax
email_too_long422Email exceeds 254 characters
missing_required_field400email field not present in body
invalid_json400Request body is not valid JSON

Rate limit errors

ErrorStatusDescription
rate_limit_exceeded429Per-second limit hit; check retry_after
quota_exceeded429Monthly quota exhausted (Free plan blocks; paid plans continue with overage billing)

Server errors

ErrorStatusDescription
internal_error500Transient server error — retry with backoff
upstream_timeout504SMTP probe timed out; result is inconclusive

Handling errors in code

try {
  const result = await mb.verify(email);
  if (!result.valid) {
    // Email is invalid but request succeeded — this is NOT an error
    handleInvalidEmail(result.reason);
  }
} catch (err) {
  switch (err.code) {
    case "rate_limit_exceeded":
      await sleep(err.retryAfter * 1000);
      // retry
      break;
    case "quota_exceeded":
      // Notify ops, switch to fallback, or allow signup
      notifyOpsTeam();
      break;
    case "invalid_api_key":
    case "revoked_api_key":
      // Alert — configuration issue
      alertPagerDuty("Mailbeam API key invalid");
      break;
    default:
      // Log and continue — don't block users on unexpected errors
      logger.error("Mailbeam error", { code: err.code, requestId: err.requestId });
  }
}

The reason field

When valid is false, the reason field contains a machine-readable string explaining why:

ReasonExplanation
invalid_syntaxFails RFC 5322 format check
no_mx_recordsDomain has no mail servers
smtp_rejectedMailbox does not exist
disposable_domainMatched a temporary email provider
role_addressLooks like a non-personal address
catch_all_unverifiableDomain accepts all mail; SMTP is inconclusive
timeoutSMTP probe timed out — treat as unknown

Never block users solely on catch_all_unverifiable. Use the score field instead to make nuanced decisions.