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
.To use the DomainDns API, install the @wix/domains
package using npm or Yarn:
npm install @wix/domains
or
yarn add @wix/domains
Then import { domainDns }
from @wix/domains
:
import { domainDns } from "@wix/domains";
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.
function createDnsZone(dnsZone: DnsZone): Promise<DnsZone>;
DNS zone to create.
import { createClient, ApiKeyStrategy } from "@wix/sdk";
import { domainDns } from "@wix/domains";
const wixClient = createClient({
modules: { domainDns },
auth: ApiKeyStrategy({
siteId: "MY-SITE-ID",
apiKey: "MY-API-KEY",
}),
});
async function createDnsZone(dnsZone) {
const response = await domainDns.createDnsZone(dnsZone);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
function deleteDnsZone(domainName: string): Promise<void>;
Domain name to delete the DNS zone for.
import { createClient, ApiKeyStrategy } from "@wix/sdk";
import { domainDns } from "@wix/domains";
const wixClient = createClient({
modules: { domainDns },
auth: ApiKeyStrategy({
siteId: "MY-SITE-ID",
apiKey: "MY-API-KEY",
}),
});
async function deleteDnsZone(domainName) {
const response = await domainDns.deleteDnsZone(domainName);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.