> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# AddMailboxRecords

# Package: domains

# Namespace: DomainDns

# Method link: https://dev.wix.com/docs/api-reference/account-level/domains/domain-dns/add-mailbox-records.md

## Permission Scopes:
Manage Domains: SCOPE.ACC-DC-PREMIUM.MANAGE-DOMAINS

## Introduction

Adds mailbox records to a domain's DNS zone, connecting an email provider to the domain.


Specify the records to add in one of these ways:
- `providerId`: ID of a known email provider. The provider's records for the
domain are added, including its `MX` records and any `CNAME`, `TXT`, or `SRV`
records it needs. To retrieve the available providers, call
[List Mailbox Providers](https://dev.wix.com/docs/api-reference/account-level/domains/mailbox-providers/list-mailbox-providers.md).
- `customMailbox`: Records for an email provider that isn't one of the known
providers. Typically, the `MX` records for the provider's mail servers.

If the domain already has a connected email provider, the new provider
replaces it. All existing `MX` records are deleted. If the previous provider
is a known provider, its other records and the `TXT` values it added are also
deleted. To avoid replacing an existing email setup by mistake, call
[Get DNS Zone](https://dev.wix.com/docs/api-reference/account-level/domains/domain-dns/get-dns-zone.md)
first to check the domain's current `MX` records.

Existing `TXT` values that weren't added by the previous provider, such as
SPF values, are kept.

Supports root domains, such as `example.com`. Subdomains, such as
`mail.example.com`, aren't supported.

You can safely retry this method with the same input. Calling it again
writes the same records.

To remove the mailbox records, call
[Delete Mailbox Records](https://dev.wix.com/docs/api-reference/account-level/domains/domain-dns/delete-mailbox-records.md).

> __Important:__ This method requires an account-level API key and can't be authenticated with the standard authorization header.

---

## REST API

### Schema

```
 Method: addMailboxRecords
 Description: Adds mailbox records to a domain's DNS zone, connecting an email provider to the domain.   Specify the records to add in one of these ways: - `providerId`: GUID of a known email provider. The provider's records for the domain are added, including its `MX` records and any `CNAME`, `TXT`, or `SRV` records it needs. To retrieve the available providers, call [List Mailbox Providers](https://dev.wix.com/docs/api-reference/account-level/domains/mailbox-providers/list-mailbox-providers.md). - `customMailbox`: Records for an email provider that isn't one of the known providers. Typically, the `MX` records for the provider's mail servers.  If the domain already has a connected email provider, the new provider replaces it. All existing `MX` records are deleted. If the previous provider is a known provider, its other records and the `TXT` values it added are also deleted. To avoid replacing an existing email setup by mistake, call [Get DNS Zone](https://dev.wix.com/docs/api-reference/account-level/domains/domain-dns/get-dns-zone.md) first to check the domain's current `MX` records.  Existing `TXT` values that weren't added by the previous provider, such as SPF values, are kept.  Supports root domains, such as `example.com`. Subdomains, such as `mail.example.com`, aren't supported.  You can safely retry this method with the same input. Calling it again writes the same records.  To remove the mailbox records, call [Delete Mailbox Records](https://dev.wix.com/docs/api-reference/account-level/domains/domain-dns/delete-mailbox-records.md).  > __Important:__ This method requires an account-level API key and can't be authenticated with the standard authorization header.
 URL: https://www.wixapis.com/domains/v1/dns-zones/{domainName}/mailbox-records
 Method: POST
 Method parameters:
    - ONE-OF: 
     - name: providerId | type: integer | description: GUID of the email provider to connect. To retrieve the available providers and their GUIDs, call [List Mailbox Providers](https://dev.wix.com/docs/api-reference/account-level/domains/mailbox-providers/list-mailbox-providers.md).  
     - name: customMailbox | type: CustomMailbox | description: Mailbox records for an email provider that isn't one of the known providers.  
        - name: records | type: array<DnsRecord> | description: Mailbox records to add. Typically, the `MX` records for the email provider's mail servers.  | validation: minItems 1, maxItems 50
           - name: type | type: RecordType | description: [DNS record type](https://en.wikipedia.org/wiki/List_of_DNS_record_types).  
                 - enum:
                 -     UNKNOWN: Default value. Used in case the record type isn't known. You can't set a record type to `UNKNOWN`.
                 -     A: Address record. Most fundamental type of DNS record that indicates the IP address of a given domain.
                 -     AAAA: Address record in [IPv6 format](https://en.wikipedia.org/wiki/IPv6).
                 -     NS: Name server record. Describes which server contains the actual DNS record.
                 -     SOA: [Start of authority record](https://en.wikipedia.org/wiki/SOA_record). Holds administrative information about the zone.
                 -     CNAME: [CNAME record](https://en.wikipedia.org/wiki/CNAME_record). Maps an alias name to the canonical domain name.
                 -     MX: MX record. Directs emails to mail servers.
                 -     TXT: [TXT record](https://en.wikipedia.org/wiki/TXT_record). Used by domain admins to add human-readable descriptions.
                 -     SPF: SPF record. Used for email authentication.
                 -     SRV: [Service record](https://en.wikipedia.org/wiki/SRV_record). Defines the server location.
                 -     PTR: Pointer record. Specifies which host is supported for a given IP address.
                 -     NAPTR: [Name Authority Pointer record](https://en.wikipedia.org/wiki/NAPTR_record). Used by Internet telephony applications.
           - name: hostName | type: string | description: Host name the record applies to. Can be the domain itself or a subdomain. For example, `example.com` or `mail.example.com`.  | validation: maxLength 256
           - name: ttl | type: integer | description: [Time to live](https://en.wikipedia.org/wiki/Time_to_live) in seconds.  
           - name: values | type: array<string> | description: DNS record values.  External DNS providers may support a different maximum number of values for a record type. These external limits aren't validated.  | validation: minItems 1, maxItems 50, maxLength 1000
 Return type: AddMailboxRecordsResponse
  - name: dnsZone | type: DnsZone | description: Updated DNS zone, including the added mailbox records.  
     - name: domainName | type: string | description: Domain name including the TLD. Both root domains and subdomains are supported.  | validation: format HOSTNAME
     - name: records | type: array<DnsRecord> | description: DNS records. A DNS zone holds a single record per DNS record type. To specify multiple values for the same record type, add them to that record's `values` array.  A DNS zone must include at least an `NS` record and an `SOA` record.  | validation: minItems 2, maxItems 5000
        - name: type | type: RecordType | description: [DNS record type](https://en.wikipedia.org/wiki/List_of_DNS_record_types).  
             - enum:
             -     UNKNOWN: Default value. Used in case the record type isn't known. You can't set a record type to `UNKNOWN`.
             -     A: Address record. Most fundamental type of DNS record that indicates the IP address of a given domain.
             -     AAAA: Address record in [IPv6 format](https://en.wikipedia.org/wiki/IPv6).
             -     NS: Name server record. Describes which server contains the actual DNS record.
             -     SOA: [Start of authority record](https://en.wikipedia.org/wiki/SOA_record). Holds administrative information about the zone.
             -     CNAME: [CNAME record](https://en.wikipedia.org/wiki/CNAME_record). Maps an alias name to the canonical domain name.
             -     MX: MX record. Directs emails to mail servers.
             -     TXT: [TXT record](https://en.wikipedia.org/wiki/TXT_record). Used by domain admins to add human-readable descriptions.
             -     SPF: SPF record. Used for email authentication.
             -     SRV: [Service record](https://en.wikipedia.org/wiki/SRV_record). Defines the server location.
             -     PTR: Pointer record. Specifies which host is supported for a given IP address.
             -     NAPTR: [Name Authority Pointer record](https://en.wikipedia.org/wiki/NAPTR_record). Used by Internet telephony applications.
        - name: hostName | type: string | description: Host name the record applies to. Can be the domain itself or a subdomain. For example, `example.com` or `mail.example.com`.  | validation: maxLength 256
        - name: ttl | type: integer | description: [Time to live](https://en.wikipedia.org/wiki/Time_to_live) in seconds.  
        - name: values | type: array<string> | description: DNS record values.  External DNS providers may support a different maximum number of values for a record type. These external limits aren't validated.  | validation: minItems 1, maxItems 50, maxLength 1000
     - name: id | type: string | description: DNS zone GUID. Identical to the domain name, including the TLD.  | read-only: true | validation: format HOSTNAME
     - name: dnssecEnabled | type: boolean | description: Whether [DNS Security Extensions (DNSSEC)](https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions) are enabled.  Default: `false`  
     - name: dnssecInfo | type: DnssecInfo | description: Information about [DNSSEC](https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions).  Returned only when `dnssecEnabled` is `true`.  | read-only: true 
        - name: keyTag | type: integer | description: Unique 16-bit identifier for a [DNSKEY](https://cloud.google.com/dns/docs/reference/rest/v1/dnsKeys) record that allows efficient DNSSEC validation in zones with multiple keys.  | validation: minimum 0, maximum 65535
        - name: digest | type: string | description: Cryptographic hash of the [DNSKEY](https://cloud.google.com/dns/docs/reference/rest/v1/dnsKeys) record that's included in the delegation signer (DS) record and ensures secure DNSSEC validation.  | validation: maxLength 128


```

### Examples

### Connect Google Workspace to a domain
Adds the mailbox records of a known email provider by its ID.

```curl
curl -X POST \
'https://www.wixapis.com/domains/v1/dns-zones/mydomain.com/mailbox-records' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "providerId": 3
}'
```

### Add custom mailbox records
Adds MX records for an email provider that isn't one of the known providers.

```curl
curl -X POST \
'https://www.wixapis.com/domains/v1/dns-zones/mydomain.com/mailbox-records' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "customMailbox": {
    "records": [
      {
        "type": "MX",
        "hostName": "mydomain.com",
        "ttl": 3600,
        "values": [
          "10 mx1.examplemail.com",
          "20 mx2.examplemail.com"
        ]
      }
    ]
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.domains.domainDns.addMailboxRecords(domainName, options)
 Description: Adds mailbox records to a domain's DNS zone, connecting an email provider to the domain.   Specify the records to add in one of these ways: - `providerId`: GUID of a known email provider. The provider's records for the domain are added, including its `MX` records and any `CNAME`, `TXT`, or `SRV` records it needs. To retrieve the available providers, call [List Mailbox Providers](https://dev.wix.com/docs/api-reference/account-level/domains/mailbox-providers/list-mailbox-providers.md). - `customMailbox`: Records for an email provider that isn't one of the known providers. Typically, the `MX` records for the provider's mail servers.  If the domain already has a connected email provider, the new provider replaces it. All existing `MX` records are deleted. If the previous provider is a known provider, its other records and the `TXT` values it added are also deleted. To avoid replacing an existing email setup by mistake, call [Get DNS Zone](https://dev.wix.com/docs/api-reference/account-level/domains/domain-dns/get-dns-zone.md) first to check the domain's current `MX` records.  Existing `TXT` values that weren't added by the previous provider, such as SPF values, are kept.  Supports root domains, such as `example.com`. Subdomains, such as `mail.example.com`, aren't supported.  You can safely retry this method with the same input. Calling it again writes the same records.  To remove the mailbox records, call [Delete Mailbox Records](https://dev.wix.com/docs/api-reference/account-level/domains/domain-dns/delete-mailbox-records.md).  > __Important:__ This method requires an account-level API key and can't be authenticated with the standard authorization header.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  domainName
 Method parameters: 
   param name: domainName | type: string | description: Root domain to add the mailbox records to, including the TLD. For example, `example.com`. | required: true | validation: format HOSTNAME
   param name: options | type: AddMailboxRecordsOptions  none  
    - ONE-OF: 
     - name: providerId | type: integer | description: GUID of the email provider to connect. To retrieve the available providers and their GUIDs, call [List Mailbox Providers](https://dev.wix.com/docs/api-reference/account-level/domains/mailbox-providers/list-mailbox-providers.md).  
     - name: customMailbox | type: CustomMailbox | description: Mailbox records for an email provider that isn't one of the known providers.  
        - name: records | type: array<DnsRecord> | description: Mailbox records to add. Typically, the `MX` records for the email provider's mail servers.  | validation: minItems 1, maxItems 50
           - name: type | type: RecordType | description: [DNS record type](https://en.wikipedia.org/wiki/List_of_DNS_record_types).  
                 - enum:
                 -     UNKNOWN: Default value. Used in case the record type isn't known. You can't set a record type to `UNKNOWN`.
                 -     A: Address record. Most fundamental type of DNS record that indicates the IP address of a given domain.
                 -     AAAA: Address record in [IPv6 format](https://en.wikipedia.org/wiki/IPv6).
                 -     NS: Name server record. Describes which server contains the actual DNS record.
                 -     SOA: [Start of authority record](https://en.wikipedia.org/wiki/SOA_record). Holds administrative information about the zone.
                 -     CNAME: [CNAME record](https://en.wikipedia.org/wiki/CNAME_record). Maps an alias name to the canonical domain name.
                 -     MX: MX record. Directs emails to mail servers.
                 -     TXT: [TXT record](https://en.wikipedia.org/wiki/TXT_record). Used by domain admins to add human-readable descriptions.
                 -     SPF: SPF record. Used for email authentication.
                 -     SRV: [Service record](https://en.wikipedia.org/wiki/SRV_record). Defines the server location.
                 -     PTR: Pointer record. Specifies which host is supported for a given IP address.
                 -     NAPTR: [Name Authority Pointer record](https://en.wikipedia.org/wiki/NAPTR_record). Used by Internet telephony applications.
           - name: hostName | type: string | description: Host name the record applies to. Can be the domain itself or a subdomain. For example, `example.com` or `mail.example.com`.  | validation: maxLength 256
           - name: ttl | type: integer | description: [Time to live](https://en.wikipedia.org/wiki/Time_to_live) in seconds.  
           - name: values | type: array<string> | description: DNS record values.  External DNS providers may support a different maximum number of values for a record type. These external limits aren't validated.  | validation: minItems 1, maxItems 50, maxLength 1000
 Return type: PROMISE<AddMailboxRecordsResponse>
  - name: dnsZone | type: DnsZone | description: Updated DNS zone, including the added mailbox records.  
     - name: domainName | type: string | description: Domain name including the TLD. Both root domains and subdomains are supported.  | validation: format HOSTNAME
     - name: records | type: array<DnsRecord> | description: DNS records. A DNS zone holds a single record per DNS record type. To specify multiple values for the same record type, add them to that record's `values` array.  A DNS zone must include at least an `NS` record and an `SOA` record.  | validation: minItems 2, maxItems 5000
        - name: type | type: RecordType | description: [DNS record type](https://en.wikipedia.org/wiki/List_of_DNS_record_types).  
             - enum:
             -     UNKNOWN: Default value. Used in case the record type isn't known. You can't set a record type to `UNKNOWN`.
             -     A: Address record. Most fundamental type of DNS record that indicates the IP address of a given domain.
             -     AAAA: Address record in [IPv6 format](https://en.wikipedia.org/wiki/IPv6).
             -     NS: Name server record. Describes which server contains the actual DNS record.
             -     SOA: [Start of authority record](https://en.wikipedia.org/wiki/SOA_record). Holds administrative information about the zone.
             -     CNAME: [CNAME record](https://en.wikipedia.org/wiki/CNAME_record). Maps an alias name to the canonical domain name.
             -     MX: MX record. Directs emails to mail servers.
             -     TXT: [TXT record](https://en.wikipedia.org/wiki/TXT_record). Used by domain admins to add human-readable descriptions.
             -     SPF: SPF record. Used for email authentication.
             -     SRV: [Service record](https://en.wikipedia.org/wiki/SRV_record). Defines the server location.
             -     PTR: Pointer record. Specifies which host is supported for a given IP address.
             -     NAPTR: [Name Authority Pointer record](https://en.wikipedia.org/wiki/NAPTR_record). Used by Internet telephony applications.
        - name: hostName | type: string | description: Host name the record applies to. Can be the domain itself or a subdomain. For example, `example.com` or `mail.example.com`.  | validation: maxLength 256
        - name: ttl | type: integer | description: [Time to live](https://en.wikipedia.org/wiki/Time_to_live) in seconds.  
        - name: values | type: array<string> | description: DNS record values.  External DNS providers may support a different maximum number of values for a record type. These external limits aren't validated.  | validation: minItems 1, maxItems 50, maxLength 1000
     - name: _id | type: string | description: DNS zone GUID. Identical to the domain name, including the TLD.  | read-only: true | validation: format HOSTNAME
     - name: dnssecEnabled | type: boolean | description: Whether [DNS Security Extensions (DNSSEC)](https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions) are enabled.  Default: `false`  
     - name: dnssecInfo | type: DnssecInfo | description: Information about [DNSSEC](https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions).  Returned only when `dnssecEnabled` is `true`.  | read-only: true 
        - name: keyTag | type: integer | description: Unique 16-bit identifier for a [DNSKEY](https://cloud.google.com/dns/docs/reference/rest/v1/dnsKeys) record that allows efficient DNSSEC validation in zones with multiple keys.  | validation: minimum 0, maximum 65535
        - name: digest | type: string | description: Cryptographic hash of the [DNSKEY](https://cloud.google.com/dns/docs/reference/rest/v1/dnsKeys) record that's included in the delegation signer (DS) record and ensures secure DNSSEC validation.  | validation: maxLength 128


```

### Examples

### Add custom mailbox records
Adds MX records for an email provider that isn't one of the known providers.

```javascript
import { domainDns } from "@wix/domains";

async function addMailboxRecords() {
  const response = await domainDns.addMailboxRecords("mydomain.com", {
    "customMailbox": {
      "records": [
        {
          "type": "MX",
          "hostName": "mydomain.com",
          "ttl": 3600,
          "values": [
            "10 mx1.examplemail.com",
            "20 mx2.examplemail.com"
          ]
        }
      ]
    }
  });
}

/* Promise resolves to:
 * {
 *   "dnsZone": {
 *     "domainName": "mydomain.com",
 *     "records": [
 *       {
 *         "type": "A",
 *         "hostName": "mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "185.230.63.171",
 *           "185.230.63.186",
 *           "185.230.63.107"
 *         ]
 *       },
 *       {
 *         "type": "NS",
 *         "hostName": "mydomain.com",
 *         "ttl": 86400,
 *         "values": [
 *           "ns8.wixdns.net",
 *           "ns9.wixdns.net"
 *         ]
 *       },
 *       {
 *         "type": "SOA",
 *         "hostName": "mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "ns8.wixdns.net. support.wix.com. 2026120301 10800 3600 604800 3600"
 *         ]
 *       },
 *       {
 *         "type": "CNAME",
 *         "hostName": "www.mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "cdn1.wixdns.net"
 *         ]
 *       },
 *       {
 *         "type": "MX",
 *         "hostName": "mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "10 mx1.examplemail.com",
 *           "20 mx2.examplemail.com"
 *         ]
 *       }
 *     ],
 *     "dnssecEnabled": false,
 *     "_id": "mydomain.com"
 *   }
 * }
 */

```

### Connect Google Workspace to a domain
Adds the mailbox records of a known email provider by its ID.

```javascript
import { domainDns } from "@wix/domains";

async function addMailboxRecords() {
  const response = await domainDns.addMailboxRecords("mydomain.com", { providerId: 3 });
}

/* Promise resolves to:
 * {
 *   "dnsZone": {
 *     "domainName": "mydomain.com",
 *     "records": [
 *       {
 *         "type": "A",
 *         "hostName": "mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "185.230.63.171",
 *           "185.230.63.186",
 *           "185.230.63.107"
 *         ]
 *       },
 *       {
 *         "type": "NS",
 *         "hostName": "mydomain.com",
 *         "ttl": 86400,
 *         "values": [
 *           "ns8.wixdns.net",
 *           "ns9.wixdns.net"
 *         ]
 *       },
 *       {
 *         "type": "SOA",
 *         "hostName": "mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "ns8.wixdns.net. support.wix.com. 2026120301 10800 3600 604800 3600"
 *         ]
 *       },
 *       {
 *         "type": "CNAME",
 *         "hostName": "www.mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "cdn1.wixdns.net"
 *         ]
 *       },
 *       {
 *         "type": "MX",
 *         "hostName": "mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "10 aspmx.l.google.com",
 *           "20 alt1.aspmx.l.google.com",
 *           "30 alt2.aspmx.l.google.com",
 *           "40 alt3.aspmx.l.google.com",
 *           "50 alt4.aspmx.l.google.com"
 *         ]
 *       },
 *       {
 *         "type": "TXT",
 *         "hostName": "mydomain.com",
 *         "ttl": 3600,
 *         "values": [
 *           "v=spf1 include:_spf.google.com ~all"
 *         ]
 *       }
 *     ],
 *     "dnssecEnabled": false,
 *     "_id": "mydomain.com"
 *   }
 * }
 */

```

### addMailboxRecords (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { domainDns } from '@wix/domains';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { domainDns },
  // Include the auth strategy and host as relevant
});


async function addMailboxRecords(domainName,options) {
  const response = await myWixClient.domainDns.addMailboxRecords(domainName,options);
};
```

---