client.domains
Every method in this namespace: its signature, its parameters, what it returns and an example.
Methods
Custom domains attached to the workspace: add and remove them, read the DNS records to publish, check whether they can receive and send, manage their addresses and their photos, and set the catch-all, the tracking and files domains, the DMARC policy, the sender name and the brand logo.
domains.listdomains.list_alldomains.iteratedomains.getdomains.createdomains.verifydomains.updatedomains.deletedomains.get_logodomains.set_logodomains.remove_logodomains.set_logo_certificatedomains.remove_logo_certificatedomains.list_addressesdomains.list_all_addressesdomains.iterate_addressesdomains.create_addressdomains.get_addressdomains.update_addressdomains.set_address_photodomains.remove_address_photodomains.start_gravatar_publishdomains.delete_addressdomains.list_address_forwardsdomains.add_address_forwardsdomains.update_address_forwarddomains.delete_address_forwarddomains.resend_address_forward_consentdomains.list_address_membersdomains.get_address_logindomains.set_address_logindomains.delete_address_logindomains.get_mail_app_settingsdomains.update_mail_app_settingsdomains.get_address_limitsdomains.update_address_limitsdomains.list_app_passwordsdomains.create_app_passworddomains.update_app_passworddomains.delete_app_passworddomains.send_mail_app_setupdomains.create_mail_app_profile_linkdomains.get_dnsdomains.set_dns_zonedomains.sync_dnsdomains.list_routesdomains.list_all_routesdomains.iterate_routesdomains.create_routedomains.get_routedomains.update_routedomains.delete_routedomains.test_routedomains.list_group_membersdomains.list_all_group_membersdomains.iterate_group_membersdomains.add_group_membersdomains.remove_group_member
domains.list
List the workspace's domains and their receiving state
list(q: nil, limit: nil, cursor: nil, api_key: nil) -> Nextmail::PageReturns one page of the domains added to the workspace, alphabetically by domain. list_all collects every page and iterate walks them lazily. receiving reports the inbound checks: verified is true once verifiedAt is set, catchAll is the domain's catch all setting, lastCheckedAt is the most recent check and error is the last verification failure.
receiving and sending are independent. A verified domain can receive mail, and that says nothing about whether outbound mail from it is signed. sending.status is the signing state as the last check saw it, one of verified, pending, failed, no_identity or unknown, sending.canSend says whether a send from the domain would be accepted right now, sending.checkedAt dates that verdict, and sending.error carries the last failure. A negative verdict older than a day is treated as unknown rather than as a refusal, so canSend can be true while status is pending.
tracking reports the domain's custom tracking domain, set with update, and only a tracking.status of active means tracked links and the open pixel in new mail from the domain use its host instead of the default Nextmail host. storage reports the domain's custom files domain the same way, and only a storage.status of active means the download links for files sent from the domain use its host.
Parameters
qStringNarrows to domains whose name or id matches, up to 200 characters. Every word has to appear in one of them, ignoring case and accents, and when nothing matches exactly the search allows for a typo instead.
limitIntegerPage size, from 1 to 100. The server defaults to 25.
cursorStringThe
next_cursorof the previous page. Leave it out for the first page.api_keyStringOverrides the client's API key for this call only.
Returns
The Nextmail::Page with items, has_more? and next_cursor. Each item is a Hash with id, domain, receiving, sending, tracking, storage, logo, dmarcPolicy, senderName, autodiscovery, aliasOf, aliases and createdAt. aliasOf is the id of the domain this one is an alias of, or nil, and aliases lists the domains that are aliases of this one, each a Hash with id and domain.
Example
page = client.domains.list(limit: 100)unverified = page.items.reject { |domain| domain[:receiving][:verified] } unverified.each do |domain| receiving = domain[:receiving] puts "#{domain[:domain]}: #{receiving[:error] || "waiting for DNS"}, checked #{receiving[:lastCheckedAt]}"endNotes
A narrowed key still sees every domain in the workspace, whether it is narrowed by whole domains or by individual addresses.
Addresses, DNS records and the DMARC reading are only on
get.list_addressespages through the addresses on one domain.The cursor is opaque and holds where the last row sat in this order, so a row deleted or edited between pages never breaks the walk: the next page starts at the first row that sorts after it. A cursor this list did not hand out is a 400
invalid_cursor.
Also available in
- API
GET /domains- TypeScript
domains.list()- Python
domains.list()- PHP
domains->list- Go
Domains.List- Java
domains().list- C#
Domains.ListAsync- CLI
nextmail domains list
domains.list_all
Collect every domain into one array
list_all(q: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>Walks every page of list and returns all domains, alphabetically by domain. One request per page.
Parameters
qStringNarrows to domains whose name or id matches, up to 200 characters. Every word has to appear in one of them, ignoring case and accents, and when nothing matches exactly the search allows for a typo instead.
limitIntegerPage size for each request, from 1 to 100. The server defaults to 25.
cursorStringStarts the walk after this cursor instead of the first page.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Array of Hashes holding every domain, each shaped like an item of list.
Example
all = client.domains.list_all(limit: 100) puts all.sizeNotes
If any page fails the call raises, and the domains already fetched are discarded.
Also available in
- API
GET /domains- TypeScript
domains.listAll()- Python
domains.list_all()- PHP
domains->listAll- Go
Domains.ListAll- Java
domains().listAll- C#
Domains.ListAllAsync
domains.iterate
Stream the domains one at a time
iterate(q: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>Returns an Enumerator that yields domains one at a time, alphabetically by domain, or passes each one to the block you give it, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.
Parameters
qStringNarrows to domains whose name or id matches, up to 200 characters. Every word has to appear in one of them, ignoring case and accents, and when nothing matches exactly the search allows for a typo instead. Sent with every page.
limitIntegerPage size for each request, from 1 to 100. The server defaults to 25.
cursorStringStarts the walk after this cursor instead of the first page.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Enumerator of Hashes, one domain per step, each shaped like an item of list, or yields each one to a block.
Example
client.domains.iterate do |domain| p domainendNotes
Pages are fetched only as the loop reaches them, so an abandoned loop costs only the pages you consumed.
Also available in
- API
GET /domains- TypeScript
domains.iterate()- Python
domains.iterate()- PHP
domains->iterate- Go
Domains.Iterate- Java
domains().iterate- C#
Domains.IterateAsync
domains.get
Read one domain with its addresses, DNS records and DMARC reading
get(id, api_key: nil) -> HashReturns the same receiving and sending blocks as list, plus addresses: every address on the domain as a full lower cased address with its enabled flag. Disabled addresses are listed too. list_addresses returns the same addresses with their ids and labels. It also carries the tracking and storage blocks described on list, whose record is the CNAME record to add at your DNS provider for the tracking domain and for the files domain.
records is every DNS record the domain uses, each with type, name, value, priority on an MX record, a purpose written to be shown to a person, and status: found when the last check saw it in public DNS, missing when it did not, and nil when it has not been checked yet. found lists what public DNS answered at that name, and problem names the usual reason a record does not match, such as the domain added to the name twice, a value saved with its quote marks or a proxied CNAME, with a message to show a person. Publish each one exactly as given, since the values are specific to this domain. autodiscoveryRecords lists the SRV and TXT records that let mail apps set themselves up, while autodiscovery is true. dmarc is the domain's DMARC record as public DNS has it, with its stage, any issues, and whether a policy stricter than p=none is safe yet. It is nil until the domain is verified.
Reading an unverified domain checks its DNS again when the last check is more than 20 seconds old, so polling get is one way to wait for verification. verify checks straight away.
The id must belong to the calling workspace. Another workspace's domain id is a 404, the same as an id that does not exist, and the domain name is not accepted in its place.
Parameters
idStringRequiredDomain id from
list, a UUID.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with the fields of a list item plus addresses, records, autodiscoveryRecords and dmarc. Each entry of addresses is a Hash with address and enabled, each entry of records and autodiscoveryRecords is a Hash with type, name, value, priority, purpose, status, found and problem, and dmarc is a Hash with stage, record, issues, alignmentPossible and caveat, or nil.
Example
domain = client.domains.get("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f")live = domain[:addresses].select { |entry| entry[:enabled] } puts domain[:domain], domain[:receiving][:verified]p live.map { |entry| entry[:address] }Notes
sending.canSendis the value to branch on before a send: when it is false,emails.sendfrom this domain is refused with 409domain_not_sendable.A narrowed key still sees every address on the domain, whether it is narrowed by whole domains or by individual addresses.
Also available in
- API
GET /domains/{id}- TypeScript
domains.get()- Python
domains.get()- PHP
domains->get- Go
Domains.Get- Java
domains().get- C#
Domains.GetAsync- CLI
nextmail domains get
domains.create
Add a domain to the workspace
create(body = nil, api_key: nil, **fields) -> HashAdds a domain and returns it with every DNS record to publish, in the same shape as get. The first DNS check runs during the call, so the status of each entry in records already says what public DNS answers with.
The domain receives mail once public DNS answers with its MX records and its ownership TXT record, and it can send once its signing records are in place. Publish every entry in records exactly as given, since the values are specific to this domain, then call verify or poll get until receiving.verified is true.
A new domain starts with its catch-all on and no addresses. Create addresses with create_address, or turn the catch-all off with update.
Parameters
domainStringRequiredA bare domain such as
example.com. It is trimmed, lower cased and converted to its ASCII form, so an internationalised name is stored as punycode.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash shaped like get: the new domain with addresses empty, records holding every DNS record to publish, and dmarc nil until the domain is verified.
Example
domain = client.domains.create(domain: "example.com") domain[:records].each do |record| puts [record[:type], record[:name], record[:value], record[:priority], record[:status] || "not checked"].join(" ")endNotes
How many domains you can add is set by the plan of the workspace, counted within that workspace. Past it the call is refused with 403
domain_allowance_reached, and the message says which plan includes more.A domain you already added is 409
domain_already_added, one verified in another account is 409domain_claimeduntil that account removes it, and one that belongs to Nextmail is 409operator_domain. Anything that is not a hostname is 422invalid_parameterondomain.Adding a domain reaches the whole workspace, so a key or app limited to particular addresses or domains is refused with 422
capability_unsupportedondomainAllowlist. Use a key with no address or domain restriction.The SDK does not retry a create after a network failure. A second attempt after a lost response is refused with 409
domain_already_added, which means the first one worked: read the domain withlist.
Also available in
- API
POST /domains- TypeScript
domains.create()- Python
domains.create()- PHP
domains->create- Go
Domains.Create- Java
domains().create- C#
Domains.CreateAsync- CLI
nextmail domains create
domains.verify
Check a domain's DNS now
verify(id, api_key: nil) -> HashChecks the DNS of the domain straight away and returns it in the same shape as get. On an unverified domain it looks for the records that verify it, and receiving.verified comes back true when they are found. On a verified domain it checks the signing and return path records again and asks whether mail from the domain can be sent, so sending is fresh.
When the last check ran less than 10 seconds ago, nothing new is checked and the domain comes back as it stands, so calling it faster than that gains nothing. A record published a moment ago can take a few minutes to show up in public DNS.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash shaped like get, as the check left it.
Example
domain = client.domains.verify("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") unless domain[:receiving][:verified] waiting = domain[:records].reject { |record| record[:status] == "found" } puts domain[:receiving][:error] puts waiting.map { |record| "#{record[:type]} #{record[:name]}" }endNotes
Reading an unverified domain with
getalso checks it again when its last check is more than 20 seconds old, so either call works for polling.verifyneedsdomains:writeandgetneeds onlydomains:read.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.A domain id from another workspace is a 404, the same as an id that does not exist.
Retried automatically on network failure and retryable statuses, since a repeated check changes nothing but the time of the check.
Also available in
domains.update
Turn the catch-all on or off, set or remove the tracking and files domains, set the DMARC policy and the sender name, offer the records mail apps set themselves up from, and make the domain an alias
update(id, patch = nil, api_key: nil, **fields) -> HashcatchAll true accepts mail to any address on the domain that nobody created, and the address shows up in list_addresses from its first message on. False refuses mail to every address that was not created by hand, including the ones the catch-all picked up before. It applies to the whole domain, so only a key that holds the whole domain may change it.
trackingHost and storageHost set the two custom names a domain can carry once it is verified or its ownership TXT record is published, each of them a subdomain of it. trackingHost, such as links.example.com, is the name tracked links and the open pixel use. storageHost, such as files.example.com, is the name the download links for files sent from the domain use. All seven fields are optional and independent: a field left out is left alone, and for either host nil or an empty string removes that name and a string sets it. A patch carrying none of them changes nothing and answers with the domain as it stands. Each value is trimmed and lower cased, and a leading https:// or http://, any path, query or fragment and any trailing dots are stripped.
A new host is validated, saved and checked in the same call, so the response already carries the result of that first check. trackingHost reports into the tracking block and storageHost into storage, and the two blocks carry the same fields. The check asks the host over HTTPS for an answer signed by Nextmail, on /t/v/<nonce> for a tracking domain and /f/v/<nonce> for a files domain, so the host needs a CNAME record named record.name with the value record.value, with any proxying turned off. That value, also reported as target, is an address prepared for this host alone. When it could not be prepared during the call, record is nil, target is an empty string and error says so, and it is finished within a few minutes without another call. Until a check passes, status is pending and new mail keeps using the default Nextmail host. Once one passes, status is active and new mail from the domain uses the host.
Sending a host the domain already has runs the check again, unless the last check was less than 30 seconds ago, in which case the stored state comes back unchanged. A different host replaces the current one at once, so new mail uses the default host until the new one passes a check. nil or an empty string removes that name, and its block then reports status as none with host and record nil.
dmarcPolicy is what the domain's DMARC record tells receivers to do with mail that fails its checks: none only monitors, quarantine sends it to spam and reject refuses it. Inboxes show the domain logo only at quarantine or reject, and where Nextmail writes the DNS for the domain the record is updated during the call, keeping its other tags such as rua, while elsewhere you publish the DMARC record records lists.
senderName is the name recipients see beside every address on the domain that has no name of its own, such as Acme Support. Mail sent without a name in from goes out under the name of the address, then this one, then the name of the workspace. It is trimmed, and nil or a string that is empty once trimmed removes it.
autodiscovery true offers the SRV and TXT records that let mail, calendar and contacts apps find the servers from an address on the domain alone, for IMAP, SMTP, POP3, CalDAV and CardDAV. They are listed in autodiscoveryRecords with what the last check found, and none of them is needed to verify the domain or to send from it. Where Nextmail writes the DNS for the domain they are written during the call and false takes them down again, while elsewhere you publish them yourself.
aliasOf makes the domain an alias of another domain of the workspace. Mail to local@ the alias is then handled exactly as local@ the primary domain, through its addresses, routes, group addresses and catch-all, and local@ the alias may be used as a From address wherever local@ the primary may. nil stops it being an alias. The domain then reads aliasOf, and the primary lists it in aliases.
Parameters
idStringRequiredDomain id from
list, a UUID.catchAllBooleanTrue accepts mail to any address on the domain that nobody created, false refuses it. Leaving the field out leaves the catch-all alone.
trackingHostString or nilA subdomain of the domain of at most 512 characters, such as
links.example.com.nilor an empty string removes the tracking domain, and leaving the field out leaves it alone.storageHostString or nilA subdomain of the domain of at most 512 characters, such as
files.example.com.nilor an empty string removes the files domain, and leaving the field out leaves it alone.dmarcPolicyStringnone,quarantineorreject. A policy stricter thannoneneeds mail from the domain to be signed first. Leaving the field out leaves the policy alone.senderNameString or nilThe name mail from the domain goes out under when the address has no name of its own, at most 120 characters once trimmed, such as
Acme Support.nilor an empty string removes it, and leaving the field out leaves it alone.autodiscoveryBooleanTrue offers the SRV and TXT records that let mail, calendar and contacts apps find the servers from an address on the domain alone, false stops offering them. They are listed in
autodiscoveryRecords, and where the DNS of the domain is written for it they are written or taken down at once. Leaving the field out leaves it alone.aliasOfString or nilThe id of another domain hosted in this workspace to make this domain an alias of, or
nilto stop it being one. The other domain may not be an alias itself, this domain may not have aliases of its own, and it may not hold addresses created by hand or routes. Leaving the field out leaves it alone.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the same body as get, with receiving.catchAll, tracking, storage, dmarcPolicy, senderName, autodiscovery, autodiscoveryRecords, aliasOf and aliases as they stand after the call.
Example
domain = client.domains.update( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", trackingHost: "links.example.com", storageHost: "files.example.com")tracking = domain[:tracking]storage = domain[:storage] puts tracking[:status], tracking.dig(:record, :name), tracking.dig(:record, :value), tracking[:error]puts storage[:status], storage.dig(:record, :name), storage.dig(:record, :value)Notes
The host is refused with 422
invalid_tracking_host, orinvalid_storage_hostfor the files domain, when it is not a hostname, is not a strict subdomain of the domain, is the return path hostbounce.<domain>, belongs to Nextmail or is a domain set up to receive mail. A new host on a domain whosereceiving.verifiedis false and whose ownership TXT record is not published yet gets 409domain_not_verified. The domain does not have to be receiving mail for a host to be accepted. A host another domain already uses gets 409tracking_host_in_useorstorage_host_in_use, and so does a host already in use for the other feature, since one name cannot be both. AdmarcPolicystricter thannonewhilesending.statusis notverifiedgets 409domain_not_sendable, since unsigned mail from the domain would then go to spam. Every refusal names the field it came from inparam, and a refused field changes nothing. The fields are applied in order,catchAllfirst, thentrackingHost, thenstorageHost, thendmarcPolicy, thensenderName, thenautodiscovery, thenaliasOf, so a patch carrying more than one can have an earlier change saved before a later field is refused. Send them in separate calls when any of them has to stand on its own.Every call on a domain whose tracking domain is managed by a different Nextmail server, removal included, gets 409
tracking_host_in_useuntil it is removed on that server. A files domain behaves the same way understorage_host_in_use.A tracking domain and a files domain each apply to every address on the domain, so only a key that holds the whole domain may set one. A key whose
domainAllowlistcontains this domain is allowed through, and any other narrowed key gets 422capability_unsupportedondomainAllowlist. The catch-all, the DMARC policy and the sender name need the whole domain the same way. A body key other thancatchAll,trackingHost,storageHost,dmarcPolicy,senderName,autodiscoveryandaliasOfis a 422unknown_parameter, and acatchAllthat is not a boolean, admarcPolicythat is not one of the three policies, asenderNamethat is neither a string nor nil or runs past 120 characters once trimmed, or a host field that is present but is neither a string nor nil, or runs past 512 characters, is a 422invalid_parameter. A body carrying none of the fields is not an error: it changes nothing and comes back 200.Nextmail keeps checking on its own. A host that has not passed a check yet is checked every 2 minutes in its first hour, every 10 minutes in its first day, hourly in its first week and every 6 hours after that. An active host is checked every 10 minutes, and a failed check on it is retried after 1 minute and then 2. From the third failure in a row the wait starts at 4 minutes and doubles each time, up to an hour.
An active host that fails one or two checks in a row still reads
active, with the reason inerror. It stops being used after the third, or once its last successful check is 2 hours old. New mail then goes back to the default host, andstatusreadsfaileduntil a check passes again.A tracking domain serves only tracking paths and a files domain serves only download paths, and each answers only for mail sent by the workspace that owns it.
Links in mail already sent keep the host they were sent with, and that covers the download link on a file as much as a tracked link. After removing or changing a name, those links work only for as long as the old CNAME record stays in place. Setting a host up again can give it a different
record.value, so publish the one the response reports.An
aliasOfnaming this domain or no other domain hosted in the workspace is a 409alias_not_allowed. One naming a domain that is an alias itself, or set on a domain that other domains are aliases of, is a 409alias_chain, and one set on a domain holding addresses created by hand or routes is a 409alias_has_addresses. Creating an address on an alias is refused withalias_has_addressestoo, and a route on one withalias_not_allowed.Retried automatically on network failure and retryable statuses, since repeating a call that already went through finds the catch-all, the DMARC policy, the sender name, the app setup records and the hosts already set, or already removed, and at most checks a host again.
Also available in
domains.delete
Remove a domain from the workspace
delete(id, confirm: nil, api_key: nil) -> HashRemoves the domain. Mail to it stops being accepted and nothing can be sent from it. Every address on it goes with it, their password sign-ins are revoked, its signing key is released, its tracking and files domains are retired, and the domain.deleted webhook fires. Mail already received stays in the mailbox, unless this is the last domain of the workspace.
Where Nextmail wrote the DNS for this domain itself, it takes those records back, and any it could not take back are listed in leftBehind for you to remove at your DNS provider. Records you published yourself are never touched, so remove them too once the domain is gone.
Removing the last domain of a workspace deletes the whole mailbox with it, every message for good, as removing it in the app does, so it needs confirm:, the name of the domain, the way the app asks the person to type it. mailboxPurged in the result says whether the mailbox went with it.
There is no undo. Adding the domain again starts it from scratch.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.confirmStringThe name of the domain, which removing the last domain of the workspace needs, because that deletes the whole mailbox with it. Letter case and the spaces around it do not matter, and a name that does not match is refused whichever domain it is. Sent as a query parameter.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to domain, id, domain, deleted set to true, mailboxPurged and leftBehind, where mailboxPurged is true when the last domain took the whole mailbox with it and leftBehind lists the DNS records that have to be removed by hand, one line each.
Example
removed = client.domains.delete("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") removed[:leftBehind].each { |line| puts "remove by hand: #{line}" }Notes
The last domain of a workspace without
confirm:is refused with 409last_domainand nothing is removed, and aconfirm:that is not the name of the domain with 422invalid_parameter. A key limited to particular addresses or domains, or an app that was limited to some when it was connected, cannot remove the last domain, because the mailbox holds the mail of every address: 422capability_unsupportedonaddressAllowlist.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.An access token acting for a member also needs
workspace:managein that member's role, as removing one in the app does. It is console-only, so no approval can give it to an app, and without it the call is refused with 403insufficient_authority.The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.
Also available in
domains.get_logo
Read the brand logo of a domain and what public DNS publishes for it
get_logo(id, api_key: nil) -> HashReturns the logo inboxes show next to mail from the domain through BIMI, with its mark certificate and DMARC policy, and asks public DNS what default._bimi.<domain> holds right now: published.ours turns true once the record pointing at the logo is live. For a subdomain, parentDmarc reports the DMARC record of the domain it belongs to, because inboxes show the logo only when its p= and sp= both quarantine or reject at 100 percent.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with url, record, certificate, matchesCertificate and dmarcPolicy, plus published, a Hash with found, ours and value, and parentDmarc, which is nil unless the domain is a subdomain.
Example
logo = client.domains.get_logo("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") puts logo[:url], logo[:published][:ours], logo.dig(:parentDmarc, :enforced)Notes
getandlistcarry the sameurl,record,certificateandmatchesCertificatein each domain'slogo, but onlyget_logoasks public DNS what is published.A domain id from another workspace is a 404, the same as an id that does not exist.
Also available in
domains.set_logo
Upload the brand logo inboxes show for a domain
set_logo(id, body = nil, api_key: nil, **fields) -> HashConverts the SVG to the SVG Tiny PS format inboxes require, replaces any logo the domain had, and publishes the BIMI record where Nextmail writes the DNS for the domain. Inboxes show the logo once dmarcPolicy is quarantine or reject, which update sets, and Gmail also needs a mark certificate from set_logo_certificate.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.svgStringRequiredThe logo as SVG markup, up to 1 MB. A file that is SVG Tiny PS already is kept byte for byte, so it stays the same as the copy inside a mark certificate.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the logo as it stands, with url, record, certificate, matchesCertificate, dmarcPolicy, records and logoFromCertificate. records is published once the BIMI record is in place, manual when you publish record yourself, blocked when a record you published is in the way, and busy or failed when calling again may help.
Example
logo = client.domains.set_logo("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", svg: File.read("logo.svg")) puts logo[:url], logo[:records], logo.dig(:record, :name), logo.dig(:record, :value)Notes
A domain that is not verified is refused with 409
domain_not_verified. Ansvgthat is not SVG, is over 1 MB or uses something inboxes do not draw, such as a bitmap image, a filter or a link to another file, is a 422invalid_parameterwhose message says which.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist. Safe to replay, so the SDK retries it after a network failure.
Also available in
domains.remove_logo
Remove the brand logo of a domain
remove_logo(id, api_key: nil) -> HashRemoves the logo and deletes the stored file, and takes the BIMI record down where Nextmail writes the DNS for the domain. Elsewhere remove the record yourself. Any mark certificate stays, ready for the next logo.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the logo as set_logo returns it, with url and record nil, and records saying what happened to the BIMI record.
Example
logo = client.domains.remove_logo("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") p logo[:url], logo[:records]Notes
A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.Removing a logo from a domain that has none changes nothing, so the SDK retries it after a network failure.
Also available in
domains.set_logo_certificate
Upload the mark certificate for a domain logo
set_logo_certificate(id, body = nil, api_key: nil, **fields) -> HashStores the Verified Mark Certificate (VMC) or Common Mark Certificate (CMC) a certificate authority issued for the domain, replacing any there was, and points the BIMI record at it. Gmail shows the logo only with one and Apple Mail only with a VMC, and when the logo inside the certificate differs from the published one, it becomes the published one and logoFromCertificate is true.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.certificateStringRequiredThe file the certificate authority sent, up to 128 KB: PEM text as it came, which can hold the whole chain, or a DER or PKCS #7 file encoded as base64.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the logo as set_logo returns it, with certificate, a Hash with url, mark, expiresAt, domains and issuer, plus matchesCertificate, records and logoFromCertificate.
Example
logo = client.domains.set_logo_certificate("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", certificate: File.read("certificate.pem")) puts logo.dig(:certificate, :mark), logo.dig(:certificate, :expiresAt), logo[:logoFromCertificate]Notes
A domain that is not verified is refused with 409
domain_not_verified. A file that cannot be read, is over 128 KB, holds no VMC or CMC, was issued for a different domain or has expired is a 422invalid_parameteroncertificatewhose message says which.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist. Safe to replay, so the SDK retries it after a network failure.
Also available in
domains.remove_logo_certificate
Remove the mark certificate of a domain logo
remove_logo_certificate(id, api_key: nil) -> HashRemoves the mark certificate and deletes the stored file, while the logo stays. The BIMI record no longer points at a certificate, so Gmail and Apple Mail stop showing the logo.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the logo as set_logo returns it, with certificate and matchesCertificate nil.
Example
logo = client.domains.remove_logo_certificate("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") p logo[:url], logo[:certificate]Notes
A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.Removing a certificate from a domain that has none changes nothing, so the SDK retries it after a network failure.
Also available in
domains.list_addresses
List one page of the addresses on a domain
list_addresses(id, limit: nil, cursor: nil, api_key: nil) -> Nextmail::PageReturns one page of the addresses on the domain, alphabetically by address, with each one's id, label, enabled and lastReceivedAt. That covers the addresses created by hand or through the API and the ones the catch-all picked up when mail first arrived for them. Disabled addresses are listed. Removed addresses and the catch-all itself are not: the catch-all is receiving.catchAll on the domain.
list_all_addresses collects every page and iterate_addresses walks them lazily.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.limitIntegerPage size, from 1 to 100. The server defaults to 25.
cursorStringThe
next_cursorof the previous page. Leave it out for the first page.api_keyStringOverrides the client's API key for this call only.
Returns
The Nextmail::Page with items, has_more? and next_cursor. Each item is a Hash for one address, shaped like get_address.
Example
page = client.domains.list_addresses("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", limit: 100) page.items.each { |address| puts "#{address[:address]} #{address[:enabled]} #{address[:label]}" }Notes
A narrowed key still sees every address on the domain, the same as
get.A domain id from another workspace is a 404, the same as an id that does not exist.
The cursor is opaque. A cursor this list did not hand out is a 400
invalid_cursor.
Also available in
domains.list_all_addresses
Collect every address on a domain into one array
list_all_addresses(id, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>Walks every page of list_addresses and returns all the addresses on the domain, alphabetically by address. One request per page.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.limitIntegerPage size for each request, from 1 to 100. The server defaults to 25.
cursorStringStarts the walk after this cursor instead of the first page.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Array of Hashes holding every address on the domain, each shaped like get_address.
Example
addresses = client.domains.list_all_addresses("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f")disabled = addresses.reject { |address| address[:enabled] } p disabled.map { |address| address[:address] }Notes
If any page fails the call raises, and the addresses already fetched are discarded.
Also available in
domains.iterate_addresses
Stream the addresses on a domain one at a time
iterate_addresses(id, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>Returns an Enumerator that yields the addresses on the domain one at a time, alphabetically by address, or passes each one to the block you give it, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.limitIntegerPage size for each request, from 1 to 100. The server defaults to 25.
cursorStringStarts the walk after this cursor instead of the first page.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Enumerator of Hashes, one address per step, each shaped like get_address, or yields each one to a block.
Example
client.domains.iterate_addresses("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") do |address| puts "#{address[:address]} #{address[:lastReceivedAt]}"endNotes
Pages are fetched only as the loop reaches them, so an abandoned loop costs only the pages you consumed.
Also available in
domains.create_address
Create an address on a domain
create_address(id, body = nil, api_key: nil, **fields) -> HashCreates an address on the domain, enabled, and returns it. The domain does not have to be verified yet, but the address receives nothing until it is.
When the domain has its catch-all on, the new address starts with the per-address settings of the catch-all, such as its signature and tracking, apart from the privacy settings. They are copied once, not kept in step.
Creating an address that already exists, or one that was removed, is not an error: it comes back enabled, with the label you sent or none, and keeps its id. An address the catch-all picked up becomes one created by hand, so it keeps receiving when the catch-all is turned off.
The address can start with where its mail goes, an expiry and group settings, the same fields update_address takes.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.localPartStringRequiredThe part in front of the @, 1 to 64 characters once trimmed, lower cased. Letters, digits, the backtick and ! # $ % & ' * + / = ? ^ _ { | } ~ - are allowed, and so are dots between them.
*on its own is how the catch-all is written and is refused.labelString or nilA name for the address shown in the app, trimmed, up to 120 characters. Leave it out, or send nil or an empty string, for none.
keepOriginalBooleanTrue keeps every message the address receives byte for byte as it arrived, which
threads.get_raw_messagethen returns. Left out, it stays off for a new address and as it is for one that already exists.destinationStringmailbox, the default, keeps the mail here,webhooksends every message to the endpoint inwebhookId, andgroupsends it to the group members.forwardneeds a forwarding destination that is on, which a new address never has.Nextmail::DOMAIN_ADDRESS_DESTINATIONSholds the values.webhookIdStringA webhook endpoint of this workspace mail goes to, sent with
destination: "webhook". Needsthreads:read.tapWebhookIdsArray<String> or nilUp to 5 webhook endpoints of this workspace that also get every message the address receives. Naming any needs
threads:read.expiresAtString, Time or nilAn RFC 3339 time from 60 seconds to 10 years ahead when the address expires. A Time is sent as a UTC ISO 8601 instant, and a String must already be one. Left out or
nil, it never expires.onExpiryStringstop, the default, switches the address off when it expires and keeps its mail.deleteremoves it and the conversations delivered to it, which needsthreads:write.Nextmail::ADDRESS_EXPIRY_ACTIONSholds the values.groupPostingStringWho may send to a group address:
anyone, the default,membersorworkspace.Nextmail::ADDRESS_GROUP_POSTING_POLICIESholds the values.groupKeepCopyBooleanTrue keeps each message sent to a group in the group address's own mailbox too.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the address as get_address returns it, with its id, address, label and enabled true.
Example
address = client.domains.create_address("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", localPart: "support", label: "Support") puts address[:id], address[:address]Notes
Past the workspace limit on addresses, which rises with the plan, the call is refused with 422
workspace_limit_reached.An endpoint in
webhookIdortapWebhookIdsthat is not in the workspace is a 404webhook_not_found, more than 5 taps a 422too_many_taps, andexpiresAtless than 60 seconds or more than 10 years ahead a 422invalid_parameter.Choosing where the mail goes, or deletion on expiry, with an OAuth access token needs a verification code, as
update_addressdoes, and is refused with 403step_up_requireduntil the app has verified one in the last 60 minutes.step_up_required?on the error says so. An access token acting for a member can only choose where the mail of an address that already exists goes when that member reaches it, or it is refused with 403insufficient_authority. An API key is never asked for a code.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.A domain id from another workspace is a 404, the same as an id that does not exist.
Retried automatically on network failure and retryable statuses, since creating the same address twice leaves one address with the same id.
Also available in
domains.get_address
Read one address on a domain
get_address(id, address_id, api_key: nil) -> HashReturns one address on the domain with its label, enabled, lastReceivedAt and timestamps.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to address, id, domainId, address, localPart, label, photoUrl, enabled, destination, keepOriginal, webhookId, tapWebhookIds, expiresAt, onExpiry, expiredAt, groupPosting, groupKeepCopy, lastReceivedAt, createdAt and updatedAt.
Example
address = client.domains.get_address("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") puts address[:address], address[:enabled], address[:lastReceivedAt]Notes
An address id that is not on this domain, or an address that was removed, is a 404
resource_not_found, and so is a domain from another workspace.
Also available in
domains.update_address
Rename an address, turn it off and on, choose where its mail goes, set when it expires or keep its originals
update_address(id, address_id, patch = nil, api_key: nil, **fields) -> HashChanges the fields you send and leaves the rest alone. label renames the address, and nil or an empty string removes the name. enabled false stops the address taking mail: mail to it is refused while the sending server is still connected, so the sender gets a bounce, and nothing can be sent from it. It keeps its mail, its settings and the people who can reach it, so enabled true picks up where it left off. That is the difference from delete_address.
destination chooses where the mail of the address goes: mailbox keeps a copy here, as an address does by default, and forward only sends it on to the destinations from add_address_forwards, keeping nothing here. forward needs at least one destination that is switched on. webhook sends every message to the endpoint in webhookId and keeps none here, and group sends it to the group members of the address, with groupPosting deciding who may post and groupKeepCopy whether the group keeps a copy. tapWebhookIds copies every message the address receives to up to 5 endpoints as well.
expiresAt gives the address a time to expire: from then on it takes no mail and sends none, and within a minute it is switched off, or deleted with the conversations delivered to it when onExpiry is delete. A later expiresAt, nil, or enabled true turns an expired address back on.
keepOriginal true keeps every message the address receives from then on byte for byte as it arrived, for threads.get_raw_message.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.labelString or nilA new name, trimmed, up to 120 characters.
nilor an empty string removes it.enabledBooleanFalse stops the address taking mail, true takes mail again.
destinationStringmailboxkeeps a copy of the mail here,forwardonly forwards it,webhooksends every message to the endpoint inwebhookIdand keeps none here, andgroupsends it to the group members.Nextmail::DOMAIN_ADDRESS_DESTINATIONSholds the values.keepOriginalBooleanTrue keeps every message the address receives from now on byte for byte as it arrived, which
threads.get_raw_messagethen returns. False stops keeping new ones, and the originals already kept stay with their messages.webhookIdStringA webhook endpoint of this workspace mail goes to, sent with
destination: "webhook"or alone to change the endpoint of an address that already sends to one. Needsthreads:read.tapWebhookIdsArray<String> or nilUp to 5 webhook endpoints of this workspace that also get every message the address receives. Replaces the list, and an empty Array or
nilclears it. Naming any needsthreads:read.expiresAtString, Time or nilAn RFC 3339 time from 60 seconds to 10 years ahead when the address expires. A Time is sent as a UTC ISO 8601 instant, and a String must already be one.
nilclears it, and on an expired address a later time ornilturns it back on.onExpiryStringstop, the default, switches the address off when it expires and keeps its mail.deleteremoves it and the conversations delivered to it, which needsthreads:write.Nextmail::ADDRESS_EXPIRY_ACTIONSholds the values.groupPostingStringWho may send to a group address:
anyone,membersorworkspace.Nextmail::ADDRESS_GROUP_POSTING_POLICIESholds the values.groupKeepCopyBooleanTrue keeps each message sent to a group in the group address's own mailbox too.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the address as get_address returns it after the change.
Example
address = client.domains.update_address("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", enabled: false) puts address[:address], address[:enabled]Notes
A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.A body key that is not one of the fields above is a 422
unknown_parameter.destination: "forward"on an address with no destination switched on is refused with 409forward_requiredondestination.An endpoint in
webhookIdortapWebhookIdsthat is not in the workspace is a 404webhook_not_found, more than 5 taps a 422too_many_taps,expiresAtless than 60 seconds or more than 10 years ahead a 422invalid_parameter, and so iswebhookIdwithout a webhook destination.Sending
destination,webhookIdortapWebhookIds, or choosing deletion on expiry, with an OAuth access token needs a verification code, and is refused with 403step_up_requireduntil the app has verified one in the last 60 minutes.step_up_required?on the error says so. An access token acting for a member can only change where the mail of an address goes when that member reaches it, or it is refused with 403insufficient_authority. An API key is never asked for a code.Retried automatically on network failure and retryable statuses, since the same patch sent twice leaves the same address.
Also available in
domains.set_address_photo
Upload the photo shown for an address
set_address_photo(id, address_id, data, content_type: nil, crop: nil, api_key: nil) -> HashSends the image bytes as the request body, replacing any photo the address had: PNG, JPEG, WebP or GIF up to 100 MB, cropped to a 512 pixel square, stored as JPEG or PNG and shown for the address in Nextmail in place of the domain logo. The type is read from content_type:, or, when that is left out, from data itself: its own content_type, or the extension of its file name for a Pathname, a File or an upload with an original_filename. Without a type the server refuses the bytes with 422 invalid_image.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.dataString, IO or PathnameRequiredThe image: a binary
String, anIOor aPathname.content_typeStringimage/png,image/jpeg,image/webporimage/gif. Required for a binaryString, and for anydatawhose type cannot be read from its owncontent_typeor its file name.cropHashThe part of the image to keep, as a Hash with
:x,:y,:widthand:height, each a fraction of the image from 0 to 1, measured from its top left as it shows upright. Leave it out to keep the whole image. A Hash that lacks one of them or holds anything but numbers raisesArgumentError, and nothing is sent.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the address as get_address returns it, with the new photoUrl.
Example
address = client.domains.set_address_photo( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", File.binread("photo.jpg"), content_type: "image/jpeg") puts address[:photoUrl]Notes
A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.A busy image service answers 503
image_busyand a failed save 502image_not_stored, which the SDK retries like any other retryable status.A
crop:that does not fit inside the image is refused with 422invalid_parameteroncrop.
Also available in
domains.remove_address_photo
Remove the photo of an address
remove_address_photo(id, address_id, api_key: nil) -> HashRemoves the photo of the address and deletes the stored image, so the domain logo is shown for it again.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the address as get_address returns it, with photoUrl nil.
Example
address = client.domains.remove_address_photo("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") p address[:photoUrl]Notes
A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.Removing a photo from an address that has none changes nothing, so the SDK retries it after a network failure.
Also available in
domains.start_gravatar_publish
Start publishing the photo of an address to Gravatar
start_gravatar_publish(id, address_id, api_key: nil) -> HashReturns the url that publishes the photo of the address to Gravatar, so other mail apps and sites show it too. The person the key or app acts for, the workspace owner for an API key, opens it in a browser signed in to Nextmail: Gravatar asks them to sign in to the WordPress.com account that owns the address, and the photo is published when Gravatar sends them back, which takes that signed-in browser session and never this credential.
The link works for 10 minutes. The address needs a photo first, from set_address_photo.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to gravatar_publish, addressId and url, the Gravatar sign-in page.
Example
publish = client.domains.start_gravatar_publish("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") puts "Open #{publish[:url]} to publish the photo"Notes
An address with no photo yet is 409
photo_required, and a server where publishing to Gravatar is not set up answers 503gravatar_not_configured. A domain or an address that does not exist, or was removed, is a 404.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.Not retried by the SDK.
Also available in
- API
POST /domains/{id}/addresses/{addressId}/photo/gravatar- TypeScript
domains.startGravatarPublish()- Python
domains.start_gravatar_publish()- PHP
domains->startGravatarPublish- Go
Domains.StartGravatarPublish- Java
domains().startGravatarPublish- C#
Domains.StartGravatarPublishAsync- CLI
nextmail domains start-gravatar-publish
domains.delete_address
Remove an address from a domain
delete_address(id, address_id, api_key: nil) -> HashRemoves the address. Mail to it is refused from then on, even when the catch-all on the domain is on. Its forwarding stops, its settings are deleted, the people who were given access to it lose that access, and its password sign-in is revoked. Mail it already received stays in the mailbox.
Creating the same address again with create_address brings it back with the same id, enabled, but without its old settings or access.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to address, id, address and deleted set to true.
Example
removed = client.domains.delete_address("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") puts removed[:address], removed[:deleted]Notes
A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.An access token acting for a member also needs
workspace:managein that member's role, as removing one in the app does. It is console-only, so no approval can give it to an app, and without it the call is refused with 403insufficient_authority.The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.
Also available in
domains.list_address_forwards
List where the mail of an address is forwarded
list_address_forwards(id, address_id, api_key: nil) -> HashReturns every place the mail of the address is forwarded to, oldest first, as the Forwarding section of the address in the app lists them. Each destination says whether it is switched on (enabled) and where it stands (status): only a live destination, one that confirmed by email that it wants this mail, receives anything.
destination on the list says whether the address also keeps a copy of its mail here (mailbox) or only forwards it (forward), and max is how many destinations one address may have.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with address, destination, max and the destinations in data, an Array of Hashes.
Example
forwards = client.domains.list_address_forwards("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") forwards[:data].each { |forward| puts "#{forward[:email]} #{forward[:status]}" }Notes
An address id that is not on this domain, or an address that was removed, is a 404
resource_not_found, and so is a domain from another workspace.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's
max_retries:, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.add_address_forwards
Forward the mail of an address to more places
add_address_forwards(id, address_id, body = nil, api_key: nil, **fields) -> HashAdds places the mail of the address goes to, as adding a destination in the app does. Each new destination is sent an email asking it to confirm, and receives nothing until it does, so it comes back pending and turns live once its owner confirms.
An address hosted here, one already on the list, one that would make a loop, one past the limit of 10 and one that refused mail from this workspace before are not added. Each is named in skipped with the reason, and the rest are still added.
The address keeps a copy of its mail here as before. To stop keeping one, set destination to forward with update_address once a destination is switched on.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.emailsArray<String>RequiredThe addresses to forward to, 1 to 10 of them. Each is trimmed and lowercased.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with the destinations added in added, and every address that was not, with the reason, in skipped.
Example
result = client.domains.add_address_forwards( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", emails: ["[email protected]"]) p result[:added].map { |forward| forward[:status] }, result[:skipped]Notes
An address that is switched off is refused with 409
address_disabled. Switch it on withupdate_addressfirst.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist. An access token acting for a member can only change the forwarding of an address that member reaches, 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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK, since a lost attempt may already have asked a destination to confirm.
Also available in
domains.update_address_forward
Pause a forwarding destination or switch it back on
update_address_forward(id, address_id, forward_id, patch = nil, api_key: nil, **fields) -> Hashenabled false pauses the destination: nothing is forwarded to it until it is switched on again. It keeps its confirmation, so switching it back on needs no new one, and switching it on clears the failures recorded against it.
When the last destination that is on is paused, the address goes back to keeping its mail here. destination in the result says where the mail of the address goes now.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.forward_idStringRequiredA destination id from
list_address_forwardsoradd_address_forwards. It has to be a destination of the address named byaddress_id.enabledBooleanRequiredFalse pauses the destination, true switches it back on.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the destination as it is now, with destination for the address.
Example
forward = client.domains.update_address_forward( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", "5e8f1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b", enabled: false) puts forward[:status], forward[:destination]Notes
A destination id that is not on this address is a 404
resource_not_found.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist. An access token acting for a member can only change the forwarding of an address that member reaches, 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.step_up_required?on the error says so. An API key is never asked for a code.Retried automatically on network failure, since the same patch sent twice leaves the same destination.
Also available in
- API
PATCH /domains/{id}/addresses/{addressId}/forwards/{forwardId}- TypeScript
domains.updateAddressForward()- Python
domains.update_address_forward()- PHP
domains->updateAddressForward- Go
Domains.UpdateAddressForward- Java
domains().updateAddressForward- C#
Domains.UpdateAddressForwardAsync- CLI
nextmail domains update-address-forward
domains.delete_address_forward
Stop forwarding to a destination
delete_address_forward(id, address_id, forward_id, api_key: nil) -> HashRemoves the destination, so nothing more is forwarded to it. When it was the last destination that was on, the address goes back to keeping its mail here, and destination in the result says where the mail of the address goes now.
To stop forwarding for a while instead, pause the destination with update_address_forward, which keeps its confirmation.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.forward_idStringRequiredA destination id from
list_address_forwardsoradd_address_forwards. It has to be a destination of the address named byaddress_id.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to address_forward, id, addressId, email, deleted set to true and destination.
Example
removed = client.domains.delete_address_forward( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", "5e8f1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b") puts removed[:email], removed[:destination]Notes
A destination id that is not on this address is a 404
resource_not_found.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist. An access token acting for a member can only change the forwarding of an address that member reaches, 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.step_up_required?on the error says so. An API key is never asked for a code.Not retried by the SDK. Repeating a delete that succeeded is a 404.
Also available in
- API
DELETE /domains/{id}/addresses/{addressId}/forwards/{forwardId}- TypeScript
domains.deleteAddressForward()- Python
domains.delete_address_forward()- PHP
domains->deleteAddressForward- Go
Domains.DeleteAddressForward- Java
domains().deleteAddressForward- C#
Domains.DeleteAddressForwardAsync- CLI
nextmail domains delete-address-forward
domains.resend_address_forward_consent
Ask a forwarding destination to confirm again
resend_address_forward_consent(id, address_id, forward_id, api_key: nil) -> HashSends the confirmation email to the destination once more, for when the first one was lost or ignored. status says what became of the request: sent, already-confirmed when the destination has confirmed and needs nothing, too-soon when the last email went out moments ago, revoked when the destination refused mail from this workspace, and send-failed when the email could not be sent.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.forward_idStringRequiredA destination id from
list_address_forwardsoradd_address_forwards. It has to be a destination of the address named byaddress_id.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with the status of the request.
Example
asked = client.domains.resend_address_forward_consent( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", "5e8f1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b") puts "Wait a moment before asking again." if asked[:status] == "too-soon"Notes
A destination id that is not on this address is a 404
resource_not_found.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist. An access token acting for a member can only change the forwarding of an address that member reaches, 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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK, since every attempt can send an email.
Also available in
- API
POST /domains/{id}/addresses/{addressId}/forwards/{forwardId}/resend- TypeScript
domains.resendAddressForwardConsent()- Python
domains.resend_address_forward_consent()- PHP
domains->resendAddressForwardConsent- Go
Domains.ResendAddressForwardConsent- Java
domains().resendAddressForwardConsent- C#
Domains.ResendAddressForwardConsentAsync- CLI
nextmail domains resend-address-forward-consent
domains.list_address_members
List who can reach an address
list_address_members(id, address_id, api_key: nil) -> HashReturns everybody who can read the mail of the address and how each one reaches it, in via: owner for the owner of the workspace, every-address for a role that reaches every address, whole-domain for a grant of the whole domain named in viaDomain, and direct for a grant of the address itself. Each person appears once.
access is member for somebody who reads and sends from the address and viewer for somebody who only reads it. removable is true for a grant of the address itself that the caller may take back with members.revoke_address, which for a key or an app also takes members:write and no address or domain limit. The others come from the role or a domain grant, and change there. The member who connected a mailbox at the address keeps their grant while they are in the workspace, so theirs is never removable.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with the people in data, an Array of Hashes.
Example
reach = client.domains.list_address_members("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") reach[:data].each { |person| puts "#{person[:email]} #{person[:access]} #{person[:via]}" }Notes
An address id that is not on this domain, or an address that was removed, is a 404
resource_not_found, and so is a domain from another workspace.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's
max_retries:, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.get_address_login
Read the password sign-in of an address
get_address_login(id, address_id, api_key: nil) -> HashSays whether the address has a password of its own, which lets somebody sign in to Nextmail as that address alone and read and send only its mail. login is nil when it has none, and otherwise says who set the password and when, and when it was last used to sign in.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with login, which is nil when the address has no password.
Example
login = client.domains.get_address_login("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70")[:login] puts login ? login[:lastSignedInAt] : "no password"Notes
It needs
members:write, the scope that sets a password, as the app does, rather than a read scope.An address id that is not on this domain, or an address that was removed, is a 404
resource_not_found, and so is a domain from another workspace.A key limited to particular addresses or domains is refused with 422
capability_unsupported. An access token acting for a member can only reach the sign-in of an address that member reaches, or it is refused with 403insufficient_authority.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's
max_retries:, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.set_address_login
Give an address a password, or replace it
set_address_login(id, address_id, body = nil, api_key: nil, **fields) -> HashSets the password somebody uses to sign in to Nextmail as this address alone. Whoever holds it reads and sends only the mail of the address and reaches nothing else in the workspace. Nextmail sends the password to nobody, so hand it over yourself.
Calling it again replaces the password, signs out everybody who signed in with the old one and removes the forwarding destinations they added. created says whether the sign-in is new.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.passwordStringRequiredAt least 8 characters, with a lowercase letter, an uppercase letter, a number and a special character.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the sign-in as get_address_login returns it after the change, plus created.
Example
password = "#{SecureRandom.alphanumeric(16)}-Aa1" result = client.domains.set_address_login( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", password: password) puts result[:created] ? "Sign-in created" : "Password replaced"Notes
A password that misses a rule is a 422
invalid_parameteronpassword. An address that an account on Nextmail already signs in as is refused with 409account_exists, so invite that account to the workspace instead, and an address that is switched off is refused with 409address_unavailable.The first password on a workspace whose plan has no team access is refused with 403
plan_required.A key or an access token has to hold every scope a sign-in for one address may use, or it is refused with 403
insufficient_authority. A key limited to particular addresses or domains is refused with 422capability_unsupported, and an access token acting for a member can only set the password of an address that member reaches withmemberaccess.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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK.
Also available in
domains.delete_address_login
Remove the password sign-in of an address
delete_address_login(id, address_id, api_key: nil) -> HashTakes the password away and signs out everybody who signed in with it. The address, its mail and the people who reach it otherwise stay as they are, and the forwarding destinations added by whoever signed in as the address are removed with it.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to address_login, addressId, address and deleted set to true.
Example
removed = client.domains.delete_address_login("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") puts removed[:address], removed[:deleted]Notes
An address with no password is a 404.
A key limited to particular addresses or domains is refused with 422
capability_unsupported. An access token acting for a member can only reach the sign-in of an address that member reaches, or it is refused with 403insufficient_authority.Not retried by the SDK. Repeating a delete that succeeded is a 404.
Also available in
domains.get_mail_app_settings
Read the mail app settings of an address
get_mail_app_settings(id, address_id, api_key: nil) -> HashReturns what to enter in Apple Mail, Gmail, Outlook, Thunderbird or any other mail app to add the address to it: the IMAP, SMTP and POP3 servers, each with its host, port and security, and the username to sign in with, which is the address itself. Each of those three encrypts the connection from the first byte, so its security is ssl-tls. smtpSubmission is the same SMTP server on port 587 for apps, devices and libraries that only offer STARTTLS: its security is starttls, the connection is upgraded before the sign-in, and it takes the same username and password.
caldav is the server that puts the calendar of the address into Apple Calendar, Thunderbird, DAVx5 on Android or any other CalDAV app, and carddav the one that puts the contacts of the workspace into Apple Contacts or any other CardDAV app. Each has a url to enter, with the same username and password, a principalUrl for apps that ask for the account address on the server, and host, port and security like the others.
protocols says which of these connections the address accepts, as true or false for imap, smtp, pop3, caldav and carddav. update_mail_app_settings changes them.
The password is an app password of the address, such as one create_app_password makes, or the password set_address_login set when the address has a sign-in of its own without two-factor.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to mail_app_settings, address, username, imap, smtp, smtpSubmission and pop3, each a Hash with host, port and security, caldav and carddav with the same three, their url and principalUrl, and protocols.
Example
settings = client.domains.get_mail_app_settings("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") puts "Sign in as #{settings[:username]}"puts "IMAP #{settings[:imap][:host]}:#{settings[:imap][:port]}, SMTP #{settings[:smtp][:host]}:#{settings[:smtp][:port]}"Notes
It takes
threads:readon the address, as the app lets whoever holds an address set up their own mail apps.An address id that is not on this domain, or an address that was removed, is a 404
resource_not_found, and so is a domain from another workspace. An access token acting for a member gets the same 404 for an address that member cannot read.A key or an access token limited to particular addresses or domains reads only the addresses it is limited to, and any other address 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's
max_retries:, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.update_mail_app_settings
Turn mail app connections on or off for an address
update_mail_app_settings(id, address_id, patch = nil, api_key: nil, **fields) -> HashSwitches each kind of connection the address accepts on or off: imap, smtp and pop3 for mail, caldav for its calendar and carddav for contacts. Send only the ones to change, and the rest stay as they are. Every kind is on until it is switched off.
A switched-off kind refuses every sign-in to it, whatever the password, with a message that says it is turned off. Mail apps and calendar or contacts apps that are already connected over it are signed out within minutes. App passwords stay as they are, so switching a kind back on lets them in again.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.imapBooleanIMAP, which keeps folders and read state in step with Nextmail.
smtpBooleanSMTP, for sending from a mail app, on port 465 and on port 587 alike.
pop3BooleanPOP3, for apps that only download the inbox.
caldavBooleanCalDAV, which puts the calendar of the address into calendar apps.
carddavBooleanCardDAV, which puts the contacts of the workspace into contacts apps.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the settings as get_mail_app_settings returns them, with protocols as the switches now stand.
Example
settings = client.domains.update_mail_app_settings( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", pop3: false) p settings[:protocols]Notes
It takes
threads:readon the address as well asdomains:write.Only the workspace owner, or someone whose role manages domains, may change the switches. An access token acting for anyone else is refused with 403
insufficient_authority. An API key acts for the workspace owner.An address id that is not on this domain is a 404
resource_not_found. A key or an access token limited to particular addresses or domains changes only the addresses it is limited to, and any other address is a 404resource_not_found.An unknown field is refused with 422
unknown_parameter, and a value that is not a boolean with 422invalid_parameter.Retried automatically on network failure, since the same patch sent twice leaves the same switches.
Also available in
- API
PATCH /domains/{id}/addresses/{addressId}/mail-apps- TypeScript
domains.updateMailAppSettings()- Python
domains.update_mail_app_settings()- PHP
domains->updateMailAppSettings- Go
Domains.UpdateMailAppSettings- Java
domains().updateMailAppSettings- C#
Domains.UpdateMailAppSettingsAsync- CLI
nextmail domains update-mail-app-settings
domains.get_address_limits
Read the sending and receiving limits of an address
get_address_limits(id, address_id, api_key: nil) -> HashReturns what the address may send and receive, what it has sent and received so far, and when each count goes down.
sending holds hold, the caps perHour, perDay and perMonth on messages, recipientsPerHour, recipientsPerDay and recipientsPerMonth on recipients, recipientsPerMessage, and the lists allowedRecipients and blockedRecipients. receiving holds hold, the caps perHour, perDay and perMonth, the storage quota storageBytes, and allowedSenders. A field is nil until somebody sets it, and nil means the address has no limit of its own there: the plan of the workspace still applies.
usage counts sent, recipients and received for the current clock hour, the last 24 clock hours and the calendar month, all in UTC, and usage[:storage] holds the bytes and messages of the mail the address keeps, counted since storage counting began and without mail routed to a webhook. resets says when each of those counts next goes down. updatedAt is when the limits last changed, or nil while the address has none. update_address_limits changes them.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with addressId, address, sending, receiving, usage with hour, day and month counts and the storage the address keeps, resets and updatedAt.
Example
limits = client.domains.get_address_limits("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") puts "Sent today: #{limits[:usage][:day][:sent]} of #{limits[:sending][:perDay] || "no cap"}"Notes
An address id that is not on this domain, or an address that was removed, is a 404
resource_not_found, and so is a domain from another workspace.A key or an access token limited to particular addresses or domains reads only the addresses it is limited to, and any other address 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
max_retries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.update_address_limits
Change the sending and receiving limits of an address
update_address_limits(id, address_id, patch = nil, api_key: nil, **fields) -> HashSets, changes or clears the limits of the address. Send only the fields to change, inside sending and receiving: a field left out stays as it is, and nil clears it. Caps take whole numbers from 1 to 10,000,000, receiving.storageBytes takes a storage quota from 1 MiB to 1 TiB, and each list takes up to 100 entries, each an exact address ([email protected]), a domain (client.com) or every subdomain of one (*.client.com).
The limits hold on every way mail leaves the address, the API, the SMTP relay, the app, the assistant, forms, broadcasts, automations and bookings alike, and on every way mail arrives. A send over a cap is refused with 429 address_limit_reached, whose param names the cap and whose retryAfterSeconds says when it lifts. A paused address refuses new sends with 429 address_sending_paused and holds queued or scheduled mail until it is resumed, and a disabled one refuses them with 403 address_sending_disabled and fails queued or scheduled mail. Mail that arrives over a receiving cap, or while receiving is paused, is turned away with a temporary bounce, and mail while receiving is disabled, from a sender allowedSenders leaves out, or that would take the address past its storage quota, with a permanent one. Deleting mail for good makes room under the quota again.
Messages count when they are accepted, so a scheduled message counts the moment it is scheduled, and recipients counts every address in to, cc and bcc. A plus tag counts toward the address it belongs to.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.sending.holdString or nilpausedholds sending anddisabledstops it.nilsends as usual.sending.perHourInteger or nilMessages it may send in the current clock hour, in UTC.
sending.perDayInteger or nilMessages it may send in the last 24 clock hours.
sending.perMonthInteger or nilMessages it may send in the calendar month, in UTC.
sending.recipientsPerHourInteger or nilRecipients it may send to in the current clock hour.
sending.recipientsPerDayInteger or nilRecipients it may send to in the last 24 clock hours.
sending.recipientsPerMonthInteger or nilRecipients it may send to in the calendar month.
sending.recipientsPerMessageInteger or nilRecipients one message may have, a 403
too_many_recipientspast it.sending.allowedRecipientsArray<String> or nilThe only recipients it may send to.
nilis anyone, and an empty list nobody.sending.blockedRecipientsArray<String> or nilRecipients it may never send to.
receiving.holdString or nilpausedturns mail away with a temporary bounce anddisabledwith a permanent one.nilreceives as usual.receiving.perHourInteger or nilMessages it accepts in the current clock hour, in UTC.
receiving.perDayInteger or nilMessages it accepts in the last 24 clock hours.
receiving.perMonthInteger or nilMessages it accepts in the calendar month, in UTC.
receiving.storageBytesInteger or nilThe most mail it may keep, in bytes, from 1 MiB (1048576) to 1 TiB (1099511627776). A message that would take it past the quota gets a permanent bounce (5.2.2).
nilremoves the quota.receiving.allowedSendersArray<String> or nilThe only senders it accepts mail from, matched against the From header and the envelope sender.
nilis anyone, and an empty list nobody.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the limits as get_address_limits returns them, as they now stand, with the usage so far.
Example
limits = client.domains.update_address_limits( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", sending: {perDay: 500, blockedRecipients: ["competitor.com"]}, receiving: {allowedSenders: ["*.client.com"]}) p limits[:sending][:perDay]Notes
Only the workspace owner, or someone who reaches the address, may change its limits. An access token acting for anyone else is refused with 403
insufficient_authority. An API key acts for the workspace owner.An address id that is not on this domain is a 404
resource_not_found. A key or an access token limited to particular addresses or domains changes only the addresses it is limited to, and any other address is a 404resource_not_found.An unknown field is refused with 422
unknown_parameter, and a cap outside 1 to 10,000,000, a storage quota outside 1 MiB to 1 TiB, a list longer than 100 or an entry that is not an address or a domain with 422invalid_parameter.Retried automatically on network failure, since the same patch sent twice leaves the same limits.
Also available in
domains.list_app_passwords
List the app passwords of an address
list_app_passwords(id, address_id, api_key: nil) -> HashReturns every app password a mail app can sign in to the address with, newest first. Each one has the name it was given, last4, the last four letters of the password, to tell them apart, owner, the person it signs in as, and origin, which says where it was made: settings in the app, api through create_app_password, and setup-link by opening an emailed setup link, such as one send_mail_app_setup sends.
lastUsedAt and lastUsedProtocol say when an app last signed in with it and over which of imap, smtp, pop3, caldav and carddav, and lastUsedClient names the mail app when it named itself. The passwords themselves are shown only when they are made, and revoked ones are left out.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with the app passwords in data, an Array of Hashes, newest first. Each has object set to app_password, id, name, last4, origin, owner with id, name and email, createdAt, lastUsedAt, lastUsedProtocol and lastUsedClient.
Example
passwords = client.domains.list_app_passwords("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") passwords[:data].each do |password| puts "#{password[:name]} ...#{password[:last4]} #{password.dig(:owner, :email)} #{password[:lastUsedAt] || "never used"}"endNotes
It takes
threads:readon the address, as the app lets whoever holds an address set up their own mail apps. A key or an app that also holdsmembers:write, for the workspace owner or someone whose role manages members, sees the passwords of everyone who holds the address, and any other caller sees only its own.An address id that is not on this domain, or an address that was removed, is a 404
resource_not_found, and so is a domain from another workspace.An app a member connected reaches the addresses that member holds, and a key or an app limited to particular addresses reaches only those. Any other address 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's
max_retries:, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.create_app_password
Create an app password for an address
create_app_password(id, address_id, body = nil, api_key: nil, **fields) -> HashMakes a password a mail app signs in to the address with, using the address as the username, and returns it in password with the server settings in servers. That is the only time the password is shown, so hand it over or store it then.
The password signs in as the caller for this address alone: an API key makes it for the workspace owner, and an access token for the person who connected the app. A mail app using it reaches the mail of the address with what that person may do there, and nothing else in the workspace. It is 16 letters in four groups joined by dashes, and the dashes, or spaces in their place, can be left out when it is typed.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.nameStringRequiredWhat to call the password, such as the device it is for, 1 to 64 characters. It is trimmed.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with the fields list_app_passwords returns for each password, with origin set to api, plus password, shown this once, servers, the settings of the address as get_mail_app_settings returns them, and appleProfile, an Apple configuration profile with the password inside. Saved as a .mobileconfig file and opened on an iPhone, iPad or Mac, the profile adds the address to Mail and its calendar and contacts to Calendar and Contacts in one step, for the connections the address accepts. It holds the password, so keep it like one.
Example
created = client.domains.create_app_password( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", name: "Front desk iPad") puts "Sign in as #{created.dig(:servers, :username)} with #{created[:password]}"puts "IMAP #{created.dig(:servers, :imap, :host)}:#{created.dig(:servers, :imap, :port)}"Notes
One person can hold 20 app passwords for one address, and the 21st is refused with 422
app_password_limit_reached, so revoke one withdelete_app_passwordfirst. An address that only forwards its mail, or is switched off, has no mailbox for a mail app to open and is refused with 422address_has_no_mailbox.A key or an access token limited to particular addresses or domains is refused with 422
capability_unsupported, and so is an app a member connected, because its access token is always limited to the addresses that member reaches.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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK, since a lost attempt may already have made a password. The success status is 201.
Also available in
domains.update_app_password
Rename an app password
update_app_password(id, address_id, password_id, patch = nil, api_key: nil, **fields) -> HashChanges the name shown for the app password, such as when the device it is for changes hands. The password itself stays the same, and a mail app signed in with it stays signed in.
A person renames the app passwords they hold. The workspace owner, and someone whose role manages members, rename anyone's.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.password_idStringRequiredAn app password id from
list_app_passwordsorcreate_app_password. It has to be an app password of the address named byaddress_id.nameStringRequiredThe new name, 1 to 64 characters. It is trimmed.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with the fields list_app_passwords returns for each password, with the new name.
Example
password = client.domains.update_app_password( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", "map_3f9a1c7e5b2d4f6a8c0e1b3d", name: "Reception iPad") puts password[:name], password[:last4]Notes
An app password id that is not on this address, one already revoked, or one held by someone else when the caller cannot manage members, is a 404
resource_not_found.A key or an access token limited to particular addresses or domains is refused with 422
capability_unsupported, and so is an app a member connected, because its access token is always limited to the addresses that member reaches.Retried automatically on network failure, since the same name sent twice leaves the same password.
Also available in
- API
PATCH /domains/{id}/addresses/{addressId}/app-passwords/{passwordId}- TypeScript
domains.updateAppPassword()- Python
domains.update_app_password()- PHP
domains->updateAppPassword- Go
Domains.UpdateAppPassword- Java
domains().updateAppPassword- C#
Domains.UpdateAppPasswordAsync- CLI
nextmail domains update-app-password
domains.delete_app_password
Revoke an app password
delete_app_password(id, address_id, password_id, api_key: nil) -> HashRevokes the app password, so no mail app can sign in with it again, and a mail app that is signed in with it is signed out within minutes. The address, its mail and its other app passwords stay as they are.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.password_idStringRequiredAn app password id from
list_app_passwordsorcreate_app_password. It has to be an app password of the address named byaddress_id.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to app_password, id and deleted set to true.
Example
domain_id = "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f"address_id = "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70"unused = client.domains.list_app_passwords(domain_id, address_id)[:data].select { |password| password[:lastUsedAt].nil? } unused.each { |password| client.domains.delete_app_password(domain_id, address_id, password[:id]) }Notes
An app password id that is not on this address, or one already revoked, is a 404
resource_not_found.A key or an access token limited to particular addresses or domains is refused with 422
capability_unsupported, and so is an app a member connected, because its access token is always limited to the addresses that member reaches.Not retried by the SDK. Repeating a delete that succeeded is a 404.
Also available in
- API
DELETE /domains/{id}/addresses/{addressId}/app-passwords/{passwordId}- TypeScript
domains.deleteAppPassword()- Python
domains.delete_app_password()- PHP
domains->deleteAppPassword- Go
Domains.DeleteAppPassword- Java
domains().deleteAppPassword- C#
Domains.DeleteAppPasswordAsync- CLI
nextmail domains delete-app-password
domains.send_mail_app_setup
Email a mail app setup link for an address
send_mail_app_setup(id, address_id, body = nil, api_key: nil, **fields) -> HashEmails the recipient a link that sets the address up in a mail app. Opening it makes an app password named after the recipient, shows it once with the server settings, and offers a profile that sets up an Apple device in one step. The link works once and expires in three days, at expiresAt.
The app password it makes signs in as the caller, as one from create_app_password does: an API key makes it for the workspace owner, and an access token for the person who connected the app. It then appears in list_app_passwords with origin set to setup-link.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.recipientStringRequiredThe email address to send the link to, such as the person who will use the mail app. It is trimmed and lowercased.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to mail_app_setup, address, recipient and expiresAt, when the link stops working.
Example
setup = client.domains.send_mail_app_setup( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", recipient: "[email protected]") puts "Sent #{setup[:recipient]} a link for #{setup[:address]}, good until #{setup[:expiresAt]}"Notes
When the email cannot be sent the call is a 503
setup_email_not_sentand nothing is made, so it is safe to call again. An address that only forwards its mail, or is switched off, has no mailbox for a mail app to open and is refused with 422address_has_no_mailbox. A workspace can email 50 setup links a day, and past that the call is a 429setup_email_rate_limited.A key or an access token limited to particular addresses or domains is refused with 422
capability_unsupported, and so is an app a member connected, because its access token is always limited to the addresses that member reaches. Only the workspace owner, or someone whose role holdsmembers:write, can send a link, and anyone else 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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK, since every attempt can send an email.
Also available in
domains.create_mail_app_profile_link
Make a link that sets an address up on an Apple device
create_mail_app_profile_link(id, address_id, body = nil, api_key: nil, **fields) -> HashMakes a one-time link that sets the address up on an iPhone, iPad or Mac. Opened there, url downloads an Apple configuration profile with a new app password inside, named name, which signs in as the caller for this address alone: an API key makes it for the workspace owner, and an access token for the person who connected the app. displayName and description are what the device shows for the profile.
The password is made when the link is opened, not before, so nothing appears in list_app_passwords until then. The link works once and stops working at expiresAt, five minutes later, so open it on the device straight away and keep it secret until then: it holds what makes the password.
Besides members:write, the key or access token has to hold itself every mail, calendar and contacts scope the password carries (threads:read, threads:write, emails:send, drafts:write, labels:write, calendar:read, calendar:write, contacts:read and contacts:write, or for an access token those of them its person's role holds). Without one of them the call is refused with 403 insufficient_authority.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.nameStringRequiredWhat to call the app password the link makes, such as the device it is for, 1 to 64 characters. It is trimmed.
displayNameStringRequiredThe name the device shows for the profile, 1 to 160 characters. It is trimmed.
descriptionStringRequiredThe description the device shows for the profile, 1 to 160 characters. It is trimmed.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to mail_app_profile_link, address, url, the link to open on the device, and expiresAt, when it stops working.
Example
link = client.domains.create_mail_app_profile_link( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", name: "Front desk iPad", displayName: "Support mailbox", description: "Mail, calendar and contacts for [email protected]") puts "Open on the device before #{link[:expiresAt]}: #{link[:url]}"Notes
One person can make 10 of these links an hour, and past that the call is a 429
profile_link_rate_limited. An address that only forwards its mail, or is switched off, has no mailbox for a mail app to open and is refused with 422address_has_no_mailbox.A key or an access token limited to particular addresses or domains is refused with 422
capability_unsupported, and so is an app a member connected, because its access token is always limited to the addresses that member reaches.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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically, since every attempt makes a link that can make a password. The success status is 201.
Also available in
- API
POST /domains/{id}/addresses/{addressId}/mail-app-profile-link- TypeScript
domains.createMailAppProfileLink()- Python
domains.create_mail_app_profile_link()- PHP
domains->createMailAppProfileLink- Go
Domains.CreateMailAppProfileLink- Java
domains().createMailAppProfileLink- C#
Domains.CreateMailAppProfileLinkAsync- CLI
nextmail domains create-mail-app-profile-link
domains.get_dns
Read how the DNS of a domain is set up
get_dns(id, refresh: nil, api_key: nil) -> HashReturns whether Nextmail writes the records of the domain itself (managing), through which connection and zone, where each kind of record stands in steps, and the records left behind to delete by hand.
zone says which connected zone answers for the domain: one is resolved, several are ambiguous and need set_dns_zone, none holds it, with the reason, or the connections could not be asked (unusable). The answer is kept for a few minutes, and refresh: true asks the providers again.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.refreshBooleanTrue asks the providers again which zone answers for the domain.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to domain_dns, domainId, domain, managing, connectionId, connection, zoneId, zoneName, zoneHolder, state, steps, leftovers, probe, error, syncedAt and zone.
Example
dns = client.domains.get_dns("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", refresh: true) puts dns[:managing], dns[:state], dns[:zone][:kind]Notes
A domain 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's
max_retries:, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.set_dns_zone
Choose the zone a domain is set up through
set_dns_zone(id, body = nil, api_key: nil, **fields) -> HashAttaches the domain to a zone of a connection, when several connected zones could answer for it. The zone has to cover the domain, be active at the provider and take a test record. Nothing is written yet: call sync_dns to write the records.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.connectionIdStringRequiredThe connection that holds the zone, from
dns_connections.list.zoneIdStringRequiredThe zone, as
zone.candidatesofget_dnslists it.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the DNS setup as get_dns returns it after the change.
Example
dns = client.domains.set_dns_zone( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", connectionId: "dnsl_3f9a1c2e7b4d4e6f8a0b2c3d", zoneId: "8c7e2f1a9b3d4c5e6f7a8b9c0d1e2f3a") puts dns[:zoneName], dns[:state]Notes
A zone that does not cover the domain is a 422
invalid_parameteronzoneId. A domain already set up through another zone is refused with 409dns_zone_conflict, a zone that is not active or refuses the test record with 409dns_zone_unusable, and a connection that was disconnected with 409dns_connection_unusable.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.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.step_up_required?on the error says so. An API key is never asked for a code.Not retried by the SDK.
Also available in
domains.sync_dns
Write the DNS records of a domain
sync_dns(id, body = nil, api_key: nil, **fields) -> HashWrites or repairs every record the domain needs through the connected zone that answers for it, as Sync does in the app. When exactly one zone answers it is attached first, and attached says so. With purpose, only that kind of record is written. A domain that was waiting for its records is verified once they are in place.
When no single zone answers, nothing is written: outcome is refused, message says why and zone shows the zones to choose from with set_dns_zone.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.purposeStringOnly this kind of record:
dmarc,tracking,storage,bimiorapp-host.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with outcome, the provision that ran and the DNS setup as it is now in dns, as get_dns returns it.
Example
sync = client.domains.sync_dns("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") if sync[:outcome] == "refused" puts sync[:message]else p sync.dig(:provision, :written)endNotes
A sync already running on the domain is refused with 409
dns_busy. A provider that refuses the request is a 502dns_provider_error.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.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.step_up_required?on the error says so. An API key is never asked for a code.Not retried by the SDK.
Also available in
domains.list_routes
List one page of the pattern routes of a domain
list_routes(id, limit: nil, cursor: nil, api_key: nil) -> Nextmail::PageReturns one page of the routes of the domain in the order they are tried: lowest priority first, then the longest literal text, then the oldest. A route catches mail to addresses nobody created whose local part matches its pattern, after the addresses that exist and before the catch-all, and active says whether it takes mail now, with the reason in inactiveReason when it does not.
list_all_routes collects every page and iterate_routes walks them lazily.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.limitIntegerPage size, from 1 to 100. The server defaults to 25.
cursorStringThe
next_cursorof the previous page. Leave it out for the first page.api_keyStringOverrides the client's API key for this call only.
Returns
The Nextmail::Page with items, has_more? and next_cursor. Each item is a Hash for one route, shaped like get_route.
Example
page = client.domains.list_routes("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") page.items.each { |route| puts "#{route[:pattern]} #{route[:action]} #{route[:active]}" }Notes
A domain id from another workspace is a 404, the same as an id that does not exist.
The cursor is opaque. A cursor this list did not hand out is a 400
invalid_cursor.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client
max_retries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.list_all_routes
Collect every pattern route of a domain into one array
list_all_routes(id, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>Walks every page of list_routes and returns all the routes of the domain, in the order they are tried. One request per page, and a domain holds at most 100 routes.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.limitIntegerPage size for each request, from 1 to 100. The server defaults to 25.
cursorStringStarts the walk after this cursor instead of the first page.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Array of Hashes holding every route of the domain, each shaped like get_route.
Example
routes = client.domains.list_all_routes("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f")idle = routes.reject { |route| route[:active] } p idle.map { |route| "#{route[:pattern]}: #{route[:inactiveReason]}" }Notes
If any page fails the call raises, and the routes already fetched are discarded.
Also available in
domains.iterate_routes
Stream the pattern routes of a domain one at a time
iterate_routes(id, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>Returns an Enumerator that yields the routes of the domain one at a time, in the order they are tried, or passes each one to the block you give it, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.limitIntegerPage size for each request, from 1 to 100. The server defaults to 25.
cursorStringStarts the walk after this cursor instead of the first page.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Enumerator of Hashes, one route per step, each shaped like get_route, or yields each one to a block.
Example
client.domains.iterate_routes("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f") do |route| puts "#{route[:priority]} #{route[:pattern]} #{route[:action]}"endNotes
Pages are fetched only as the loop reaches them, so an abandoned loop costs only the pages you consumed.
Also available in
domains.create_route
Add a pattern route to a domain
create_route(id, body = nil, api_key: nil, **fields) -> HashAdds a route that catches mail to addresses nobody created whose local part matches pattern, such as support-*, and acts on it. deliver files it at targetAddressId, whose own destination then applies. forward sends it on to forwardTo once that address confirms, so the route reads forwardStatus: "pending" until it does. webhook posts it to webhookId as the email.routed event. rewrite reads it as the same local part on rewriteDomainId, once.
Send the field of the action and leave the other three out. A domain holds at most 100 routes, and a domain that is an alias takes the routes of its primary domain instead.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.patternStringRequiredThe local part to catch, 1 to 64 of the letters a to z, digits,
.,_,-,+and*, with at most three*wildcards. Lowercased, and unique on the domain.actionStringRequireddeliver,forward,webhookorrewrite.Nextmail::ADDRESS_ROUTE_ACTIONSholds the values.targetAddressIdString or nilFor
deliver: an address id of this workspace, on any of its domains.forwardToString or nilFor
forward: an address at another provider, which is asked by email to confirm before it receives anything.webhookIdString or nilFor
webhook: a webhook endpoint id of this workspace.rewriteDomainIdString or nilFor
rewrite: the id of another domain hosted in this workspace.priorityInteger0 to 1000, lowest tried first. Defaults to 100.
enabledBooleanFalse keeps the route without catching mail. Defaults to true.
descriptionString or nilA note for people, up to 200 characters.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the route as it was saved and as get_route returns it, with active and inactiveReason.
Example
route = client.domains.create_route( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", pattern: "support-*", action: "deliver", targetAddressId: "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") puts route[:id], route[:active]Notes
A pattern the domain already routes is a 409
route_pattern_taken, and a pattern outside the rules is a 422invalid_route_pattern. An address, endpoint or domain that is not in the workspace is a 422route_target_not_foundwithparamnaming the field, and a domain holding 100 routes is a 422route_limit_reached.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist. An access token acting for a member needs a member who reaches the whole domain, 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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK, since a lost attempt may already have saved the route or asked a destination to confirm.
Also available in
domains.get_route
Read one pattern route of a domain
get_route(id, route_id, api_key: nil) -> HashReturns the route with what it catches, what it does, and whether it takes mail now in active, with the reason in inactiveReason when it does not. A webhook route whose endpoint was deleted reads webhook_deleted, and a forward route waiting for its destination to confirm reads forward_pending. Nextmail::ADDRESS_ROUTE_INACTIVE_REASONS holds the reasons.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.route_idStringRequiredRoute id from
list_routesorcreate_route, startingrte_. It has to be a route of the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to address_route, id, domainId, domain, pattern, action, priority, enabled, active, inactiveReason, description, targetAddressId, targetAddress, forwardTo, forwardStatus, forwardConfirmedAt, forwardAskedAt, webhookId, rewriteDomainId, rewriteDomain, createdBy, createdAt and updatedAt.
Example
route = client.domains.get_route("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "rte_8f2c1d9a4b7e6f30a5c2d1e9") puts route[:pattern], route[:inactiveReason] || "takes mail"Notes
A route id that is not on this domain 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
max_retries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.update_route
Change a pattern route
update_route(id, route_id, patch = nil, api_key: nil, **fields) -> HashChanges the route. Send only the fields to change. Changing action needs the field of the new action unless the route already holds it, and the fields of the old action are cleared. Sending forwardTo again asks that address to confirm once more when it has not. enabled false keeps the route but stops it catching mail.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.route_idStringRequiredRoute id from
list_routesorcreate_route, startingrte_. It has to be a route of the domain named byid.patternStringThe local part to catch, 1 to 64 of the letters a to z, digits,
.,_,-,+and*, with at most three*wildcards. Lowercased, and unique on the domain.actionStringdeliver,forward,webhookorrewrite.Nextmail::ADDRESS_ROUTE_ACTIONSholds the values.targetAddressIdString or nilFor
deliver: an address id of this workspace, on any of its domains.forwardToString or nilFor
forward: an address at another provider, which is asked by email to confirm before it receives anything.webhookIdString or nilFor
webhook: a webhook endpoint id of this workspace.rewriteDomainIdString or nilFor
rewrite: the id of another domain hosted in this workspace.priorityInteger0 to 1000, lowest tried first.
enabledBooleanFalse keeps the route without catching mail, true lets it catch mail again.
descriptionString or nilA note for people, up to 200 characters.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash, the route as it now stands, shaped like get_route.
Example
route = client.domains.update_route("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "rte_8f2c1d9a4b7e6f30a5c2d1e9", priority: 10) puts route[:priority]Notes
The refusals are those of
create_route, and a route id that is not on this domain is a 404resource_not_found.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK, since sending
forwardToagain sends another email.
Also available in
domains.delete_route
Delete a pattern route
delete_route(id, route_id, api_key: nil) -> HashDeletes the route. Mail it caught then goes to the next route that matches, or to the catch-all.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.route_idStringRequiredRoute id from
list_routesorcreate_route, startingrte_. It has to be a route of the domain named byid.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to address_route, id, domainId, pattern and deleted set to true.
Example
removed = client.domains.delete_route("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "rte_8f2c1d9a4b7e6f30a5c2d1e9") puts removed[:pattern], removed[:deleted]Notes
A route id that is not on this domain is a 404
resource_not_found.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.Not retried by the SDK. Repeating a delete that succeeded is a 404.
Also available in
domains.test_route
Test where mail to an address goes
test_route(id, body = nil, api_key: nil, **fields) -> HashReturns which step decides mail to an address, without sending anything. step is address when an address that exists takes it, alias when the domain is an alias and its primary decides, route when a pattern route catches it, catch_all when the catch-all takes it and none when it would be turned away. Nextmail::ADDRESS_ROUTE_TEST_STEPS holds the values. route is the route that decided, target where the mail would end up, a mailbox, a forward, a webhook or a group with the address it is filed at, and reason why mail would be turned away.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.addressStringRequiredA local part such as
support-eu, read on this domain, or a whole address on this domain or one of its aliases.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to address_route_test, address, step, route (nil, or the route Hash get_route returns), target (nil, or a Hash with kind, addressId, address, forwardTo, forwards and webhookId, where kind is one of Nextmail::DOMAIN_ADDRESS_DESTINATIONS) and reason.
Example
test = client.domains.test_route("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", address: "support-eu") p test[:step], test.dig(:route, :pattern), test.dig(:target, :address)Notes
An address that is not a local part or an address on this domain or one of its aliases is a 422
invalid_parameteronaddress.It reads and changes nothing, so it is retried automatically on network failure and retryable statuses.
Also available in
domains.list_group_members
List one page of the group members of a group address
list_group_members(id, address_id, limit: nil, cursor: nil, api_key: nil) -> Nextmail::PageReturns one page of the group members of the address, oldest first: the addresses of the workspace and the addresses at other providers its mail goes to while its destination is group. These are not the people who can read the address, which list_address_members lists. An outside member reads pending until it confirms, live once it has and refused when it said no, and a member of the workspace reads live, or paused while it is switched off.
list_all_group_members collects every page and iterate_group_members walks them lazily.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.limitIntegerPage size, from 1 to 100. The server defaults to 25.
cursorStringThe
next_cursorof the previous page. Leave it out for the first page.api_keyStringOverrides the client's API key for this call only.
Returns
The Nextmail::Page with items, has_more? and next_cursor. Each item is a Hash with object set to group_member, id, groupAddressId, kind, addressId, address, email, group, status, confirmedAt, askedAt, addedBy and createdAt. kind is one of Nextmail::GROUP_MEMBER_KINDS and status one of Nextmail::ADDRESS_FORWARD_STATUSES.
Example
page = client.domains.list_group_members("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") page.items.each { |member| puts "#{member[:address]} #{member[:status]}" }Notes
An address id that is not on this domain is a 404
resource_not_found.The cursor is opaque. A cursor this list did not hand out is a 400
invalid_cursor.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client
max_retries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
domains.list_all_group_members
Collect every group member of a group address into one array
list_all_group_members(id, address_id, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>Walks every page of list_group_members and returns all the group members of the address, oldest first. One request per page, and a group holds at most 1,000 group members.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.limitIntegerPage size for each request, from 1 to 100. The server defaults to 25.
cursorStringStarts the walk after this cursor instead of the first page.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Array of Hashes holding every group member of the address, each shaped like a list_group_members item.
Example
members = client.domains.list_all_group_members("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70")waiting = members.select { |member| member[:status] == "pending" } p waiting.map { |member| member[:address] }Notes
If any page fails the call raises, and the group members already fetched are discarded.
Also available in
domains.iterate_group_members
Stream the group members of a group address one at a time
iterate_group_members(id, address_id, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>Returns an Enumerator that yields the group members of the address one at a time, oldest first, or passes each one to the block you give it, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.limitIntegerPage size for each request, from 1 to 100. The server defaults to 25.
cursorStringStarts the walk after this cursor instead of the first page.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Enumerator of Hashes, one group member per step, each shaped like a list_group_members item, or yields each one to a block.
Example
client.domains.iterate_group_members("b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70") do |member| puts "#{member[:kind]} #{member[:address]}"endNotes
Pages are fetched only as the loop reaches them, so an abandoned loop costs only the pages you consumed.
Also available in
domains.add_group_members
Add group members to a group address
add_group_members(id, address_id, body = nil, api_key: nil, **fields) -> HashAdds up to 100 group members to the address, each a Hash with addressId for an address of the workspace or with email for an address at another provider. An email hosted in this workspace is added as that address. An outside address is sent an email asking it to confirm and receives nothing until it does, and sending one that has not confirmed yet asks it again.
The address has to be a group address already, so set its destination to group with update_address first. A group holds at most 1,000 group members, and groups nest at most 3 deep. A member already in the group, and an outside address that refused mail from this workspace or whose email could not be sent, comes back in skipped with the reason.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.membersArray<Hash>Required1 to 100 entries, each a Hash with
addressIdfor an address of this workspace or withemailfor an address at another provider.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to group_members, groupAddressId, the group members added in added, each shaped like a list_group_members item, and every entry that was not added in skipped, each a Hash with addressId, email and reason.
Example
result = client.domains.add_group_members( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", members: [{addressId: "5e8f1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b"}, {email: "[email protected]"}]) p result[:added].map { |member| member[:status] }, result[:skipped]Notes
An address that is not a group address is a 409
not_a_group. A group that would hold more than 1,000 group members is a 422group_member_limit, an address that would nest groups more than 3 deep or make the group contain itself is a 422group_nesting_too_deep, and anaddressIdthat is not in the workspace is a 422group_member_not_foundwithparampointing at it.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist. An access token acting for a member can only change a group address that member reaches, 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.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK, since a lost attempt may already have asked an address to confirm.
Also available in
domains.remove_group_member
Remove a group member from a group address
remove_group_member(id, address_id, member_id, api_key: nil) -> HashRemoves one group member, so the mail of the group stops going there. An outside address keeps its confirmation, so adding it back needs no new one.
Parameters
idStringRequiredDomain id from
listorcreate, a UUID.address_idStringRequiredAddress id from
list_addressesorcreate_address, a UUID. It has to be an address on the domain named byid.member_idStringRequiredGroup member id from
list_group_membersoradd_group_members, startinggrm_. It has to be a group member of the address named byaddress_id.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to group_member, id, groupAddressId, address and deleted set to true.
Example
removed = client.domains.remove_group_member( "b3e1f0a4-6c2d-4e8a-9f17-2d5c8a0b4e6f", "7c9d2e41-0b8f-4a63-9e25-1f4d6a8b3c70", "grm_3a7d9c1e5b2f8a4d6c0e1b9f") puts removed[:address], removed[:deleted]Notes
A group member id that is not in this group is a 404
group_member_not_found.A key limited to particular addresses or domains has to hold this whole domain in its
domainAllowlist, or the call is refused with 422capability_unsupportedondomainAllowlist.Not retried by the SDK. Repeating a remove that succeeded is a 404.
Also available in
- API
DELETE /domains/{id}/addresses/{addressId}/group-members/{memberId}- TypeScript
domains.removeGroupMember()- Python
domains.remove_group_member()- PHP
domains->removeGroupMember- Go
Domains.RemoveGroupMember- Java
domains().removeGroupMember- C#
Domains.RemoveGroupMemberAsync- CLI
nextmail domains remove-group-member