Docs

Errors

View as MarkdownOpen in ChatGPTOpen in Claude

Errors use HTTP status codes and a JSON body with a stable machine-readable code and a human message (the message may change; match on code):

{ "error": { "code": "insufficient_credits", "message": "Your credit balance is 0. Add credits in the dashboard to keep verifying." } }

Status codes

StatusCodeWhat to do
200Done
202Accepted: still checking (state: "pending") or processing in the background; poll
401unauthorizedSend Authorization: Bearer mf_live_... with a live key
402insufficient_creditsAdd credits; nothing was charged
403missing_scopeUse a key with the needed scope
403email_not_verifiedConfirm the account email address
403ip_not_allowedCall from an address in the key's IP allowlist, or edit the list in the dashboard
404not_foundWrong id, or it belongs to another account
409The list is not finished yet (download)
413too_largeBody or file over the limit; upload a file or split it
415unsupported_media_typeSend JSON or multipart as documented
422invalid_requestFix the request; the message says what is wrong
429rate_limited, limit_reached, too_many_open_listsWait Retry-After seconds (when sent) and retry
500internalRetry with backoff; safe with an Idempotency-Key
503busy, not_configuredTemporarily unavailable; retry later

Other endpoint-specific codes (for example already_monitored, monitor_limit, too_many_hooks) are listed per endpoint in the API reference.

Retries

  • Retry 429, 500, 502, 503 and 504 with exponential backoff, honouring Retry-After.
  • Send an Idempotency-Key on POST /v1/verify and /v1/verify/batch so a retry never charges twice.
  • Do not retry 4xx errors other than 429 without changing the request.

Tools endpoints

/v1/tools/* answer errors as {"error": "message"} with the same status codes (429 also carries retry_after in the body).

Handling errors in code

curl -sS -w '\nHTTP %{http_code}\n' https://api.mails.fit/v1/verify \
  -H "Authorization: Bearer $MAILSFIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "jane@example.com"}'
const res = await fetch("https://api.mails.fit/v1/verify", { method: "POST", headers, body });
if (!res.ok && res.status !== 202) {
  const { error } = await res.json();
  if (res.status === 429) await sleep(Number(res.headers.get("Retry-After") ?? 1) * 1000);
  throw new Error(`${res.status} ${error.code}: ${error.message}`);
}
res = requests.post(url, headers=headers, json=body, timeout=30)
if res.status_code == 429:
    time.sleep(int(res.headers.get("Retry-After", "1")))
elif res.status_code >= 400:
    err = res.json()["error"]
    raise RuntimeError(f"{res.status_code} {err['code']}: {err['message']}")
if res.StatusCode >= 400 {
	var e struct {
		Error struct{ Code, Message string } `json:"error"`
	}
	json.NewDecoder(res.Body).Decode(&e)
	return fmt.Errorf("%d %s: %s", res.StatusCode, e.Error.Code, e.Error.Message)
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status >= 400) {
    $err = json_decode($body, true)["error"];
    throw new RuntimeException("$status {$err['code']}: {$err['message']}");
}
let res = client.post(url).bearer_auth(&key).json(&body).send().await?;
if res.status().is_client_error() || res.status().is_server_error() {
    let status = res.status();
    let err: serde_json::Value = res.json().await?;
    anyhow::bail!("{status} {}: {}", err["error"]["code"], err["error"]["message"]);
}