> 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

# CreateConnectedDomain

# Package: connectedDomains

# Namespace: ConnectedDomainService

# Method link: https://dev.wix.com/docs/api-reference/account-level/domains/connected-domains/connected-domain-v1/create-connected-domain.md

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

## Introduction

Creates a `connectedDomain` object and starts the domain connection process.
It may take up to 48 hours for the DNS changes to take effect.


You must pass the relevant Wix account ID in the header of the call.
You may also pass a Wix site ID in the header.

You can only connect external domains using this endpoint. Domains purchased
and billed through Wix can't be connected via this endpoint to a Wix site.

You can connect both root domains and subdomains to Wix sites.

The domain can be assigned as a primary domain or a redirect.
You can read more about [primary and redirected domains](https://support.wix.com/en/article/switching-your-primary-and-redirected-domains).
If you connect a domain as `"PRIMARY"` to a Wix site, the existing primary
domain automatically becomes unassigned.

> __Important:__ This call requires an account level API key and cannot be authenticated with the standard authorization header.

---

## REST API

### Schema

```
 Method: createConnectedDomain
 Description: Creates a `connectedDomain` object and starts the domain connection process. It may take up to 48 hours for the DNS changes to take effect.   You must pass the relevant Wix account GUID in the header of the call. You may also pass a Wix site GUID in the header.  You can only connect external domains using this endpoint. Domains purchased and billed through Wix can't be connected via this endpoint to a Wix site.  You can connect both root domains and subdomains to Wix sites.  The domain can be assigned as a primary domain or a redirect. You can read more about [primary and redirected domains](https://support.wix.com/en/article/switching-your-primary-and-redirected-domains). If you connect a domain as `"PRIMARY"` to a Wix site, the existing primary domain automatically becomes unassigned.  > __Important:__ This call requires an account level API key and cannot be authenticated with the standard authorization header.
 URL: https://www.wixapis.com/domains/v1/connected-domains
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  connectedDomain, connectedDomain.domain
 Method parameters: 
   param name: connectedDomain | type: ConnectedDomain | description: A `connectedDomain` object holds information about an external domain and its connection to a Wix site. | required: true 
        - name: domain | type: string | description: Domain name including TLD. Both root domains and subdomains are supported. | required: true | validation: format HOSTNAME
        - name: connectionType | type: ConnectionType | description: How the domain is connected to the Wix site.  
             - enum:
             -     POINTING: The domain is connected by pointing. Wix doesn't manage DNS information.
             -     NAMESERVERS: The domain is connected by nameservers. Wix manages DNS information.
             -     HIDDEN: The domain isn't visible to site visitors.
        - name: siteInfo | type: SiteInfo | description: Information about the site to which the domain is assigned, and whether it's the primary domain or a redirect.  
           - name: assignmentType | type: AssignmentType | description: The relationship assigned for this domain to the site.  Read more about [primary and redirected domains](https://support.wix.com/en/article/switching-your-primary-and-redirected-domains).  
                 - enum:
                 -     PRIMARY: The singular primary domain for a site. When this type is assigned, this domain will lead directly to the site.
                 -     REDIRECT: A redirect domain for a site. Each site can have multiple redirect domains. When this type is assigned, this domain will redirect to the primary domain.
        - name: suppressNotifications | type: boolean | description: Whether the site owner receives standard email notifications from Wix about the connected domain.  Default: `false`  
 Return type: CreateConnectedDomainResponse
  - name: connectedDomain | type: ConnectedDomain | description: Connected domain.  
     - name: id | type: string | description: GUID of the connected domain. Identical to the domain name including TLD.  | read-only: true | validation: format HOSTNAME
     - name: domain | type: string | description: Domain name including TLD. Both root domains and subdomains are supported.  | validation: format HOSTNAME
     - name: connectionType | type: ConnectionType | description: How the domain is connected to the Wix site.  
         - enum:
         -     POINTING: The domain is connected by pointing. Wix doesn't manage DNS information.
         -     NAMESERVERS: The domain is connected by nameservers. Wix manages DNS information.
         -     HIDDEN: The domain isn't visible to site visitors.
     - name: siteInfo | type: SiteInfo | description: Information about the site to which the domain is assigned, and whether it's the primary domain or a redirect.  
        - ONE-OF: 
           - name: redirectInfo | type: RedirectAssignmentInfo | description: Redirect information, relevant when `assignmentType` = `REDIRECT`.  | read-only: true 
              - name: primaryDomain | type: string | description: Primary domain to which this domain will redirect.  | read-only: true | validation: format HOSTNAME
        - name: id | type: string | description: GUID of the site to which the domain is assigned.  | read-only: true | validation: format GUID
        - name: assignmentType | type: AssignmentType | description: The relationship assigned for this domain to the site.  Read more about [primary and redirected domains](https://support.wix.com/en/article/switching-your-primary-and-redirected-domains).  
             - enum:
             -     PRIMARY: The singular primary domain for a site. When this type is assigned, this domain will lead directly to the site.
             -     REDIRECT: A redirect domain for a site. Each site can have multiple redirect domains. When this type is assigned, this domain will redirect to the primary domain.
     - name: suppressNotifications | type: boolean | description: Whether the site owner receives standard email notifications from Wix about the connected domain.  Default: `false`  
     - name: dnsPropagationStatus | type: DnsPropagationStatus | description: DNS propagation status.  | read-only: true 
         - enum:
         -     COMPLETED: The domain's DNS propagation process has successfully finished.
         -     FAILED: The domain's DNS propagation process has failed.
         -     IN_PROGRESS: The domain's DNS propagation process has started but hasn't successfully completed yet.
     - name: createdDate | type: string | description: Date and time the `connectedDomain` object was created in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the `connectedDomain` object was last updated in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true | validation: format date-time


```

### Examples

### Connect a subdomain
```curl
curl -X POST 'https://www.wixapis.com/domains/v1/connected-domains' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'wix-site-id: <SITE_ID>' \
-H 'Authorization: <AUTH>' \
-d '{
     "connectedDomain": {
       "domain": "sub.mysite.com",
      "suppressNotifications": true
     }
   }'
```

### Connect a domain by pointing
```curl
curl -X POST 'https://www.wixapis.com/domains/v1/connected-domains' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'wix-site-id: <SITE_ID>' \
-H 'Authorization: <AUTH>' \
-d '{
     "connectedDomain": {
       "domain": "mysite.com",
       "connectionType": "POINTING",
       "siteInfo": {
           "assignmentType": "PRIMARY"
       }
     }
   }'
```

### Connect a domain using nameservers
```curl
curl -X POST 'https://www.wixapis.com/domains/v1/connected-domains' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'wix-site-id: <SITE_ID>' \
-H 'Authorization: <AUTH>' \
-d '{
     "connectedDomain": {
       "domain": "mysite.com",
       "connectionType": "NAMESERVERS",
       "siteInfo": {
           "assignmentType": "PRIMARY"
       }
     }
   }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.domains.connectedDomains.createConnectedDomain(connectedDomain)
 Description: Creates a `connectedDomain` object and starts the domain connection process. It may take up to 48 hours for the DNS changes to take effect.   You must pass the relevant Wix account GUID in the header of the call. You may also pass a Wix site GUID in the header.  You can only connect external domains using this endpoint. Domains purchased and billed through Wix can't be connected via this endpoint to a Wix site.  You can connect both root domains and subdomains to Wix sites.  The domain can be assigned as a primary domain or a redirect. You can read more about [primary and redirected domains](https://support.wix.com/en/article/switching-your-primary-and-redirected-domains). If you connect a domain as `"PRIMARY"` to a Wix site, the existing primary domain automatically becomes unassigned.  > __Important:__ This call requires an account level API key and cannot 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:  connectedDomain, connectedDomain.domain
 Method parameters: 
   param name: connectedDomain | type: ConnectedDomain | description: A `connectedDomain` object holds information about an external domain and its connection to a Wix site. | required: true 
        - name: domain | type: string | description: Domain name including TLD. Both root domains and subdomains are supported. | required: true | validation: format HOSTNAME
        - name: connectionType | type: ConnectionType | description: How the domain is connected to the Wix site.  
             - enum:
             -     POINTING: The domain is connected by pointing. Wix doesn't manage DNS information.
             -     NAMESERVERS: The domain is connected by nameservers. Wix manages DNS information.
             -     HIDDEN: The domain isn't visible to site visitors.
        - name: siteInfo | type: SiteInfo | description: Information about the site to which the domain is assigned, and whether it's the primary domain or a redirect.  
           - name: assignmentType | type: AssignmentType | description: The relationship assigned for this domain to the site.  Read more about [primary and redirected domains](https://support.wix.com/en/article/switching-your-primary-and-redirected-domains).  
                 - enum:
                 -     PRIMARY: The singular primary domain for a site. When this type is assigned, this domain will lead directly to the site.
                 -     REDIRECT: A redirect domain for a site. Each site can have multiple redirect domains. When this type is assigned, this domain will redirect to the primary domain.
        - name: suppressNotifications | type: boolean | description: Whether the site owner receives standard email notifications from Wix about the connected domain.  Default: `false`  
 Return type: PROMISE<ConnectedDomain>
  - name: _id | type: string | description: GUID of the connected domain. Identical to the domain name including TLD.  | read-only: true | validation: format HOSTNAME
  - name: domain | type: string | description: Domain name including TLD. Both root domains and subdomains are supported.  | validation: format HOSTNAME
  - name: connectionType | type: ConnectionType | description: How the domain is connected to the Wix site.  
     - enum:
     -     POINTING: The domain is connected by pointing. Wix doesn't manage DNS information.
     -     NAMESERVERS: The domain is connected by nameservers. Wix manages DNS information.
     -     HIDDEN: The domain isn't visible to site visitors.
  - name: siteInfo | type: SiteInfo | description: Information about the site to which the domain is assigned, and whether it's the primary domain or a redirect.  
     - ONE-OF: 
        - name: redirectInfo | type: RedirectAssignmentInfo | description: Redirect information, relevant when `assignmentType` = `REDIRECT`.  | read-only: true 
           - name: primaryDomain | type: string | description: Primary domain to which this domain will redirect.  | read-only: true | validation: format HOSTNAME
     - name: _id | type: string | description: GUID of the site to which the domain is assigned.  | read-only: true | validation: format GUID
     - name: assignmentType | type: AssignmentType | description: The relationship assigned for this domain to the site.  Read more about [primary and redirected domains](https://support.wix.com/en/article/switching-your-primary-and-redirected-domains).  
         - enum:
         -     PRIMARY: The singular primary domain for a site. When this type is assigned, this domain will lead directly to the site.
         -     REDIRECT: A redirect domain for a site. Each site can have multiple redirect domains. When this type is assigned, this domain will redirect to the primary domain.
  - name: suppressNotifications | type: boolean | description: Whether the site owner receives standard email notifications from Wix about the connected domain.  Default: `false`  
  - name: dnsPropagationStatus | type: DnsPropagationStatus | description: DNS propagation status.  | read-only: true 
     - enum:
     -     COMPLETED: The domain's DNS propagation process has successfully finished.
     -     FAILED: The domain's DNS propagation process has failed.
     -     IN_PROGRESS: The domain's DNS propagation process has started but hasn't successfully completed yet.
  - name: _createdDate | type: Date | description: Date and time the `connectedDomain` object was created in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the `connectedDomain` object was last updated in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true 


```

### Examples

### Create a connected domain with an API key
```javascript
import { createClient, ApiKeyStrategy } from "@wix/sdk";
import { connectedDomains } from "@wix/domains";

const wixClient = createClient({
 modules: { connectedDomains },
 auth: ApiKeyStrategy({
    siteId: "MY-SITE-ID",
    apiKey: "MY-API-KEY",
  }),
});

async function createConnectedDomain(connectedDomain) {
  const response = await wixClient.connectedDomains.createConnectedDomain(connectedDomain);
}

```

### Connect a domain using nameservers
```javascript
// @description: Creates a connected domain with NAMESERVERS connection type and PRIMARY assignment.

import { createClient, ApiKeyStrategy } from "@wix/sdk";
import { connectedDomains } from "@wix/domains";

const connectedDomain = {
  domain: "mysite.com",
  connectionType: "NAMESERVERS" as const,
  siteInfo: {
    assignmentType: "PRIMARY" as const,
  },
};

async function createConnectedDomainExample() {
  const wixClient = createClient({
    modules: { connectedDomains },
    auth: ApiKeyStrategy({
      siteId: process.env.WIX_SITE_ID!,
      apiKey: process.env.WIX_API_KEY!,
    }),
  });

  const response = await wixClient.connectedDomains.createConnectedDomain(connectedDomain);
  return response;
}

/* Promise resolves to:
 * {
 *   connectedDomain: {
 *     _id: "mysite.com",
 *     domain: "mysite.com",
 *     connectionType: "NAMESERVERS",
 *     siteInfo: { id: "<SITE_ID>", assignmentType: "PRIMARY" },
 *     suppressNotifications: false,
 *     dnsPropagationStatus: string
 *   }
 * }
 */

```

### Connect a subdomain
```javascript
// @description: Creates a connected subdomain with suppressNotifications enabled.

import { createClient, ApiKeyStrategy } from "@wix/sdk";
import { connectedDomains } from "@wix/domains";

const connectedDomain = {
  domain: "sub.mysite.com",
  suppressNotifications: true,
};

async function createConnectedDomainExample() {
  const wixClient = createClient({
    modules: { connectedDomains },
    auth: ApiKeyStrategy({
      siteId: process.env.WIX_SITE_ID!,
      apiKey: process.env.WIX_API_KEY!,
    }),
  });

  const response = await wixClient.connectedDomains.createConnectedDomain(connectedDomain);
  return response;
}

/* Promise resolves to:
 * {
 *   connectedDomain: {
 *     _id: "sub.mysite.com",
 *     domain: "sub.mysite.com",
 *     connectionType: string,
 *     siteInfo: { id: "<SITE_ID>", assignmentType: "PRIMARY" },
 *     suppressNotifications: true,
 *     dnsPropagationStatus: string
 *   }
 * }
 */

```

### Connect a domain by pointing
```javascript
// @description: Creates a connected domain with POINTING connection type and PRIMARY assignment.

import { createClient, ApiKeyStrategy } from "@wix/sdk";
import { connectedDomains } from "@wix/domains";

const connectedDomain = {
  domain: "mysite.com",
  connectionType: "POINTING" as const,
  siteInfo: {
    assignmentType: "PRIMARY" as const,
  },
};

async function createConnectedDomainExample() {
  const wixClient = createClient({
    modules: { connectedDomains },
    auth: ApiKeyStrategy({
      siteId: process.env.WIX_SITE_ID!,
      apiKey: process.env.WIX_API_KEY!,
    }),
  });

  const response = await wixClient.connectedDomains.createConnectedDomain(connectedDomain);
  return response;
}

/* Promise resolves to:
 * {
 *   connectedDomain: {
 *     _id: "mysite.com",
 *     domain: "mysite.com",
 *     connectionType: "POINTING",
 *     siteInfo: { id: "<SITE_ID>", assignmentType: "PRIMARY" },
 *     suppressNotifications: false,
 *     dnsPropagationStatus: string
 *   }
 * }
 */

```

### createConnectedDomain (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 { connectedDomains } from '@wix/domains';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function createConnectedDomain(connectedDomain) {
  const response = await myWixClient.connectedDomains.createConnectedDomain(connectedDomain);
};
```

---