# Check MX records

> GET /domains/mx-check — preflight a hostname's existing MX records before enabling receiving.

`GET /domains/mx-check`

A preflight for [receiving](https://www.mailblastr.com/docs/receiving/introduction): does a hostname already have MX records, and do they all point at our inbound host? Use it before pointing a domain's MX at us so you can warn about an existing mail provider (switching MX would redirect **all** of that domain's mail to us). Read-only; requires a read-scoped key.

**Query parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | Yes | The hostname to check, e.g. `mail.yourdomain.com`. |

### Request

```bash
curl "https://api.mailblastr.com/domains/mx-check?name=mail.yourdomain.com" \
  -H "Authorization: Bearer $MAILBLASTR_API_KEY"
```

```js
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr(process.env.MAILBLASTR_API_KEY);

const { data } = await mb.domains.mxCheck('mail.yourdomain.com');
```

### Response

```json
{
  "has_mx": true,
  "ours": false,
  "records": [
    { "exchange": "aspmx.l.google.com", "priority": 1 },
    { "exchange": "alt1.aspmx.l.google.com", "priority": 5 }
  ]
}
```

**Response fields**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `has_mx` | boolean | No | Whether the hostname has any MX records at all. |
| `ours` | boolean | No | Whether every MX record already points at our inbound host (i.e. receiving is ready). |
| `records` | object[] | No | The discovered MX records, each `{ exchange, priority }`, sorted by priority. |

A missing `name` returns `missing_required_field` (400); an invalid domain returns `validation_error` (422). A hostname with no MX (or an unresolvable one) returns `{ has_mx: false, ours: false, records: [] }`. See [Errors](https://www.mailblastr.com/docs/api/errors).
