# Nightmail API

Send, receive and reply to email on your own domains. 202 means queued, not delivered.

- [Interactive documentation](/docs)
- [OpenAPI 3.1 JSON](/openapi.json)
- [Agent index](/llms.txt)
- TypeScript package: `@nightmail/sdk`

[API index](/docs.md) · [Domains reference](/docs/tags/domains.md)

## Get domain

`GET /v1/domains/{id}`

On MX, read the stored DNS records and verification status without an AWS call.

Operation ID: `getDomain`

Permission: Needs Configuration: read for the sender domain. A person needs to be an owner or admin.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |


### TypeScript SDK

```ts
import { createClient } from '@nightmail/sdk/client';
import { getDomain } from '@nightmail/sdk';

const client = createClient({
  baseUrl: 'https://nightmail.dev',
  auth: scheme => scheme.scheme === 'bearer'
    ? process.env.NIGHTMAIL_API_KEY
    : undefined,
});

const result = await getDomain({
  client,
  path: {
    "id": "resource_123"
  },
  throwOnError: true,
});

console.log(result.data);
```

### cURL

```sh
curl --request GET \
  --url 'https://nightmail.dev/v1/domains/resource_123' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY"
```

### Responses

| Status | Description | Schema |
| --- | --- | --- |
| `200` | Success | object |
| `400`, `401`, `403`, `404`, `409`, `413`, `422`, `429`, `500`, `503` | Request failed; use error.code and requestId to diagnose. | object |

#### 200: Success

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes |  |
| `name` | string | yes |  |
| `region` | string | yes |  |
| `verificationStatus` | string | yes |  |
| `verified` | boolean | yes |  |
| `dkimStatus` | string | yes |  |
| `dmarc` | object or null | yes | Last DNS and SES observation for this From domain. Null when unchecked, unavailable or stale. Alignment describes configured identifiers, not a delivery verdict. |
| `dmarc.status` | string | yes |  |
| `dmarc.record` | string or null | yes |  |
| `dmarc.source` | string or null | yes | Domain publishing the effective TXT record; may be the organizational domain. |
| `dmarc.adkim` | string | yes |  |
| `dmarc.aspf` | string | yes |  |
| `dmarc.alignment` | object | yes |  |
| `ready` | boolean | yes |  |
| `sending` | string | yes |  |
| `receiving` | string | yes |  |
| `mailFromDomain` | string or null | yes |  |
| `mailFromStatus` | string or null | yes |  |
| `dnsStatus` | string | yes |  |
| `dnsUnavailableReason` | string or null | yes |  |
| `dns` | object[] | yes |  |
| `dns[].name` | string | yes |  |
| `dns[].type` | string | yes |  |
| `dns[].value` | string | yes |  |
| `dns[].priority` | number | no |  |
| `dns[].purpose` | string | yes | links: optional, the domain's own link host (links.<domain>) for the unsubscribe and other links Nightmail adds to campaign and marketing mail; shown when the installation has a link domain with Cloudflare for SaaS. |
| `dns[].status` | string | yes |  |
| `dns[].note` | string | no |  |
| `dns[].publicDns` | object or null | no | For pending sending and MAIL FROM records: what public DNS (Cloudflare 1.1.1.1) shows for this record. verifyDomain looks it up now (answers cached up to 30 seconds). Other reads show the last background check, which runs every 15 to 60 minutes for a Hosted domain still pending an hour after it was added. Null when DNS did not answer in time; absent before any check and on other records. |
| `dnsHost` | object or null | no | Where this domain’s DNS is hosted, from its zone’s NS records, alongside publicDns: null when the provider is not one Nightmail recognizes. |
| `dnsHost.name` | string | yes | The provider, e.g. Cloudflare, Vercel, Route 53, GoDaddy or Namecheap. |
| `dnsHost.zone` | string | yes | The zone it hosts, which record names are relative to there. |
| `dnsHost.url` | string or null | yes | The provider's DNS page for the zone, when it has a known address. |
| `dnsIssue` | object or null | no | Set when adding the domain (one bounded NS lookup), by Check now and by the background check: the domain has no DNS at all. Never set when DNS couldn’t be read. Fix the name (add the right domain and delete this one) or register the domain. |
| `dnsIssue.code` | string | yes | no_dns: no nameservers serve this domain: it is unregistered, lapsed or mistyped, so its records can’t be published and it can’t verify. |
| `dnsIssue.message` | string | yes |  |
| `releasesAt` | string or null | no | Hosted only: when this domain is released if its records are still unproven (72 hours after it was added). Null once ownership has been proven. |
| `receivingIssue` | object or null | no | Hosted only: receiving needs attention. Set by the DNS checks that run when a receiving host is suggested or chosen, on Check now and in the hourly recheck. Null when the receiving record is clear. |
| `receivingIssue.code` | string | yes | cname: the host is a CNAME, so it cannot have an MX (RFC 1034). foreign_mx: another provider receives its mail. split: other MX records share its mail. wildcard: a *.domain CNAME or MX answers for it. bane_record: it is one of Nightmail’s own names (custom MAIL FROM, ownership TXT, DKIM). host_taken: another claim, possibly in another workspace, receives on it. claimed: another workspace claimed it, or a name between it and this domain, in any scope. delegated: it is a delegated zone with its own NS records. claimed and delegated hosts never receive here. mx_missing: its MX disappeared after setup. wrong_region and null_mx: its MX points elsewhere in SES or refuses mail. proof_stale / identity_stale: the ownership TXT proof or the SES verification is out of date. |
| `receivingIssue.host` | string | yes |  |
| `receivingIssue.blocking` | boolean | yes | True when receiving there cannot work until DNS or the choice changes. |
| `receivingIssue.message` | string | yes |  |
| `receivingIssue.provider` | string or null | no |  |
| `receivingIssue.target` | string or null | no | The existing CNAME target. |
| `receivingIssue.suggestion` | string or null | no | A free subdomain to use instead. |
| `builtIn` | boolean | no | Hosted only: the workspace’s built-in domain, a subdomain of Nightmail’s own domain that needs no DNS. It sends until a domain of the workspace’s own verifies (limits here and connection.builtinDomain in GET /v1/me say what it sends), receives at every address, and can’t be deleted or changed (409 BUILTIN_DOMAIN). |
| `limits` | object | no | Built-in domain only: what it sends, before a send finds out. GET /v1/domains/{id} and listDomains. |
| `limits.scope` | string | yes | Who it sends to: anyone, or the verified addresses of the workspace’s members. |
| `limits.perDay` | integer | yes | Recipients in a rolling 24 hours. |
| `limits.perMinute` | integer | yes | Recipients in a minute. |
| `limits.unsupported` | string[] | yes | Request fields a send from it can’t use (refused together, as error.details[].unsupported of 422 BUILTIN_DOMAIN_UNSUPPORTED): from (a subdomain of it), replyTo (elsewhere), headers, attachments, template, scheduledAt, kind (marketing) and campaign. |
| `limits.summary` | string | yes | The same, in one sentence. |

#### 400, 401, 403, 404, 409, 413, 422, 429, 500, 503: Request failed; use error.code and requestId to diagnose.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | object | yes |  |
| `error.code` | string | yes |  |
| `error.message` | string | yes |  |
| `error.requestId` | string | yes |  |
| `error.field` | string | no |  |
| `error.retryable` | boolean | yes |  |
| `error.resetAt` | string | no | Next capacity change for a Hosted rolling send limit. |
| `error.details` | object[] | no | Every problem found, when there is more than one part, such as rule diagnostics with rule, line, column, message and hint, or a measurement, such as CONTENT_TOO_LARGE_TO_SCREEN with screenedBytes and limitBytes (and index in a batch). |
| `error.required` | object | no | On a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same. |
