> 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`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# SetDomainAsPrimary

# Package: domains

# Namespace: DomainAssignmentService

# Method link: https://dev.wix.com/docs/api-reference/account-level/domains/domain-assignments/set-domain-as-primary.md

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

## Introduction

Sets a domain as the primary domain of the site it's assigned to.


The site's previous primary domain becomes a redirect, and all of the site's
redirect domains point to the new primary domain. If the domain is already the
site's primary domain, the domain assignment is returned unchanged.

To assign a domain to a site, call
[Upsert Domain Assignment](https://dev.wix.com/docs/api-reference/account-level/domains/domain-assignments/upsert-domain-assignment.md).

You must specify the Wix account ID in the `wix-account-id` header.

---

## REST API

### Schema

```
 Method: setDomainAsPrimary
 Description: Sets a domain as the primary domain of the site it's assigned to.   The site's previous primary domain becomes a redirect, and all of the site's redirect domains point to the new primary domain. If the domain is already the site's primary domain, the domain assignment is returned unchanged.  To assign a domain to a site, call [Upsert Domain Assignment](https://dev.wix.com/docs/api-reference/account-level/domains/domain-assignments/upsert-domain-assignment.md).  You must specify the Wix account GUID in the `wix-account-id` header.
 URL: https://www.wixapis.com/domains/v1/domain-assignments/{domainAssignmentId}
 Method: PATCH
 Return type: SetDomainAsPrimaryResponse
  - name: domainAssignment | type: DomainAssignment | description: Updated domain assignment.  
     - name: id | type: string | description: Domain assignment GUID. Identical to `domain`.  | read-only: true | validation: format HOSTNAME
     - name: domain | type: string | description: Domain name, including the top-level domain. For example, `mystunningsite.com`.  | validation: format HOSTNAME
     - name: siteInfo | type: SiteInfo | description: Site the domain is assigned to, and whether the domain is the site's primary domain or a redirect.  
        - ONE-OF: 
           - name: redirectInfo | type: RedirectAssignmentInfo | description: Redirect details.  Returned only when `assignmentType` is `REDIRECT`.  | read-only: true 
              - name: primaryDomain | type: string | description: Primary domain that this domain redirects to.  | read-only: true | validation: format HOSTNAME
        - name: id | type: string | description: GUID of the site the domain is assigned to.  Required unless the request header specifies the site GUID. If you specify the site GUID in both places, the GUIDs must be identical.  | validation: format GUID
        - name: assignmentType | type: AssignmentType | description: Whether the domain is the site's primary domain or a redirect to the site's primary domain.  
             - enum:
             -     PRIMARY: Site's primary domain. Visitors who enter this domain reach the site directly.
             -     REDIRECT: Domain that redirects visitors to the site's primary domain. A site can have up to 300 redirect domains.
     - name: createdDate | type: string | description: Date and time the domain assignment was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the domain assignment was last updated.  | read-only: true | validation: format date-time


```

### Examples

### Set a redirect domain as the site's primary domain
Sets a redirect domain as the site's primary domain. The site's previous primary domain becomes a redirect.

```curl
curl -X PATCH \
'https://www.wixapis.com/domains/v1/domain-assignments/mystunningsite.net' \
-H 'wix-account-id: <ACCOUNT_ID>' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.domains.domainAssignments.setDomainAsPrimary(domainAssignmentId)
 Description: Sets a domain as the primary domain of the site it's assigned to.   The site's previous primary domain becomes a redirect, and all of the site's redirect domains point to the new primary domain. If the domain is already the site's primary domain, the domain assignment is returned unchanged.  To assign a domain to a site, call [Upsert Domain Assignment](https://dev.wix.com/docs/api-reference/account-level/domains/domain-assignments/upsert-domain-assignment.md).  You must specify the Wix account GUID in the `wix-account-id` header.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  domainAssignmentId
 Method parameters: 
   param name: domainAssignmentId | type: string | description: GUID of the domain assignment whose domain to set as primary. Identical to the domain name. | required: true | validation: format HOSTNAME
 Return type: PROMISE<SetDomainAsPrimaryResponse>
  - name: domainAssignment | type: DomainAssignment | description: Updated domain assignment.  
     - name: _id | type: string | description: Domain assignment GUID. Identical to `domain`.  | read-only: true | validation: format HOSTNAME
     - name: domain | type: string | description: Domain name, including the top-level domain. For example, `mystunningsite.com`.  | validation: format HOSTNAME
     - name: siteInfo | type: SiteInfo | description: Site the domain is assigned to, and whether the domain is the site's primary domain or a redirect.  
        - ONE-OF: 
           - name: redirectInfo | type: RedirectAssignmentInfo | description: Redirect details.  Returned only when `assignmentType` is `REDIRECT`.  | read-only: true 
              - name: primaryDomain | type: string | description: Primary domain that this domain redirects to.  | read-only: true | validation: format HOSTNAME
        - name: _id | type: string | description: GUID of the site the domain is assigned to.  Required unless the request header specifies the site GUID. If you specify the site GUID in both places, the GUIDs must be identical.  | validation: format GUID
        - name: assignmentType | type: AssignmentType | description: Whether the domain is the site's primary domain or a redirect to the site's primary domain.  
             - enum:
             -     PRIMARY: Site's primary domain. Visitors who enter this domain reach the site directly.
             -     REDIRECT: Domain that redirects visitors to the site's primary domain. A site can have up to 300 redirect domains.
     - name: _createdDate | type: Date | description: Date and time the domain assignment was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the domain assignment was last updated.  | read-only: true 


```

### Examples

### Set a redirect domain as the site's primary domain
Sets a redirect domain as the site's primary domain. The site's previous primary domain becomes a redirect.

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

async function setDomainAsPrimary() {
  const response =
    await domainAssignments.setDomainAsPrimary("mystunningsite.net");
}

/* Promise resolves to:
 * {
 *   "domainAssignment": {
 *     "_id": "mystunningsite.net",
 *     "domain": "mystunningsite.net",
 *     "siteInfo": {
 *       "id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *       "assignmentType": "PRIMARY"
 *     },
 *     "_createdDate": "2026-11-01T10:30:00.000Z",
 *     "_updatedDate": "2026-11-01T11:05:12.000Z"
 *   }
 * }
 */

```

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

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


async function setDomainAsPrimary(domainAssignmentId) {
  const response = await myWixClient.domainAssignments.setDomainAsPrimary(domainAssignmentId);
};
```

---