NightmailDocs
Docs

Choose receiving host

post/v1/domains/{id}/receiving-host

Hosted only. Choose a host for this domain to receive on, its root or one of its subdomains. Until the domain receives anywhere, the choice replaces the automatic suggestion (the first of reply., inbound., mail. and so on with no MX and no CNAME), and null returns to it. Once it receives, the chosen host is added beside the hosts it already receives on, as POST /v1/inbound/domains/{id}/hosts does: nothing that receives is moved or stopped. Public DNS is checked first. A CNAME (RFC 1034), one of Nightmail’s own names (custom MAIL FROM, ownership TXT, DKIM), a host another domain receives on (in any workspace), a name another workspace has claimed (send-only included) or a delegated zone (its own NS records) is refused with a free subdomain to use instead. A host whose mail another provider receives, or whose MX is split, needs confirm: true, because publishing Nightmail’s MX moves that mail. A wildcard (*.domain) answer only flags receivingIssue. Nothing changes in DNS or SES.

Needs Receiving rules: write for the sender domain. A person needs to be an owner or admin. Not a temporary agent token.

Example

import { createClient } from '@nightmail/sdk/client';
import { chooseReceivingHost } from '@nightmail/sdk';

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

const result = await chooseReceivingHost({
  client,
  path: {
    "id": "resource_123"
  },
  body: {
    "host": "example",
    "confirm": false
  },
  throwOnError: true,
});

console.log(result.data);
curl --request POST \
  --url 'https://nightmail.dev/v1/domains/resource_123/receiving-host' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "host": "example",
  "confirm": false
}'

Parameters

idrequiredpath · string

Request body

ChooseReceivingHost
hostrequiredstring or null
confirmboolean

Responses

200Success
DomainReadiness
idrequiredstring
namerequiredstring
regionrequiredstring
verificationStatusrequiredstring
verifiedrequiredboolean
dkimStatusrequiredstring
dmarcrequiredobject or null

Last DNS and SES observation for this From domain. Null when unchecked, unavailable or stale. Alignment describes configured identifiers, not a delivery verdict.

dmarc.statusrequiredstring
dmarc.recordrequiredstring or null
dmarc.sourcerequiredstring or null

Domain publishing the effective TXT record; may be the organizational domain.

dmarc.adkimrequiredstring
dmarc.aspfrequiredstring
dmarc.alignmentrequiredobject
readyrequiredboolean
sendingrequiredstring
receivingrequiredstring
mailFromDomainrequiredstring or null
mailFromStatusrequiredstring or null
dnsStatusrequiredstring
dnsUnavailableReasonrequiredstring or null
dnsrequiredobject[]
dns[].namerequiredstring
dns[].typerequiredstring
dns[].valuerequiredstring
dns[].prioritynumber
dns[].purposerequiredstring

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[].statusrequiredstring
dns[].notestring
dns[].publicDnsobject or null

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.

dnsHostobject or null

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

The provider, e.g. Cloudflare, Vercel, Route 53, GoDaddy or Namecheap.

dnsHost.zonerequiredstring

The zone it hosts, which record names are relative to there.

dnsHost.urlrequiredstring or null

The provider's DNS page for the zone, when it has a known address.

dnsIssueobject or null

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

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.messagerequiredstring
releasesAtstring or null

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.

receivingIssueobject or null

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

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.hostrequiredstring
receivingIssue.blockingrequiredboolean

True when receiving there cannot work until DNS or the choice changes.

receivingIssue.messagerequiredstring
receivingIssue.providerstring or null
receivingIssue.targetstring or null

The existing CNAME target.

receivingIssue.suggestionstring or null

A free subdomain to use instead.

builtInboolean

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

limitsobject

Built-in domain only: what it sends, before a send finds out. GET /v1/domains/{id} and listDomains.

limits.scoperequiredstring

Who it sends to: anyone, or the verified addresses of the workspace’s members.

limits.perDayrequiredinteger

Recipients in a rolling 24 hours.

limits.perMinuterequiredinteger

Recipients in a minute.

limits.unsupportedrequiredstring[]

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

The same, in one sentence.

400, 401, 403, 404, 409, 413, 422, 429, 500, 503Request failed; use error.code and requestId to diagnose.
ApiError
errorrequiredobject
error.coderequiredstring
error.messagerequiredstring
error.requestIdrequiredstring
error.fieldstring
error.retryablerequiredboolean
error.resetAtstring

Next capacity change for a Hosted rolling send limit.

error.detailsobject[]

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

On a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.