nextmail.dnsConnections
Every method in this namespace: its signature, its parameters, what it returns and an example.
Methods
The DNS provider accounts connected to the workspace, through which Nextmail writes the records of a domain itself: list them, start connecting one, read what disconnecting one would leave behind, and disconnect it. A connection is finished in a browser, because the provider asks the person to sign in.
dnsConnections.list()
List the DNS provider accounts connected to the workspace
list(options?: RequestScope): Promise<DnsConnectionListResource>Returns every DNS provider account connected to the workspace, through which Nextmail writes the records of a domain itself, as the Providers tab of the domains page in the app shows them. Each one names the domains it serves, how many records Nextmail wrote through it and still keeps, and whether it is active, needs connecting again (needs-reauth) or was disconnected (revoked).
configured is false when this server cannot connect a provider at all. start begins a connection, which the person finishes in a browser because the provider asks them to sign in.
Parameters
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
Returns
DnsConnectionListResource, with every connection in data, disconnected ones included.
Example
const { configured, data } = await nextmail.dnsConnections.list() for (const connection of data) console.log(connection.subject, connection.status, connection.domains.length)Notes
A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client
maxRetries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
dnsConnections.start()
Start connecting a DNS provider account
start(options?: RequestScope): Promise<DnsConnectionStartResource>Starts connecting a Cloudflare account to the workspace and resolves with the url to open. The person the key or app acts for, the workspace owner for an API key, opens it in a browser signed in to Nextmail with this workspace open. Cloudflare asks them to sign in and choose what Nextmail may reach, and the connection is made when Cloudflare sends them back, which takes that signed-in browser session and never this credential.
The link works once, within 10 minutes. Connecting an account that is already connected refreshes it, and list shows the connection once it is made.
Parameters
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
Returns
DnsConnectionStartResource with object: 'dns_connection_start' and url, the Cloudflare sign-in page.
Example
const { url } = await nextmail.dnsConnections.start() console.log(`Open ${url} in a browser signed in to the workspace`)Notes
A server that cannot connect a provider answers 503
dns_unavailable, andconfiguredonlistis then false.A key or an access token limited to particular addresses or domains is refused with 422
capability_unsupported. An access token acting for a member also needsworkspace:managein their role, or it is refused with 403insufficient_authority.An OAuth access token needs a verification code for this call, and is refused with 403
step_up_requireduntil the app has verified one in the last 60 minutes.isStepUpRequiredon the error says so. An API key is never asked for a code.Not retried by the SDK.
Also available in
dnsConnections.get()
Read a DNS connection and what disconnecting it would leave behind
get(id: string, options?: RequestScope): Promise<DnsConnectionDetailResource>Returns one connection with what disconnecting it would do: the domains it serves, the records Nextmail wrote through it, busy for the domains a sync is running on right now, which hold a disconnect back until it ends, and keepsMail for the verified domains that stop receiving mail once their records come down.
Parameters
idstringRequiredA connection id from
list.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
Returns
DnsConnectionDetailResource.
Example
const connection = await nextmail.dnsConnections.get('dnsl_3f9a1c2e7b4d4e6f8a0b2c3d') if (connection.keepsMail.length) console.log('These stop receiving mail:', connection.keepsMail)Notes
A connection id that is not in this workspace is a 404
resource_not_found.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client
maxRetries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
dnsConnections.delete()
Disconnect a DNS provider account
delete(id: string, options?: RequestScope): Promise<DeletedDnsConnectionResource>Disconnects the account as Disconnect does in the app: the records Nextmail wrote through it come down, every domain it serves is detached, and the connection is revoked at the provider. A verified domain whose records come down stops receiving mail, so read get first. detached counts what came down and lists the records still published, to delete by hand.
A connection that is already disconnected is removed from the list instead, once no domain and no record is left on it, and removed says so.
Parameters
idstringRequiredA connection id from
list.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
Returns
DeletedDnsConnectionResource with removed, confirmed and detached.
Example
const result = await nextmail.dnsConnections.delete('dnsl_3f9a1c2e7b4d4e6f8a0b2c3d') console.log(result.removed ? 'Removed from the list' : `${result.detached?.detached ?? 0} domains detached`)Notes
A sync running on one of its domains is refused with 409
dns_busy, and nothing is revoked. A disconnected connection that still has domains or records on it is refused with 409dns_connection_in_use.A key or an access token limited to particular addresses or domains is refused with 422
capability_unsupported. An access token acting for a member also needsworkspace:managein their role, or it is refused with 403insufficient_authority.An OAuth access token needs a verification code for this call, and is refused with 403
step_up_requireduntil the app has verified one in the last 60 minutes.isStepUpRequiredon the error says so. An API key is never asked for a code.Not retried by the SDK.