With the Domain DNS API you can manage DNS zones in Google's Cloud DNS. This allows you to connect domains that you've registered through Wix to non-Wix websites. You can also use the Domain DNS API to manage DNS records for external domains that are connected by nameservers to Wix sites.
Using the Domain DNS API you can:
Learn more about:
It’s important to note the following points before starting to code:
com
, net
, or org
.This article shares a possible use case your implementation could support, as well as a sample flow. You're not limited to this use case, but it can be a helpful jumping off point for your planning.
You can update the MX and TXT records for a domain purchased through Wix, and connect it to an external (non-Wix) site.
To update the DNS records for a domain:
You could help Wix site owners connect an external domain by nameservers to their site. Note that you can't use Update DNS Zone for external domains that are connected by pointing.
To connect an external domain by nameservers to a Wix site:
{"connectionType": "NAMESERVERS"}
.connectedDomainSetupInfo.pointingRecords.aRecord.values
and connectedDomainSetupInfo.pointingRecords.cnameRecord.value
.dnsPropagationStatus
and confirm that it
changes to "COMPLETED"
.This article outlines error messages that might be issued when calling endpoints of the Domain DNS API.
Create DNS Zone might issue the following error messages:
HTTP status | Error code | Error message | Troubleshooting |
---|---|---|---|
NOT_FOUND (404) | USER_ID_NOT_FOUND | User id not found in request context. | Make sure to pass the correct authorization header. |
NOT_FOUND (404) | TARGET_ACCOUNT_NOT_FOUND | Target account id not found in request context. | Make sure to pass the correct account ID in the header of the call. |
NOT_FOUND (404) | DNS_ZONE_NOT_FOUND | No dns zone found for domain name <domainName> . | You must pass a dnsZone object when setting up a DNS zone in Google's Cloud DNS. |
FAILED_PRECONDITION (428) | DOMAIN_NOT_PERMITTED | Domain <domain> is not permitted to target account. | Make sure to pass the correct account ID in the header of the call. The target account must also have a Premium subscription that allows connecting a domain with the chosen TLD. See the Resellers API for more information. |
FAILED_PRECONDITION (428) | DOMAIN_ALREADY_EXISTS | Domain <domain> already exists. | You can create a DNS zone in Google's Cloud DNS that already exists. |
FAILED_PRECONDITION (428) | DOMAIN_DNS_EMPTY_RECORD_VALUE | Value of record <recordType> is empty. | You must pass values for each DNS record that you want to specify in Google's Cloud DNS. |
FAILED_PRECONDITION (428) | DOMAIN_MX_RECORD_VALUE_INVALID | Value of MX record <value> is invalid, it should start with a priority and then the mail server, for example "5 aspmx.l.google.com" . | Make sure to use this format "5 aspmx.l.google.com" when specifying the value of an MX record in Google's Cloud DNS. |
FAILED_PRECONDITION (428) | DOMAIN_CNAME_RECORD_HOSTNAME_INVALID | Host name of the CNAME record $value is invalid, it should end with the domain name but not equal to it, for example "en.domain.com" . | Make sure to use this format "en.domain.com" when specifying the value of a CNAME record in Google's Cloud DNS. |
FAILED_PRECONDITION (428) | DOMAIN_MX_RECORD_VALUE_INVALID | Multiple <recordType> records with the same hostName <hostName> not supported, the multiple values belong to the same hostName should be combined under one <recordType> . | Make sure that you pass all DNS record values that belong to the same type in a single values array of the relevant records.type object. You can't pass multiple record objects with the same record type . |
Update DNS Zone might issue the following error messages:
HTTP status | Error code | Error message | Troubleshooting |
---|---|---|---|
NOT_FOUND (404) | USER_ID_NOT_FOUND | User id not found in request context. | Make sure to pass the correct authorization header. |
NOT_FOUND (404) | TARGET_ACCOUNT_NOT_FOUND | Target account id not found in request context. | Make sure to pass the correct account ID in the header of the call. |
FAILED_PRECONDITION (428) | DOMAIN_NOT_PERMITTED | Domain <domain> is not permitted to target account. | Make sure to pass the correct account ID in the header of the call. The target account must also have a Premium subscription that allows connecting a domain with the chosen TLD. See the Resellers API for more information. |
FAILED_PRECONDITION (428) | DOMAIN_DNS_EMPTY_RECORD_VALUE | Value of record <recordType> is empty. | You must pass at least one value for each DNS record type that you want to specify in Google's Cloud DNS. |
FAILED_PRECONDITION (428) | DOMAIN_MX_RECORD_VALUE_INVALID | Value of MX record <value> is invalid, it should start with a priority and then the mail server, for example "5 aspmx.l.google.com" . | Make sure to use this format: "5 aspmx.l.google.com" , when specifying the value of an MX record in Google's Cloud DNS. |
FAILED_PRECONDITION (428) | DOMAIN_CNAME_RECORD_HOSTNAME_INVALID | Host name of the CNAME record $value is invalid, it should end with the domain name but not equal to it, for example "en.domain.com" . | Make sure to use this format: "en.domain.com" , when specifying the value of a CNAME record in Google's Cloud DNS. |
FAILED_PRECONDITION (428) | DOMAIN_MX_RECORD_VALUE_INVALID | Multiple <recordType> records with the same hostName <hostName> not supported, the multiple values belong to the same hostName should be combined under one <recordType> . | Make sure that you pass all DNS record values that belong to the same DNS record type in the values array of the relevant record object. You can't pass multiple record objects that have the same record type . |
DNS zones hold information about the records that map a domain's URL to an IP address.
Domain name including the TLD. Both root domains and subdomains are supported.
DNS records. You can only set up a single record
object per DNS record
type. If you want to specify multiple values for the same record type, you
must save them in the values
for the relevant type.
Min: 2 DNS record - a DNS zone file has to have at least two required DNS records: NS and SOA records Max: 5000 DNS records
ID of the Dns Zone. Identical to the domain name including TLD.
Whether DNS Security Extensions (DNSSEC) are enabled.
Default: false
Information about DNSSEC.
Available only if {"dnssecEnabled": true}
.
Creates a DNS zone in Google's Cloud DNS.
If there is an existing DNS zone for the domain, it's deleted before the new zone is created.
The call is synchronous, that means it fails in case of an error on Google's side.
You can only set up a single record
object per DNS record
type. If you want to specify multiple values for the same record type, you
must save them in the values
for the relevant type.
Important: This call requires an account level API key and cannot be authenticated with the standard authorization header.
DNS zone to create.
Created DNS zone.
curl -X POST
'https://www.wixapis.com/domains/v1/dns-zones' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'Authorization: <AUTH>' \
-d '{
"dnsZone": {
"records": [
{
"values": [
"10 aspmx.l.google.com"
],
"ttl": 3600,
"hostName": "mysite.com",
"type": "MX"
}
],
"domainName": "mysite.com"
}
}'
{
"dnsZone": {
"records": [
{
"values": ["10 aspmx.l.google.com"],
"ttl": 3600,
"hostName": "mysite.com",
"type": "MX"
}
],
"domainName": "mysite.com"
}
}
Retrieves the DNS zone belonging to the domain from Google's Cloud DNS.
Important: This call requires an account level API key and cannot be authenticated with the standard authorization header.
Domain to retrieve the DNS zone for.
Retrieved DNS zone.
curl -X GET
'https://www.wixapis.com/domains/v1/dns-zones/primarydemo.xyz' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'Authorization: <AUTH>' \
{
"dnsZone": {
"domainName": "primarydemo.xyz.",
"records": [
{
"type": "A",
"hostName": "primarydemo.xyz",
"ttl": 3600,
"values": ["185.230.63.171", "185.230.63.186", "185.230.63.107"]
},
{
"type": "NS",
"hostName": "primarydemo.xyz",
"ttl": 86400,
"values": ["ns8.wixdns.net", "ns9.wixdns.net"]
},
{
"type": "SOA",
"hostName": "primarydemo.xyz",
"ttl": 3600,
"values": [
"ns8.wixdns.net. support.wix.com. 2023112220 10800 3600 604800 3600"
]
},
{
"type": "CNAME",
"hostName": "www.primarydemo.xyz",
"ttl": 3600,
"values": ["cdn1.wixdns.net"]
}
],
"id": "primarydemo.xyz.",
"dnssecEnabled": true,
"dnssecInfo": {
"keyTag": 8494,
"digest": "14AECDC8B7E9FDB42AF08A8A55B1E8A9DEA5FC348B1F517026E40B8ACA5F1830"
}
}
}
Deletes a DNS zone in Google's Cloud DNS.
The call is synchronous, that means it fails in case of an error on Google's side.
Important: This call requires an account level API key and cannot be authenticated with the standard authorization header.
Domain name to delete the DNS zone for.
curl -X DELETE
'https://www.wixapis.com/domains/v1/dns-zones/mysite.com' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'Authorization: <AUTH>' \
{}
Adds DNS records to and removes DNS records from a DNS zone in Google's Cloud DNS.
The call is synchronous, that means it fails in case of an error on Google's side.
You can only set up a single record
object per DNS record
type. If you want to specify multiple values for the same record type, you
must save them in the values
for the relevant type. This means, you must
delete the relevant record and add a new addition
object for this type
to the request, in case you want to add values for an existing DNS record
type.
Important: This call requires an account level API key and cannot be authenticated with the standard authorization header.
Domain to update the DNS zone for. Must include the TLD.
DNS records to add to the DNS zone.
Max: 10 additions
DNS records to remove from the DNS zone.
Max: 10 deletions
Whether you want to enable or disable DNS Security Extensions (DNSSEC).
Updated DNS zone.
curl -X PATCH
'https://www.wixapis.com/domains/v1/dns-zones/mysite.com' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'Authorization: <AUTH>' \
-d '{
"deletions": [
{
"values": "google-site-verification=epsWybsHVqJqkw0dD2xrIaSO_jYJAmczAU7IqLWToVM",
"type": "TXT",
"hostName": "mysite.com",
"ttl": 3600
}
],
"additions": [
{
"values": "10 aspmx.l.google.com",
"type": "MX",
"hostName": "mysite.com",
"ttl": 3600
}
],
"domainName": "mysite.com"
}'
{
"dnsZone": {
"records": [
{
"values": ["10 aspmx.l.google.com"],
"ttl": 3600,
"hostName": "mysite.com",
"type": "MX"
}
],
"domainName": "mysite.com"
}
}
Generates a preview for a DNS zone based on Google's Cloud DNS.
This includes calculating the A
, CNAME
, NS
and SOA
records.
You can use this information to configure a domain from an external
provider, before connecting it to a Wix site.
Important: This call requires an account level API key and cannot be authenticated with the standard authorization header.
Domain name to generate a DNS zone preview for.
DNS zone preview.
Includes calculated A
, CNAME
, NS
and SOA
records.
curl -X GET
'https://www.wixapis.com/domains/v1/dns-zones/mysite.com/preview' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'Authorization: <AUTH>' \
{
"dnsZone": {
"records": [
{
"values": ["10 aspmx.l.google.com"],
"ttl": 3600,
"hostName": "mysite.com",
"type": "MX"
}
],
"domainName": "mysite.com"
}
}