# 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)

## List domains

`GET /v1/domains`

MX returns persisted DNS records and background verification status without AWS calls. Self-hosted installations refresh up to ten identities unless refresh=false.

Operation ID: `listDomains`

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `cursor` | query | string | no |  |
| `limit` | query | integer | no |  |
| `region` | query | string | no |  |
| `refresh` | query | string | no |  |


### TypeScript SDK

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

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

const result = await listDomains({
  client,
  throwOnError: true,
});

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

### cURL

```sh
curl --request GET \
  --url 'https://nightmail.dev/v1/domains' \
  --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 |
| --- | --- | --- | --- |
| `data` | object[] | yes |  |
| `data[].id` | string | yes |  |
| `data[].name` | string | yes |  |
| `data[].region` | string | yes |  |
| `data[].verificationStatus` | string | yes |  |
| `data[].verified` | boolean | yes |  |
| `data[].dkimStatus` | string | yes |  |
| `data[].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. |
| `data[].ready` | boolean | yes |  |
| `data[].sending` | string | yes |  |
| `data[].receiving` | string | yes |  |
| `data[].mailFromDomain` | string or null | yes |  |
| `data[].mailFromStatus` | string or null | yes |  |
| `data[].dnsStatus` | string | yes |  |
| `data[].dnsUnavailableReason` | string or null | yes |  |
| `data[].dns` | object[] | yes |  |
| `data[].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. |
| `data[].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. |
| `data[].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. |
| `data[].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. |
| `data[].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). |
| `data[].limits` | object | no | Built-in domain only: what it sends, before a send finds out. GET /v1/domains/{id} and listDomains. |
| `nextCursor` | string or null | yes |  |
| `quota` | object | no | Hosted only, and only for credentials without domain restrictions. Absent when the workspace sends through its own AWS account, which has no domain total. Adding a domain past the limit fails with DOMAIN_LIMIT_REACHED; at most 10 of them may be unproven at once. |
| `quota.used` | integer | yes | Domains in the workspace, across every region and page. |
| `quota.limit` | integer | yes | How many domains the workspace may have: 100 unless Nightmail set another limit on request. |

#### 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. |
