---
title: "Check the health of a mailbox"
url: "https://coldagentai.com/docs/guides/check-mailbox-health.md"
canonical_url: "https://coldagentai.com/docs/guides/check-mailbox-health"
last_updated: "2026-10-18"
type: "how-to"
summary: "Run a live check on a connected mailbox, read its connection status and SPF, DKIM and DMARC results, and fix what fails."
related: ["https://coldagentai.com/docs/api/mailboxes.md", "https://coldagentai.com/docs/webhooks.md", "https://coldagentai.com/docs/capabilities.md", "https://coldagentai.com/docs/errors.md"]
install: "claude mcp add --transport http coldagentai-free https://coldagentai.com/api/mcp"
---

# Check the health of a mailbox

> **For AI agents:** the complete index of ColdAgentAI pages is [llms.txt](https://coldagentai.com/llms.txt). Every page is also served as markdown at its URL plus .md.

Run a live check on a connected mailbox, read its connection status and SPF, DKIM and DMARC results, and fix what fails.

Run a live check on a mailbox, read its status and its SPF, DKIM and DMARC results, and act on whatever failed.

## What you need

- A mailbox id from `GET /v1/mailboxes`, which lists every connected mailbox with its status and health. Credentials are never returned.
- A write key for the check itself, because it contacts the mail server and can change the mailbox status. Reading status needs only a read key. See [Authentication](https://coldagentai.com/docs/authentication.md).

## Read the status first

`GET /v1/mailboxes/{id}` returns the mailbox as the API holds it. Three fields tell you its state without contacting anything.

| Field | Values | Meaning |
| --- | --- | --- |
| `status` | `connected`, `disconnected`, `error` | `connected` mailboxes can send. A mailbox is marked `disconnected` after repeated authentication failures, and a `MailboxDisconnected` [webhook](https://coldagentai.com/docs/webhooks.md) event is sent when that happens. |
| `health.last_checked_at` | time or `null` | When the credentials were last tested. |
| `health.consecutive_failures` and `health.last_error` | number, text or `null` | The current run of failed checks, plus sends or syncs the mail server rejected for bad credentials, and the latest error. A success resets the count. |

## Run a check

`POST /v1/mailboxes/{id}/check` proves the stored credentials still work without sending any mail, then looks up SPF, DKIM and DMARC for the mailbox domain. The body is optional.

DKIM selectors cannot be listed in DNS, so the check tries a list of common ones. If your provider uses another selector, pass up to 10 in `dkim_selectors`.

cURL:

```
curl -X POST https://api.coldagentai.com/v1/mailboxes/$MAILBOX_ID/check \
  -H "Authorization: Bearer $COLDAGENTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "dkim_selectors": ["selector1", "selector2"] }'
```

Node:

```
const base = 'https://api.coldagentai.com';
const headers = { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}`, 'Content-Type': 'application/json' };

async function call(method, path, body) {
  const res = await fetch(base + path, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
  const json = await res.json();
  if (!res.ok) throw new Error(`${json.error.code}: ${json.error.fix}`);
  return json;
}

const check = await call('POST', `/v1/mailboxes/${process.env.MAILBOX_ID}/check`, {
  dkim_selectors: ['selector1', 'selector2'],
});

console.log(check.mailbox.status, check.connectivity);
if (check.dns) {
  console.log(check.dns.overall, check.dns.spf.verdict, check.dns.dkim.verdict, check.dns.dmarc.verdict);
} else {
  console.log(check.dns_error);
}
```

## Read the response

The response has four parts: `mailbox` (the resource after the check), `connectivity`, `dns` and `dns_error`.

| `connectivity.status` | Meaning | What to do |
| --- | --- | --- |
| `ok` | The credentials work. A passing check also marks a mailbox that is not `connected` as `connected` again and clears its failure count. | Nothing. |
| `failed` | The mail server did not accept the connection. `reason` says why and `retryable` says whether trying again can help. | If `retryable` is false, reconnect the mailbox with fresh credentials. If true, run the check again later. |
| `unavailable` | This server cannot test this kind of mailbox. `blocked_by` and `reason` name the missing piece. | Read `GET /v1/capabilities`, slot `mail`. The mailbox itself is not shown to be broken. |

`dns` holds an `overall` verdict and one block each for `spf`, `dkim` and `dmarc`. The verdicts are `pass`, `warn`, `fail`, `missing` and `unknown`. Each block lists `issues`, and every issue has a `severity` (`fail`, `warn` or `info`), a `code`, a `message` and a `fix` in plain words. `dns` is `null` when the lookup could not run, and `dns_error` says why.

## What to do for each failing result

| Result | What to do |
| --- | --- |
| `spf` is `fail` or `warn` | Read the issues. `lookup_count` is how many DNS-querying terms the record uses across its includes, and `lookup_limit` is the most the standard allows. If you are at or over it, remove an include you no longer send through. Then publish the corrected record and check again. |
| `spf` is `missing` | Publish an SPF record for the domain that lists the services you send from. `GET /v1/tools/dns-auth` with `providers` returns the records for common sending services. |
| `dkim` is `missing` | No key was found at the common selectors. Look up your selector in your mail provider's settings and check again with `dkim_selectors`. If the key does not exist yet, publish it first. |
| `dkim` is `unknown` | Every DNS lookup failed. Run the check again in a minute. |
| `dkim` is `fail` with `selector_not_found` | Publish the DKIM record at exactly the host name for that selector. `keys` lists each selector found with its key size and whether it is valid. |
| `dmarc` is `missing` | Publish a DMARC record. `policy` shows the policy the current record sets, once there is one. |
| `overall` is `fail` | Fix the failing blocks above first. `overall` is the worst of the three, except that a DKIM `missing` counts only as a warning. |
| `connectivity` is `failed` with `retryable` false | The mail server refused the credentials. Reconnect the mailbox, then run the check once more. |

> DNS changes can take time to reach every resolver. If a record you just published still shows as `missing`, wait and run the check again.

## Check a domain without a mailbox

`GET /v1/tools/dns-auth?domain=example.com` runs the same SPF, DKIM and DMARC lookup for any domain with a read key. It is free and sends nothing. Add `selectors` (comma separated) for your own DKIM selectors and `providers` (comma separated) to get the records to publish for sending services such as `google` or `microsoft`.

cURL:

```
curl "https://api.coldagentai.com/v1/tools/dns-auth?domain=example.com&providers=google" \
  -H "Authorization: Bearer $COLDAGENTAI_API_KEY"
```

Node:

```
const base = 'https://api.coldagentai.com';
const res = await fetch(`${base}/v1/tools/dns-auth?domain=example.com&providers=google`, {
  headers: { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}` },
});
const dns = await res.json();
if (!res.ok) throw new Error(`${dns.error.code}: ${dns.error.fix}`);
console.log(dns.overall, dns.spf.verdict, dns.dkim.verdict, dns.dmarc.verdict, dns.recommended_records);
```

## What can go wrong

| Code | Cause | Fix |
| --- | --- | --- |
| [`unknown_product`](https://coldagentai.com/docs/errors.md#unknown_product) | The mailbox id is not in your account. | List mailboxes with `GET /v1/mailboxes`. |
| [`forbidden`](https://coldagentai.com/docs/errors.md#forbidden) | The check needs a write key and the key has read scope. | Use a write key. |
| [`invalid_input`](https://coldagentai.com/docs/errors.md#invalid_input) | A `dkim_selectors` entry is not a valid selector name, or there are too many. | Pass plain selector names only. |
| [`provider_unavailable`](https://coldagentai.com/docs/errors.md#provider_unavailable) | The route can answer 503 when the server cannot run the work. A blocked mail adapter is normally reported inside a 200 response, as `connectivity.status` of `unavailable`. | Read `GET /v1/capabilities`. |
| [`rate_limited`](https://coldagentai.com/docs/errors.md#rate_limited) | Too many requests for this key. | Wait `Retry-After` seconds. |

## Next steps

- Lower or raise a mailbox's daily limit, or turn on the volume ramp, with `PATCH /v1/mailboxes/{id}`. See [Mailboxes](https://coldagentai.com/docs/api/mailboxes.md).
- If a mailbox cannot be repaired, remove it. See the guide on disconnecting a mailbox.
- Get notified when a mailbox stops working by subscribing to `MailboxDisconnected` on [Webhooks](https://coldagentai.com/docs/webhooks.md).

## Related

- [Mailboxes API reference](https://coldagentai.com/docs/api/mailboxes.md)
- [Webhooks](https://coldagentai.com/docs/webhooks.md)
- [Capabilities](https://coldagentai.com/docs/capabilities.md)
- [API errors](https://coldagentai.com/docs/errors.md)
